diff --git a/.circleci/config.yml b/.circleci/config.yml index 14c66a50..9f6f5736 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -177,6 +177,12 @@ jobs: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf - attach_workspace: at: ~/uport-mobile + - run: + name: Install appium server + command: | + npm install -g appium + npm install wd + pip install Appium-Python-Client - restore_cache: keys: - bundle-{{ arch }}-v4-ios-{{ checksum "Gemfile.lock" }} @@ -198,6 +204,17 @@ jobs: - run: name: Fastlane command: cd ~/uport-mobile/ios && bundle exec fastlane buildTheApp + - run: + name: Build debug version of app + command: | + yarn global add react-native-cli + yarn + react-native run-ios + - run: + command: | + npm run start-appium-server + sleep 5 + npm run run-appium-tests - persist_to_workspace: root: ~/uport-mobile paths: diff --git a/package.json b/package.json index 03b006a8..6579d391 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,9 @@ "android-release": "cd android && ./gradlew assembleRelease && cd ..", "package-android": "mkdir -p android/app/build/jsbundle/assets/ && mkdir -p android/app/build/jsbundle/res && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/build/jsbundle/assets/index.android.bundle --assets-dest android/app/build/jsbundle/res", "package-android-release": "cd android && ./gradlew clean && cd - && mkdir -p android/app/build/jsbundle/assets/ && mkdir -p android/app/build/jsbundle/res && node node_modules/react-native/local-cli/cli.js bundle --platform android --dev false --entry-file index.js --bundle-output android/app/build/jsbundle/assets/index.android.bundle --assets-dest android/app/build/jsbundle/res && cd android && ./gradlew deliverArchives -x bundleReleaseJsAndAssets", - "package-android-dummy": "cd android && ./gradlew clean && cd - && yarn package-android && cd android && ./gradlew deliverArchives -x bundleReleaseJsAndAssets -PIGNORE_VAULT=true -PIGNORE_REPOSITORY_STATE=true" + "package-android-dummy": "cd android && ./gradlew clean && cd - && yarn package-android && cd android && ./gradlew deliverArchives -x bundleReleaseJsAndAssets -PIGNORE_VAULT=true -PIGNORE_REPOSITORY_STATE=true", + "start-appium-server": "./testsuites/terminal.scpt", + "run-appium-tests": "python testsuites/test.py" }, "jest": { "preset": "react-native", @@ -180,6 +182,7 @@ "@types/react-native-vector-icons": "^4.6.4", "@types/react-redux": "^7.0.0", "@types/react-test-renderer": "^16.0.3", + "appium": "^1.14.0", "babel-jest": "^24.8.0", "browserify": "^16.2.0", "codecov": "^3.5.0", @@ -216,7 +219,8 @@ "tslint-config-prettier": "^1.17.0", "tslint-eslint-rules": "^5.4.0", "tslint-react": "^3.6.0", - "typescript": "^3.2.4" + "typescript": "^3.2.4", + "wd": "^1.11.3" }, "browser": { "stream": false, diff --git a/testsuites/support/__init__.py b/testsuites/support/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/testsuites/support/__init__.pyc b/testsuites/support/__init__.pyc new file mode 100644 index 00000000..6b08879c Binary files /dev/null and b/testsuites/support/__init__.pyc differ diff --git a/testsuites/support/common_methods.py b/testsuites/support/common_methods.py new file mode 100644 index 00000000..f7851ccd --- /dev/null +++ b/testsuites/support/common_methods.py @@ -0,0 +1,23 @@ +from os import getcwd, chdir +import glob +import os + +def select_element(driverinfo, elem): + + return driverinfo.find_element_by_id(elem) + + + +def find_uportapp(): + folder = 'Debug-*' + current_dir = os.path.abspath(os.path.dirname(__file__)) + direct = os.path.join(os.path.abspath(current_dir + "/../../"),"ios", "build", "Build", "Products") + saved = getcwd() + chdir(direct) + it = glob.glob(folder) + chdir(saved) + return (" ".join(it)) + + + + diff --git a/testsuites/terminal.scpt b/testsuites/terminal.scpt new file mode 100755 index 00000000..08ef9c43 --- /dev/null +++ b/testsuites/terminal.scpt @@ -0,0 +1,3 @@ +osascript -e 'tell app "Terminal" + do script "appium" +end tell' diff --git a/testsuites/test.py b/testsuites/test.py new file mode 100644 index 00000000..b4787af2 --- /dev/null +++ b/testsuites/test.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from appium import webdriver +from appium.webdriver.common.touch_action import TouchAction +from support.common_methods import select_element, find_uportapp +from os.path import expanduser + +import unittest +import os +import glob +import shutil + + +class identityTests(unittest.TestCase): + + def test_createIdentity(self): + this_dir = os.path.abspath(os.path.dirname(__file__)) + print this_dir + " **file directory" + #uportapp = find_uportapp() + desired_caps = {} + desired_caps['platformName'] = 'iOS' + desired_caps['platformVersion'] = '12.1' + desired_caps['deviceName'] = 'iPhone XR' # Run on simulator + cwd = os.getcwd() + print cwd + " **current directory" + current_dir = os.path.abspath(os.path.dirname(__file__)) + desired_caps['app'] = os.path.join(os.path.abspath(current_dir + "/../"),"ios", "build", "uPortMobile", "Build", "Products", "Debug-iphonesimulator", "uPort.app") + + #desired_caps['fullReset'] = 'true' + desired_caps['automationName'] = "XCUITest" + self.wd = webdriver.Remote('http://0.0.0.0:4723/wd/hub', desired_caps) + + self.wd.implicitly_wait(10) + #screenshot + directory = '%s/' % os.getcwd() + file_name = 'screenshot.png' + self.wd.save_screenshot(directory + file_name) + + self.assertTrue(select_element(self.wd, "Dismiss All").is_displayed()) #dismiss + select_element(self.wd, "Dismiss All").click() + + self.assertTrue(select_element(self.wd, "ONBOARDING_GET_STARTED").is_displayed()) #select onboarding + select_element(self.wd, "ONBOARDING_GET_STARTED").click() + + self.assertTrue(select_element(self.wd, "ONBOARDING_LEARN_CONTINUE").is_displayed()) #select onboarding + select_element(self.wd, "ONBOARDING_LEARN_CONTINUE").click() + + #type in uport user and press enter ("\n") + self.wd.find_element_by_id("Enter name or username").send_keys('Sanaa'+"\n") + + self.wd.implicitly_wait(5) + + self.assertTrue(select_element(self.wd, "ONBOARDING_TERMS_RADIO").is_displayed()) #terms + select_element(self.wd, "ONBOARDING_TERMS_RADIO").click() + + + self.assertTrue(select_element(self.wd, "ONBOARDING_PRIVACY_RADIO").is_displayed()) #terms + select_element(self.wd, "ONBOARDING_PRIVACY_RADIO").click() + + self.assertTrue(select_element(self.wd, "ONBOARDING_CREATE_IDENTITY").is_displayed()) #create identity + select_element(self.wd, "ONBOARDING_CREATE_IDENTITY").click() + + + # notifications permissions + if self.assertFalse(select_element(self.wd, "Allow").is_displayed()): + select_element(self.wd, "").click() + elif self.assertTrue(select_element(self.wd, "Allow").is_displayed()): + select_element(self.wd, "Allow").click() + + + #verify did is created + #self.assertTrue(select_element(self.wd, "uPort ID ").is_displayed()) + #select_element(self.wd, "uPort ID ").click() + + #self.assertTrue(select_element(self.wd, "DID did:ethr:0x6...").is_displayed()) + #select_element(self.wd, "DID did:ethr:0x6...").click() + + + + + + + +if __name__ == '__main__': + unittest.main()