diff --git a/SETUP.md b/SETUP.md index 2ddd793a2f9..c649f68f500 100644 --- a/SETUP.md +++ b/SETUP.md @@ -248,7 +248,7 @@ export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$PATH Run the emulator with: ```bash -emulator -avd Nexus_5X_API_28 +emulator -avd Nexus_5X_API_28_x86 ``` #### Optional: Install Genymotion Emulator Manager diff --git a/packages/mobile/.env b/packages/mobile/.env index f3ce19e1ed2..bd9eb273058 100644 --- a/packages/mobile/.env +++ b/packages/mobile/.env @@ -1,5 +1,5 @@ ENVIRONMENT=local -DEFAULT_TESTNET=alfajoresstaging +DEFAULT_TESTNET=integration # If ZERO_SYNC_ENABLED_INITIALLY, local geth will not run initially. # If toggled on, it will use DEFAULT_SYNC_MODE. See src/geth/consts.ts for more info ZERO_SYNC_ENABLED_INITIALLY=false diff --git a/packages/mobile/.env.test b/packages/mobile/.env.test index 240cedb61f0..84d954a7498 100644 --- a/packages/mobile/.env.test +++ b/packages/mobile/.env.test @@ -5,7 +5,8 @@ DEFAULT_TESTNET=integration ZERO_SYNC_ENABLED_INITIALLY=true DEFAULT_SYNC_MODE=5 DEV_SETTINGS_ACTIVE_INITIALLY=true +# Disable firebase b.c. google-services.json files are missing in CI FIREBASE_ENABLED=false SECRETS_KEY=debug SHOW_TESTNET_BANNER=false -SHOW_GET_INVITE_LINK=true \ No newline at end of file +SHOW_GET_INVITE_LINK=true \ No newline at end of file diff --git a/packages/mobile/README.md b/packages/mobile/README.md index ea579e13326..40e0a7e8dc1 100644 --- a/packages/mobile/README.md +++ b/packages/mobile/README.md @@ -88,13 +88,6 @@ renders when no state has changed. Reducing renders can be done via pure components in react or overloading the should component update method [example here][rn optimize example]. -### Connecting to networks - -By default, we have the `alfajores` network set up. If you have other testnets -that you want to use with the app, update `.env.ENV-NAME` and `packages/mobile/.env.ENV-NAME` with -the new network name and settings, then rebuild the app. Note that this will assume the testnets -have a corresponding `/blockchain-api` and `/notification-service` set up. - ### Running Wallet app in zero sync (Data Saver) mode By default, the mobile wallet app runs geth in ultralight sync mode where all the epoch headers are fetched. The default sync mode is defined in [packages/mobile/.env](https://github.com/celo-org/celo-monorepo/blob/master/packages/mobile/.env#L4) file. @@ -130,21 +123,9 @@ See [`src/identity/verification.test.ts`] for an example. ### E2E testing We use [Detox][detox] for E2E testing. In order to run the tests locally, you -must have the proper emulator set up. Emulator installation instructions are in -the [setup instructions][setup#emulator]. - -Please set `123456` as the pin code in the emulator, since the e2e tests rely on -that. - -Next, the VM snapshot settings should be modified: - -1. Close all apps and lock the emulator (go to lock screen). -2. Power off the emulator -3. Power it back on and go to emulator settings (... button) -> Snapshots -> Settings -4. Set Auto-Save to No +must have the proper emulator set up. Follow the instrutions in [e2e/README.md][e2e readme]. -For information on how to run and extend the e2e tests, refer to the -[e2e readme][e2e readme]. +Once setup is done, you can run the tests with `yarn test:e2e:android` ## Building APKs / Bundles @@ -264,7 +245,6 @@ $ adb kill-server && adb start-server [rn profiler]: https://reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html [rn running on device]: https://facebook.github.io/react-native/docs/running-on-device [setup]: ../../SETUP.md -[setup#emulator]: ../../SETUP.md#optional-install-an-android-emulator [react-native-testing-library]: https://github.com/callstack/react-native-testing-library [rntl-docs]: https://callstack.github.io/react-native-testing-library/ [jest]: https://jestjs.io/docs/en/snapshot-testing diff --git a/packages/mobile/android/app/build.gradle b/packages/mobile/android/app/build.gradle index a764b2db6c8..122e5ee7981 100644 --- a/packages/mobile/android/app/build.gradle +++ b/packages/mobile/android/app/build.gradle @@ -252,10 +252,8 @@ android { packagingOptions { exclude 'META-INF/-no-jdk.kotlin_module' exclude 'META-INF/androidx.exifinterface_exifinterface.version' - pickFirst 'lib/x86/libc++_shared.so' - pickFirst 'lib/arm64-v8a/libc++_shared.so' - pickFirst 'lib/x86_64/libc++_shared.so' - pickFirst 'lib/armeabi-v7a/libc++_shared.so' + pickFirst '**/libjsc.so' + pickFirst '**/libc++_shared.so' } diff --git a/packages/mobile/android/app/proguard-rules.pro b/packages/mobile/android/app/proguard-rules.pro index 456fc255a96..caad5acc802 100644 --- a/packages/mobile/android/app/proguard-rules.pro +++ b/packages/mobile/android/app/proguard-rules.pro @@ -9,6 +9,9 @@ # Add any project specific keep options here: +# Detox +-keep class com.facebook.react.ReactInstanceManager { *; } + # RN Firebase -keep class io.invertase.firebase.** { *; } -dontwarn io.invertase.firebase.** diff --git a/packages/mobile/android/app/src/debug/AndroidManifest.xml b/packages/mobile/android/app/src/debug/AndroidManifest.xml index 24425d92863..44a7e108063 100644 --- a/packages/mobile/android/app/src/debug/AndroidManifest.xml +++ b/packages/mobile/android/app/src/debug/AndroidManifest.xml @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/packages/mobile/android/app/src/debug/res/xml/network_security_config.xml b/packages/mobile/android/app/src/debug/res/xml/network_security_config.xml new file mode 100644 index 00000000000..598e8250cd6 --- /dev/null +++ b/packages/mobile/android/app/src/debug/res/xml/network_security_config.xml @@ -0,0 +1,10 @@ + + + + + localhost + 10.0.1.1 + 10.0.2.2 + 10.0.3.2 + + \ No newline at end of file diff --git a/packages/mobile/e2e/README.md b/packages/mobile/e2e/README.md index 8fd4a9695d6..1d6adbfbbb1 100644 --- a/packages/mobile/e2e/README.md +++ b/packages/mobile/e2e/README.md @@ -2,46 +2,21 @@ [![e2e test status](https://storage.googleapis.com/celo-e2e-data/e2e-banner.svg)](https://console.cloud.google.com/storage/browser/celo-e2e-data?project=celo-testnet) -These are the End-to-End (e2e) tests for the mobile (payments) application. They run an emulator and simulate a user clicking through the mobile app. +These are the End-to-End (e2e) tests for the wallet mobile app. They run an emulator and simulate a user clicking through the app. -## The e2e banner +## Setting up the VM -In the readme files (in the root, mobile, and this one), there are banners for the e2e tests. The test status is saved in a [google cloud storage bucket](https://console.cloud.google.com/storage/browser/celo-e2e-data?project=celo-testnet). -There is also a log file for the last test run. +First install the emulator as described in the [SETUP readme](../../../SETUP.md#optional-install-an-android-emulator). -Too see all the versions of the log file: +By default, the e2e scripts will assume the VM name of `Nexus_5X_API_28_x86` recommended in the instructions but you can rename the VM as you like. -```bash -gsutil ls -al gs://celo-e2e-data/last_run_log -``` +Next, to improve reliability of the tests, configure the VM as described in the [Detox best practices doc](https://github.com/wix/Detox/blob/master/docs/Introduction.AndroidEmulatorsBestPractices.md). -Too display a specific version of the log file: +## Running the tests -```bash -gsutil cat gs://celo-e2e-data/last_run_log# -gsutil cat gs://celo-e2e-data/last_run_log #specify no version number to get the latest -``` +Simply run `yarn test:e2e:android` or `yarn test:e2e:ios` -If you need to have a more detailed look, there is a collection of log files and even screenshots for the failing tests saved in `detailed_logs.tar.gz`. Download with: - -```bash - gsutil cp gs://celo-e2e-data/detailed_logs.tar.gz . - tar -xvf detailed_logs.tar.gz -``` - -These files are uploaded by by the [a script](../scripts/ci-e2e.sh), that is executed regularly. Don't use this script to run the tests locally. - -## Running the tests locally - -First install the emulator as described in the [mobile readme](../README.md). - -```bash -yarn test:build-e2e #To build the java parts -yarn test:run-e2e #packages the react native parts of the app, launches the emulator and runs the tests -``` - -After making small changes to the app or adding new tests you can rerun the tests without rebuilding first. -When the tests are running, they will automatically try to enter `123456` as the pin code when needed. You will have to set this pin code in the settings of the emulator. +The run_e2e.sh script will take care of configuring and building the app for you. ## Adding a test @@ -107,6 +82,33 @@ The e2e tests should use as few mocks as possible, since they are supposed to be The mocks are only used, when the environment variable `CELO_TEST_CONFIG` is set too 'e2e'. This variable will be read in `mobile/rn-cli.config.js` and will modify what the metro bundler will include in the bundle. If you're mocking a module from node_nodules, put the mock in `e2e/mocks/`. Use the file extension `.e2e.ts` or `.e2e.js`. +## The e2e banner + +In the readme files (in the root, mobile, and this one), there are banners for the e2e tests. The test status is saved in a [google cloud storage bucket](https://console.cloud.google.com/storage/browser/celo-e2e-data?project=celo-testnet). +There is also a log file for the last test run. + +Too see all the versions of the log file: + +```bash +gsutil ls -al gs://celo-e2e-data/last_run_log +``` + +Too display a specific version of the log file: + +```bash +gsutil cat gs://celo-e2e-data/last_run_log# +gsutil cat gs://celo-e2e-data/last_run_log #specify no version number to get the latest +``` + +If you need to have a more detailed look, there is a collection of log files and even screenshots for the failing tests saved in `detailed_logs.tar.gz`. Download with: + +```bash + gsutil cp gs://celo-e2e-data/detailed_logs.tar.gz . + tar -xvf detailed_logs.tar.gz +``` + +These files are uploaded by by the [a script](../scripts/ci-e2e.sh), that is executed regularly. Don't use this script to run the tests locally. + ## Troubleshooting If tests are failing, and you don't why: diff --git a/packages/mobile/e2e/Transfer.spec.js b/packages/mobile/e2e/Transfer.spec.js index b1c3ebe4d37..52ea0e121d7 100644 --- a/packages/mobile/e2e/Transfer.spec.js +++ b/packages/mobile/e2e/Transfer.spec.js @@ -93,28 +93,6 @@ describe('Transfer Works', () => { await sleep(10000) }) - it.skip('NUX->ImportContacts', async () => { - await device.launchApp({ permissions: { contacts: 'YES' } }) - - await waitFor(element(by.id('ImportContactsPermissionTitle'))) - .toBeVisible() - .withTimeout(1000) - - await waitFor(element(by.id('importContactsEnable'))) - .toBeVisible() - .withTimeout(1000) - - await waitFor(element(by.id('importContactsSkip'))) - .toBeVisible() - .withTimeout(1000) - - if (ENABLE_CONTACT_IMPORT) { - await element(by.id('importContactsEnable')).tap() - } else { - await element(by.id('importContactsSkip')).tap() - } - }) - it.skip('NUX->VerifyEducation', async () => { await waitFor(element(by.id('VerifyEducationHeader'))) .toBeVisible() diff --git a/packages/mobile/e2e/init.js b/packages/mobile/e2e/init.js index 7a444dcb994..b9c86120e7f 100644 --- a/packages/mobile/e2e/init.js +++ b/packages/mobile/e2e/init.js @@ -2,14 +2,23 @@ const detox = require('detox') const config = require('../package.json').detox const adapter = require('detox/runners/jest/adapter') const specReporter = require('detox/runners/jest/specReporter') +const assignReporter = require('detox/runners/jest/assignReporter') -jest.setTimeout(120000) jasmine.getEnv().addReporter(adapter) +// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level. +// This is strictly optional. jasmine.getEnv().addReporter(specReporter) +// This will post which device has assigned to run a suite, which can be useful in a multiple-worker tests run. +// This is strictly optional. +jasmine.getEnv().addReporter(assignReporter) + +// Increase default jest timeout +jest.setTimeout(120000) + beforeAll(async () => { await detox.init(config) -}) +}, 300000) beforeEach(async () => { await adapter.beforeEach() diff --git a/packages/mobile/package.json b/packages/mobile/package.json index fddeed99b45..5bc5af0e9c9 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -25,11 +25,8 @@ "test:ci": "yarn test --coverage --runInBand", "test:watch": "yarn test --watch --maxWorkers=4", "test:verbose": "export TZ=UTC && jest --verbose", - "test:build-e2e": "bash ./scripts/build_e2e.sh", - "test:run-e2e": "bash ./scripts/run_e2e.sh", - "test:dry-run-e2e": "yarn dev:emulator && cd android && yarn test:build-e2e && yarn test:run-e2e", - "test:detox": "CELO_TEST_CONFIG=e2e detox test -c android.emu.debug -a e2e/tmp/ --take-screenshots=failing --record-logs=failing --detectOpenHandles -l verbose", - "test:unlock": "./scripts/unlock.sh", + "test:e2e:android": "./scripts/run_e2e.sh -p android", + "test:e2e:ios": "./scripts/run_e2e.sh -p ios", "test:verify-locales": "./scripts/verify_locales.sh", "pre-deploy": "./scripts/pre-deploy.sh", "deploy:update-disclaimer": "yarn licenses generate-disclaimer > android/app/src/main/assets/custom/LicenseDisclaimer.txt" @@ -43,7 +40,7 @@ "@celo/client": "0.0.247", "@celo/contractkit": "0.2.10-dev", "@celo/react-components": "1.0.0", - "@celo/react-native-fast-crypto": "^1.8.2", + "react-native-fast-crypto": "git+https://github.com/celo-org/react-native-fast-crypto#3946f9", "@celo/react-native-sms-retriever": "git+https://github.com/celo-org/react-native-sms-retriever#b88e502", "@celo/utils": "0.1.6-dev", "@celo/walletkit": "^0.0.15", @@ -81,7 +78,7 @@ "react-i18next": "^11.2.7", "react-native": "^0.61.2", "react-native-android-open-settings": "^1.3.0", - "react-native-bip39": "git://github.com/celo-org/react-native-bip39#8d00738", + "react-native-bip39": "git://github.com/celo-org/react-native-bip39#b31a8ff", "react-native-camera": "^3.7.1", "react-native-clock-sync": "^1.0.0", "react-native-config": "https://github.com/luggit/react-native-config#89a602b", @@ -163,7 +160,7 @@ "@types/utf8": "^2.1.6", "@types/web3": "^1.0.18", "babel-core": "7.0.0-bridge.0", - "detox": "^14.5.0", + "detox": "^15.0.0", "enzyme": "^3.9.0", "enzyme-adapter-react-16": "^1.11.2", "enzyme-to-json": "^3.3.5", @@ -189,7 +186,7 @@ "configurations": { "android.emu.debug": { "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk", - "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..", + "build": "cd android && ENVFILE=.env.test ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..", "type": "android.emulator", "name": "Nexus_5X_API_28_x86", "__comment": "Nexus_5X_API_28_x86 is currently harcoded but it should be the result from $ANDROID_SDK_ROOT/emulator/emulator -list-avds | grep 'x86' | head -n 1`" diff --git a/packages/mobile/scripts/build_e2e.sh b/packages/mobile/scripts/build_e2e.sh deleted file mode 100755 index f73f0e0bcc0..00000000000 --- a/packages/mobile/scripts/build_e2e.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -##### -# This file creates apk that will be used for the tests -##### - -ENVFILE=".env.test" - -# set the IS_E2E_ENV value in .env during build only if it does not exist already -grep -qF -- "IS_E2E=1" $ENVFILE || printf "IS_E2E=1" >> $ENVFILE - -ENVFILE=$ENVFILE yarn detox build -c android.emu.debug - -# Remove the temp flag from file -sed -i '' '/IS_E2E=1/d' $ENVFILE diff --git a/packages/mobile/scripts/run_app.sh b/packages/mobile/scripts/run_app.sh index cffde243930..16dce06680c 100755 --- a/packages/mobile/scripts/run_app.sh +++ b/packages/mobile/scripts/run_app.sh @@ -1,26 +1,29 @@ #!/usr/bin/env bash set -euo pipefail -# ==================================== -# Configure and run the mobile app -# ==================================== +# ======================================== +# Configure, build, and run the mobile app +# ======================================== # Flags: -# -n: Name of the network to run on # -p: Platform (android or ios) -# -f: Fast (skip steps not required unless network or depedencies changes) -# -r: Hot Reload (Restore nav state on reload) +# -n (Optional): Name of the network to run on +# -f (Optional): Fast (skip steps not required unless network or depedencies changes) +# -r (Optional): Hot Reload (Restore nav state on reload, useful for UI dev-ing) +# -b (Optional): Just configure and build sdk, skip running NETWORK="" PLATFORM="" FAST=false HOT_RELOAD=false -while getopts 'n:p:fr' flag; do +BUILD_ONLY=false +while getopts 'p:n:frb' flag; do case "${flag}" in - n) NETWORK="$OPTARG" ;; p) PLATFORM="$OPTARG" ;; + n) NETWORK="$OPTARG" ;; f) FAST=true ;; r) HOT_RELOAD=true ;; + b) BUILD_ONLY=true ;; *) error "Unexpected option ${flag}" ;; esac done @@ -44,14 +47,8 @@ ENV_FILENAME="${ENVFILE:-.env}" export $(grep -v '^#' $ENV_FILENAME | xargs) if [ -z "$NETWORK" ]; then - echo "No network set." - read -p "Use $DEFAULT_TESTNET network set in .env file (y/n)? " - if [[ $REPLY =~ ^[Yy]$ ]]; then - NETWORK=$DEFAULT_TESTNET - else - echo "No network chosen. Exiting." - exit 1 - fi + echo "No network set, using $DEFAULT_TESTNET network set in .env file." + NETWORK=$DEFAULT_TESTNET fi # Set DEFAULT_TESTNET in .env file @@ -71,7 +68,6 @@ rm -f $ENV_FILENAME.bak rm -f $ANDROID_GSERVICES_PATH.bak rm -f $IOS_GSERVICES_PATH.bak - # Build Wallet Kit for env if [ "$FAST" = false ]; then echo "Building sdk for testnet $NETWORK" @@ -83,12 +79,6 @@ fi if [ $PLATFORM = "android" ]; then echo "Using platform android" - NUM_DEVICES=`adb devices -l | wc -l` - if [ $NUM_DEVICES -lt 3 ]; then - echo "No android devices found" - exit 1 - fi - # Run jettify to fix non-android-x compatible libs if [ "$FAST" = false ]; then echo "Jetifying react native libraries" @@ -96,6 +86,17 @@ if [ $PLATFORM = "android" ]; then echo "Jetified" fi + if [ "$BUILD_ONLY" = true ]; then + echo "Build only enabled, stopping here." + exit 0 + fi + + NUM_DEVICES=`adb devices -l | wc -l` + if [ $NUM_DEVICES -lt 3 ]; then + echo "No android devices found" + exit 1 + fi + if [ $MACHINE = "Mac" ]; then echo "Starting packager in new terminal" RN_START_CMD="cd `pwd` && (yarn react-native start || yarn react-native start)" @@ -114,6 +115,13 @@ elif [ $PLATFORM = "ios" ]; then echo "Using platform ios" # TODO have iOS build and start from command line echo -e "\nFor now ios must be build and run from xcode\nStarting RN bundler\n" + + + if [ "$BUILD_ONLY" = true ]; then + echo "Build only enabled, stopping here." + exit 0 + fi + yarn react-native start else diff --git a/packages/mobile/scripts/run_e2e.sh b/packages/mobile/scripts/run_e2e.sh index 54740a719b8..48e7308e546 100755 --- a/packages/mobile/scripts/run_e2e.sh +++ b/packages/mobile/scripts/run_e2e.sh @@ -1,78 +1,105 @@ #!/usr/bin/env bash set -euo pipefail -##### -# This file launches the emulator and fires the tests -##### - -export CELO_TEST_CONFIG=e2e - -adb kill-server && adb start-server - -DEFAULT_AVD="Nexus_5X_API_28_x86" - -if [[ ! $($ANDROID_SDK_ROOT/emulator/emulator -list-avds | grep ^$DEFAULT_AVD$) ]]; then - echo "AVD $DEFAULT_AVD not installed. Pleas install it or change detox' configuration in package.json" - echo "You can see the list of available installed devices with $ANDROID_SDK_ROOT/emulator/emulator -list-avds" - exit 1 -fi - - -bash ./scripts/unlock.sh -adb reconnect -if [ $? -ne 0 ] -then - exit 1 -fi +# ======================================== +# Build and run the end-to-end tests +# ======================================== + +# Flags: +# -p: Platform (android or ios) +# -v (Optional): Name of virual machine to run +# -f (Optional): Fast (skip build step) +# -r (Optional): Use release build (by default uses debug) +# TODO ^ release doesn't work currently b.c. the run_app.sh script assumes we want a debug build + +PLATFORM="" +VD_NAME="Nexus_5X_API_28_x86" +FAST=false +RELEASE=false +while getopts 'p:fr' flag; do + case "${flag}" in + p) PLATFORM="$OPTARG" ;; + v) VD_NAME="$OPTARG" ;; + f) FAST=true ;; + r) RELEASE=true ;; + *) error "Unexpected option ${flag}" ;; + esac +done -echo "Waiting for emulator to unlock..." -# TODO: improve this to actually poll if the screen is unlocked -# https://stackoverflow.com/questions/35275828/is-there-a-way-to-check-if-android-device-screen-is-locked-via-adb -sleep 3 -echo "Emulator unlocked!" +[ -z "$PLATFORM" ] && echo "Need to set the PLATFORM via the -p flag" && exit 1; -# sometimes the emulator locks itself after boot -# this prevents that -bash ./scripts/unlock.sh +# Ensure jest is accessible to detox +cp ../../node_modules/.bin/jest node_modules/.bin/ # Just to be safe kill any process that listens on the port 'yarn start' is going to use echo "Killing previous metro server (if any)" -react-native-kill-packager || echo 'Failed to kill for some reason' -echo "Start metro server" -yarn react-native start & - - -echo "Waiting for device to connect to Wifi, this is a good proxy the device is ready" -until adb shell dumpsys wifi | grep "mNetworkInfo" |grep "state: CONNECTED" -do - sleep 10 -done - -cp ../../node_modules/.bin/jest node_modules/.bin/ - -yarn test:detox -STATUS=$? - - # Retry on fail logic -if [ $STATUS -ne 0 ]; then - echo "It failed once, let's try again" - yarn test:detox - STATUS=$? -fi +yarn react-native-kill-packager || echo "Failed to kill package manager, proceeding anyway" + +# Build the app and run it +if [ $PLATFORM = "android" ]; then + echo "Using platform android" + + if [ -z $ANDROID_HOME ]; then + echo "No Android SDK root set" + exit 1 + fi + + if [[ ! $($ANDROID_HOME/emulator/emulator -list-avds | grep ^$VD_NAME$) ]]; then + echo "AVD $VD_NAME not installed. Please install it or change the detox configuration in package.json" + echo "You can see the list of available installed devices with $ANDROID_HOME/emulator/emulator -list-avds" + exit 1 + fi + + if [ "$RELEASE" = false ]; then + CONFIG_NAME="android.emu.debug" + else + CONFIG_NAME="android.emu.release" + fi + + if [ "$FAST" = false ]; then + echo "Configuring the app" + ./scripts/run_app.sh -p $PLATFORM -b + fi + + echo "Building detox" + yarn detox build -c $CONFIG_NAME + + echo "Starting the metro server" + yarn react-native start & + + NUM_DEVICES=`adb devices -l | wc -l` + if [ $NUM_DEVICES -gt 2 ]; then + echo "Emulator already running or device attached. Please shutdown / remove first" + exit 1 + fi + + echo "Starting the emulator" + $ANDROID_HOME/emulator/emulator -avd $VD_NAME -no-boot-anim & + + echo "Waiting for device to connect to Wifi, this is a good proxy the device is ready" + until [ `adb shell dumpsys wifi | grep "mNetworkInfo" | grep "state: CONNECTED" | wc -l` -gt 0 ] + do + sleep 3 + done + + CELO_TEST_CONFIG=e2e yarn detox test -c $CONFIG_NAME -a e2e/tmp/ --take-screenshots=failing --record-logs=failing --detectOpenHandles -l verbose + STATUS=$? + + echo "Closing emulator (if active)" + adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done + +elif [ $PLATFORM = "ios" ]; then + echo "Using platform ios" + echo "IOS e2e tests not currently supported" + exit 1 -if [ $STATUS -ne 0 ]; then - # TODO: upload e2e_run.log and attach the link - echo "Test failed" else - echo "Test passed" + echo "Invalid value for platform, must be 'android' or 'ios'" + exit 1 fi -react-native-kill-packager - -echo "Closing emulator" -kill -s 9 `ps -a | grep "Nexus_5X_API_28_x86" | grep -v "grep" | awk '{print $1}'` - -echo "Closing pidcat" -kill -s 9 `ps -a | grep "pidcat" | grep -v "grep" | awk '{print $1}'` +echo "Done test, cleaning up" +yarn react-native-kill-packager +echo "Exiting with test result status $STATUS" exit $STATUS diff --git a/packages/mobile/scripts/start_emulator.sh b/packages/mobile/scripts/start_emulator.sh deleted file mode 100755 index f7d391e350e..00000000000 --- a/packages/mobile/scripts/start_emulator.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -ENABLE_EMULATOR_WINDOW="${ENABLE_EMULATOR_WINDOW:-false}" - -PARAMS="" - -if ! $ENABLE_EMULATOR_WINDOW ; then - PARAMS="${PARAMS} -no-window" - echo "Not showing emulator windown due ENABLE_EMULATOR_WINDOW env variable" -fi - -$ANDROID_SDK_ROOT/emulator/emulator -avd `$ANDROID_SDK_ROOT/emulator/emulator -list-avds | grep 'x86' | head -n 1` -no-boot-anim $PARAMS \ No newline at end of file diff --git a/packages/mobile/scripts/wait_for_emulator_to_connect.sh b/packages/mobile/scripts/wait_for_emulator_to_connect.sh deleted file mode 100755 index 0d63f39743d..00000000000 --- a/packages/mobile/scripts/wait_for_emulator_to_connect.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -until adb shell dumpsys wifi | grep "mNetworkInfo" | grep "state: CONNECTED"; do sleep 10 ; done \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 4f0462a5274..a92a685ce29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2743,14 +2743,6 @@ source-map-support "0.5.12" yargs "13.2.4" -"@celo/react-native-fast-crypto@^1.8.2": - version "1.8.2" - resolved "https://registry.yarnpkg.com/@celo/react-native-fast-crypto/-/react-native-fast-crypto-1.8.2.tgz#7563e73a47c9ce22407e0ceb4d6406078872795f" - integrity sha512-yb8TNnfVU6dWEWc2x8oNyF4mIzerXcS/Gv6ETRi5lM8bz1RyJUrX87mxTPhDJp0vdwtX0bnXRBjycgpPEPSPAA== - dependencies: - buffer "^5.0.8" - rfc4648 "^1.0.0" - "@celo/react-native-sms-retriever@git+https://github.com/celo-org/react-native-sms-retriever#b88e502": version "1.0.3" resolved "git+https://github.com/celo-org/react-native-sms-retriever#b88e502fcd5bab2b6b9a22f59829c3eb40e27780" @@ -13371,10 +13363,10 @@ detect-node@^2.0.4: resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c" integrity sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw== -detox@^14.5.0: - version "14.5.0" - resolved "https://registry.yarnpkg.com/detox/-/detox-14.5.0.tgz#cc96b41a2b76a029ef26be861fb04f69fe70c965" - integrity sha512-6LH/Aw/0pnf5llCY5rZICxVK1uoAmV+OZzGPQogpE3ZqxPkViFkg/SHsQqOn1M1Iswia7SzfSgu2KfKMNFXvRA== +detox@^15.0.0: + version "15.0.0" + resolved "https://registry.yarnpkg.com/detox/-/detox-15.0.0.tgz#1b4a4133d2de1a9ac6918c061306cc348090b580" + integrity sha512-mnF+3FoTP0ruqmYSJOEWQ5mmDYp3igD/CytBnhOupYHzTrzgIKl7F5+qnIg6SXIA+ANqgfQvy6bAiXI/26CSrQ== dependencies: "@babel/core" "^7.4.5" bunyan "^1.8.12" @@ -28431,13 +28423,13 @@ react-native-autocomplete-input@^4.1.0: resolved "https://registry.yarnpkg.com/react-native-autocomplete-input/-/react-native-autocomplete-input-4.1.0.tgz#979ece28d891b245ecb967b6d31f1f924445b8ab" integrity sha512-Yn4GulZ9F6tde74UUGZHdVFeYWVuL7+EbUZy6kt+QHrzMc5B4OuRop1FT4RyWLpvbySW/vvqYgj9LAmlzkuEqA== -"react-native-bip39@git://github.com/celo-org/react-native-bip39#8d00738": +"react-native-bip39@git://github.com/celo-org/react-native-bip39#b31a8ff": version "2.2.0" - resolved "git://github.com/celo-org/react-native-bip39#8d007387fc8bcc18a2d0e2344ec986a0c6f15834" + resolved "git://github.com/celo-org/react-native-bip39#b31a8ffc6a6c4393178e5a173ecbc966fbfcf92c" dependencies: create-hash "^1.1.0" react-native-crypto "^2.0.1" - react-native-fast-crypto "^1.8.1" + react-native-fast-crypto "git+https://github.com/celo-org/react-native-fast-crypto#3946f9" react-native-secure-randombytes "^2.2.3" unorm "^1.3.3" @@ -28507,10 +28499,9 @@ react-native-exit-app@^1.1.0: resolved "https://registry.yarnpkg.com/react-native-exit-app/-/react-native-exit-app-1.1.0.tgz#5ec082152974240e2d6a93f1608efb49a4385f21" integrity sha512-Spne19zfMfJvnUTX909EHUqWMk69rATtLJq9XMBGpNSHhx0M7v5yetx2Z87egBhLOqQm+CWfD/oxWzDG8rbIQA== -react-native-fast-crypto@^1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/react-native-fast-crypto/-/react-native-fast-crypto-1.8.1.tgz#9b59d7eb4bcb19f99c62695df9ea4f683bb1e52c" - integrity sha512-5Cym09wcYSDXS7+QFg5oWGuW4rz2DyaU09YTeGxn3Qc+rqc01VQ5T6ruW4dWv7bIULtyBcJ2ovTkXTtbsDl3uA== +"react-native-fast-crypto@git+https://github.com/celo-org/react-native-fast-crypto#3946f9": + version "1.8.3" + resolved "git+https://github.com/celo-org/react-native-fast-crypto#3946f918ff314455a6d55fdb49ecc0f1f5bc2ac2" dependencies: buffer "^5.0.8" rfc4648 "^1.0.0"