From 66a6dd3dd6fef9806daf048986444590e261c13b Mon Sep 17 00:00:00 2001 From: Christopher Ferreira <104831203+christopherferreira9@users.noreply.github.com> Date: Thu, 8 Feb 2024 14:01:28 +0000 Subject: [PATCH] chore: Split tests into suites and create workflows for the different run types (#672) * feat: adds a new way of triggering the e2e job * feat: adds a new way of triggering the e2e job - wip * feat: splits e2e workflows and test suites * feat: splits specs for different sdks * chore: renames the JS e2e name * chore: rename E2E workflow name * chore: updates the workflows with the current artifact options * chore: fixes url in workflows * chore: fixes workflows * chore: renames AndroidSDK test for better visibility * chore: fixes JS Tests on android * chore: moves the helper const out of constants to avoid driver not being initialized * chore: cleans wdio configs * chore: makes android SDK dapp mandatory on the CI workflow * chore: fixes ci spelling --- .github/workflows/e2e-android-sdk-tests.yml | 64 +++++++++++++ .../workflows/e2e-js-sdk-android-tests.yml | 73 +++++++++++++++ .github/workflows/e2e-js-sdk-ios-tests.yml | 72 +++++++++++++++ .github/workflows/e2e-tests.yml | 89 ------------------- e2e/package.json | 5 +- e2e/src/Utils.ts | 10 ++- e2e/src/helpers.ts | 20 +++++ .../screens/Dapps/SdkPlaygroundDappScreen.ts | 7 +- .../wdio.android.app.browserstack.conf.ts | 6 +- .../wdio.ios.app.browserstack.conf.ts | 16 +--- e2e/test/configs/wdio.conf.ts | 6 +- e2e/test/specs/android_sdk.spec.ts | 76 ++++++++++++++++ e2e/test/specs/js_sdk.spec.ts | 71 +-------------- 13 files changed, 330 insertions(+), 185 deletions(-) create mode 100644 .github/workflows/e2e-android-sdk-tests.yml create mode 100644 .github/workflows/e2e-js-sdk-android-tests.yml create mode 100644 .github/workflows/e2e-js-sdk-ios-tests.yml delete mode 100644 .github/workflows/e2e-tests.yml create mode 100644 e2e/src/helpers.ts create mode 100644 e2e/test/specs/android_sdk.spec.ts diff --git a/.github/workflows/e2e-android-sdk-tests.yml b/.github/workflows/e2e-android-sdk-tests.yml new file mode 100644 index 000000000..c2451326c --- /dev/null +++ b/.github/workflows/e2e-android-sdk-tests.yml @@ -0,0 +1,64 @@ +name: Run Android SDK E2E Tests + +on: + workflow_dispatch: + inputs: + android_sdk_native: + description: 'Android SDK Native apk' + required: true + type: choice + options: + - 'Android-SDK-Dapp-0-4-0.apk' + wallet_app_name_android: + description: 'MM Wallet Android apk name' + required: true + type: choice + options: + - 'MM-Wallet-7-16.0-RC.apk' + +jobs: + e2e-tests: + runs-on: ubuntu-latest + env: + SRP: ${{ secrets.SRP }} + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + BROWSERSTACK_API_USERNAME: ${{ secrets.BROWSERSTACK_API_USERNAME }} + BROWSERSTACK_API_PASSWORD: ${{ secrets.BROWSERSTACK_API_PASSWORD }} + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.18.2' + + - name: Install dependencies + run: yarn install && cd e2e && yarn install && cd .. + + # Create .android.env with inputs in the /e2e directory + - name: Create .android.env + run: | + browserstack_api_url="https://api-cloud.browserstack.com/app-automate/recent_apps/" + response=$(curl -s -u "$BROWSERSTACK_API_USERNAME:$BROWSERSTACK_API_PASSWORD" "$browserstack_api_url") + android_wallet_app_name="${{ inputs.wallet_app_name_android }}" + android_native_sdk="${{ inputs.android_sdk_native }}" + + # Gets the app_url and custom_id for the wallet app, react native and android native test app to use in the .android.env file + android_wallet_app_url=$(echo "$response" | jq -r --arg android_wallet_app_name "$android_wallet_app_name" '.[] | select(.app_name == $android_wallet_app_name) | .app_url') + android_wallet_app_bundle_id=$(echo "$response" | jq -r --arg android_wallet_app_name "$android_wallet_app_name" '.[] | select(.app_name == $android_wallet_app_name) | .custom_id') + + android_native_sdk_url=$(echo "$response" | jq -r --arg android_native_sdk "$android_native_sdk" '.[] | select(.app_name == $android_native_sdk) | .app_url') + android_native_sdk_bundle_id=$(echo "$response" | jq -r --arg android_native_sdk "$android_native_sdk" '.[] | select(.app_name == $android_native_sdk) | .custom_id') + + { + echo "APP_PATH=$android_wallet_app_url" + echo "BUNDLE_ID=$android_wallet_app_bundle_id" + echo "ANDROID_SDK_TEST_APP_PATH=$android_native_sdk_url" + echo "ANDROID_SDK_TEST_BUNDLE_ID=$android_native_sdk_bundle_id" + } >> e2e/.android.env + + - name: Run Android SDK E2E tests + run: yarn test:android:androidsdk:e2e:browserstack + diff --git a/.github/workflows/e2e-js-sdk-android-tests.yml b/.github/workflows/e2e-js-sdk-android-tests.yml new file mode 100644 index 000000000..fb89253d5 --- /dev/null +++ b/.github/workflows/e2e-js-sdk-android-tests.yml @@ -0,0 +1,73 @@ +name: Run JS E2E Tests on Android + +on: + workflow_dispatch: + inputs: + rn_test_app_name_android: + description: 'React Native Test App apk' + required: true + type: choice + options: + - 'RN-demo-0-14-2.apk' + wallet_app_name_android: + description: 'MM Wallet Android apk name' + required: true + type: choice + options: + - 'MM-Wallet-7-16.0-RC.apk' + +jobs: + e2e-tests: + runs-on: ubuntu-latest + env: + SRP: ${{ secrets.SRP }} + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + BROWSERSTACK_API_USERNAME: ${{ secrets.BROWSERSTACK_API_USERNAME }} + BROWSERSTACK_API_PASSWORD: ${{ secrets.BROWSERSTACK_API_PASSWORD }} + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.18.2' + + - name: Install dependencies + run: yarn install && cd e2e && yarn install && cd .. + + # Create .android.env with inputs in the /e2e directory + - name: Create .android.env + run: | + browserstack_api_url="https://api-cloud.browserstack.com/app-automate/recent_apps/" + response=$(curl -s -u "$BROWSERSTACK_API_USERNAME:$BROWSERSTACK_API_PASSWORD" "$browserstack_api_url") + android_wallet_app_name="${{ inputs.wallet_app_name_android }}" + android_rn_app_name="${{ inputs.rn_test_app_name_android }}" + + # Gets the app_url and custom_id for the wallet app, react native and android native test app to use in the .android.env file + android_wallet_app_url=$(echo "$response" | jq -r --arg android_wallet_app_name "$android_wallet_app_name" '.[] | select(.app_name == $android_wallet_app_name) | .app_url') + android_wallet_app_bundle_id=$(echo "$response" | jq -r --arg android_wallet_app_name "$android_wallet_app_name" '.[] | select(.app_name == $android_wallet_app_name) | .custom_id') + android_rn_app_url=$(echo "$response" | jq -r --arg android_rn_app_name "$android_rn_app_name" '.[] | select(.app_name == $android_rn_app_name) | .app_url') + android_rn_app_bundle_id=$(echo "$response" | jq -r --arg android_rn_app_name "$android_rn_app_name" '.[] | select(.app_name == $android_rn_app_name) | .custom_id') + + # Writes to the .android.env file + { + echo "APP_PATH=$android_wallet_app_url" + echo "BUNDLE_ID=$android_wallet_app_bundle_id" + echo "RN_TEST_APP_PATH=$android_rn_app_url" + echo "RN_TEST_APP_BUNDLE_ID=$android_rn_app_bundle_id" + } >> e2e/.android.env + + # Hard code .dapps.env values in the /e2e directory + - name: Set Dapps Environment Variables + run: | + { + echo "TEST_DAPP_URL=https://c0f4f41c-2f55-4863-921b-sdk-docs.github.io/test-dapp/" + echo "SDK_PLAYGROUND_DAPP_URL=https://mmsdk-playground-test.vercel.app/demo" + echo "WEB3_ON_BOARD_DAPP_URL=https://mmsdk-playground-test.vercel.app/onboard" + } >> e2e/.dapps.env + + - name: Run JS-SDK Android E2E tests + run: yarn test:android:jssdk:e2e:browserstack + diff --git a/.github/workflows/e2e-js-sdk-ios-tests.yml b/.github/workflows/e2e-js-sdk-ios-tests.yml new file mode 100644 index 000000000..9a8df83e4 --- /dev/null +++ b/.github/workflows/e2e-js-sdk-ios-tests.yml @@ -0,0 +1,72 @@ +name: Run JS E2E Tests on iOS + +on: + workflow_dispatch: + inputs: + rn_test_app_name_ios: + description: 'React Native Test App ipa' + required: true + type: choice + options: + - 'RN-demo-0-14-2.ipa' + wallet_app_name_ios: + description: 'MM Wallet iOS ipa name' + required: true + type: choice + options: + - 'MM-Wallet-7-16.0-RC.ipa' + +jobs: + e2e-tests: + runs-on: ubuntu-latest + env: + SRP: ${{ secrets.SRP }} + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + BROWSERSTACK_API_USERNAME: ${{ secrets.BROWSERSTACK_API_USERNAME }} + BROWSERSTACK_API_PASSWORD: ${{ secrets.BROWSERSTACK_API_PASSWORD }} + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.18.2' + + - name: Install dependencies + run: yarn install && cd e2e && yarn install && cd .. + + # Create .ios.env with inputs in the /e2e directory + - name: Create .ios.env + run: | + browserstack_api_url="https://api-cloud.browserstack.com/app-automate/recent_apps/" + response=$(curl -s -u "$BROWSERSTACK_API_USERNAME:$BROWSERSTACK_API_PASSWORD" "$browserstack_api_url") + ios_wallet_app_name="${{ inputs.wallet_app_name_ios }}" + ios_rn_app_name="${{ inputs.rn_test_app_name_ios }}" + + # Gets the app_url and custom_id for the wallet app and the react native test app to use in the .ios.env file + ios_wallet_app_url=$(echo "$response" | jq -r --arg ios_wallet_app_name "$ios_wallet_app_name" '.[] | select(.app_name == $ios_wallet_app_name) | .app_url') + ios_wallet_app_bundle_id=$(echo "$response" | jq -r --arg ios_wallet_app_name "$ios_wallet_app_name" '.[] | select(.app_name == $ios_wallet_app_name) | .custom_id') + ios_rn_app_url=$(echo "$response" | jq -r --arg ios_rn_app_name "$ios_rn_app_name" '.[] | select(.app_name == $ios_rn_app_name) | .app_url') + ios_rn_app_bundle_id=$(echo "$response" | jq -r --arg ios_rn_app_name "$ios_rn_app_name" '.[] | select(.app_name == $ios_rn_app_name) | .custom_id') + + # Writes to the .ios.env file + { + echo "APP_PATH=$ios_wallet_app_url" + echo "BUNDLE_ID=$ios_wallet_app_bundle_id" + echo "RN_TEST_APP_PATH=$ios_rn_app_url" + echo "RN_TEST_APP_BUNDLE_ID=$ios_rn_app_bundle_id" + } >> e2e/.ios.env + + # Hard code .dapps.env values in the /e2e directory + - name: Set Dapps Environment Variables + run: | + { + echo "TEST_DAPP_URL=https://c0f4f41c-2f55-4863-921b-sdk-docs.github.io/test-dapp/" + echo "SDK_PLAYGROUND_DAPP_URL=https://mmsdk-playground-test.vercel.app/demo" + echo "WEB3_ON_BOARD_DAPP_URL=https://mmsdk-playground-test.vercel.app/onboard" + } >> e2e/.dapps.env + + - name: Run JS-SDK iOS E2E tests + run: yarn test:ios:jssdk:e2e:browserstack diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml deleted file mode 100644 index de652d4bf..000000000 --- a/.github/workflows/e2e-tests.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Run E2E Tests - -on: - workflow_dispatch: - inputs: - rn_test_app_path_ios: - description: 'React Native Test App Path for iOS' - type: string - required: true - rn_test_app_bundle_id_ios: - description: 'React Native Test App Bundle ID for iOS' - type: string - required: true - rn_test_app_path_android: - description: 'React Native Test App Path for Android' - type: string - required: true - rn_test_app_bundle_id_android: - description: 'React Native Test App Bundle ID for Android' - type: string - required: true - app_path_ios: - description: 'Path to iOS App' - type: string - required: true - bundle_id_ios: - description: 'Bundle ID for iOS App' - type: string - required: true - app_path_android: - description: 'Path to Android App' - type: string - required: true - bundle_id_android: - description: 'Bundle ID for Android App' - type: string - required: true - -jobs: - e2e-tests: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '18.18.2' - - - name: Install dependencies - run: yarn install && cd e2e && yarn install && cd .. - - # Create .ios.env and .android.env with inputs in the /e2e directory - - name: Create .ios.env and .android.env - run: | - echo "RN_TEST_APP_PATH=${{ inputs.rn_test_app_path_ios }}" > e2e/.ios.env - echo "RN_TEST_APP_BUNDLE_ID=${{ inputs.rn_test_app_bundle_id_ios }}" >> e2e/.ios.env - echo "RN_TEST_APP_PATH=${{ inputs.rn_test_app_path_android }}" > e2e/.android.env - echo "RN_TEST_APP_BUNDLE_ID=${{ inputs.rn_test_app_bundle_id_android }}" >> e2e/.android.env - echo "APP_PATH=${{ inputs.app_path_ios }}" > e2e/.ios.env - echo "BUNDLE_ID=${{ inputs.bundle_id_ios }}" >> e2e/.ios.env - echo "APP_PATH=${{ inputs.app_path_android }}" > e2e/.android.env - echo "BUNDLE_ID=${{ inputs.bundle_id_android }}" >> e2e/.android.env - - # Hard code .dapps.env values in the /e2e directory - - name: Set Dapps Environment Variables - run: | - echo "TEST_DAPP_URL=https://c0f4f41c-2f55-4863-921b-sdk-docs.github.io/test-dapp/" > e2e/.dapps.env - echo "SDK_PLAYGROUND_DAPP_URL=https://mmsdk-playground-test.vercel.app/demo" >> e2e/.dapps.env - echo "WEB3_ON_BOARD_DAPP_URL=https://mmsdk-playground-test.vercel.app/onboard" >> e2e/.dapps.env - - - name: Run Android E2E tests - env: - SRP: ${{ secrets.SRP }} - BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} - BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - BROWSERSTACK_API_USERNAME: ${{ secrets.BROWSERSTACK_API_USERNAME }} - BROWSERSTACK_API_PASSWORD: ${{ secrets.BROWSERSTACK_API_PASSWORD }} - run: yarn test:e2e:android:ci - - - name: Run IOS E2E tests - env: - SRP: ${{ secrets.SRP }} - BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} - BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - BROWSERSTACK_API_USERNAME: ${{ secrets.BROWSERSTACK_API_USERNAME }} - BROWSERSTACK_API_PASSWORD: ${{ secrets.BROWSERSTACK_API_PASSWORD }} - run: yarn test:e2e:ios:ci diff --git a/e2e/package.json b/e2e/package.json index f5cff8bdb..18678a945 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -16,9 +16,12 @@ "wdio-wait-for": "^3.0.9" }, "scripts": { - "test:android": "wdio run test/configs/local/wdio.android.app.local.conf.ts", + "test:android:jssdk:e2e:browserstack": "SDK_TYPE=js wdio run test/configs/browserstack/wdio.android.app.browserstack.conf.ts --suite js_sdk", + "test:android:androidsdk:e2e:browserstack": "SDK_TYPE=androidsdk wdio run test/configs/browserstack/wdio.android.app.browserstack.conf.ts --suite android_sdk", + "test:ios:jssdk:e2e:browserstack": "SDK_TYPE=js wdio run test/configs/browserstack/wdio.ios.app.browserstack.conf.ts --suite js_sdk", "test:android:browserstack": "wdio run test/configs/browserstack/wdio.android.app.browserstack.conf.ts", "test:ios:browserstack": "wdio run test/configs/browserstack/wdio.ios.app.browserstack.conf.ts", + "test:android": "wdio run test/configs/local/wdio.android.app.local.conf.ts", "setup": "yarn install", "build": "tsc --build", "clean": "yarn clean:reports && rm -rf node_modules", diff --git a/e2e/src/Utils.ts b/e2e/src/Utils.ts index 4e0dcfade..80f544ac8 100644 --- a/e2e/src/Utils.ts +++ b/e2e/src/Utils.ts @@ -11,7 +11,12 @@ import { MetaMaskElementSelector, ScreenPercentage, } from './types'; -import { FIXTURE_SERVER_PORT, PLATFORM, Platforms } from './Constants'; +import { + FIXTURE_SERVER_PORT, + METAMASK_BUNDLE_ID, + PLATFORM, + Platforms, +} from './Constants'; export const getSelectorForPlatform = (locator: MetaMaskElementSelector) => { const platformSelector = @@ -36,8 +41,7 @@ class Utils { static async launchMetaMask(): Promise { console.log(`Launching MetaMask on ${PLATFORM}`); - const metamaskBundleId = process.env.BUNDLE_ID as string; - await driver.activateApp(metamaskBundleId); + await driver.activateApp(METAMASK_BUNDLE_ID); } /* diff --git a/e2e/src/helpers.ts b/e2e/src/helpers.ts new file mode 100644 index 000000000..413e6d6c8 --- /dev/null +++ b/e2e/src/helpers.ts @@ -0,0 +1,20 @@ +/* + * Dynamically infers the path of the other apps to be installed on the device + * based on the SDK_TYPE environment variable + */ +export const getOtherAppsPath = () => { + const SDK_TYPE = process.env.SDK_TYPE as string; + + const otherAppsPaths = []; + switch (SDK_TYPE) { + case 'js': + otherAppsPaths.push(process.env.RN_TEST_APP_PATH ?? ''); + break; + case 'androidsdk': + otherAppsPaths.push(process.env.ANDROID_SDK_TEST_APP_PATH ?? ''); + break; + default: + break; + } + return otherAppsPaths; +}; diff --git a/e2e/src/screens/Dapps/SdkPlaygroundDappScreen.ts b/e2e/src/screens/Dapps/SdkPlaygroundDappScreen.ts index 2b6e08c17..1b29bcb49 100644 --- a/e2e/src/screens/Dapps/SdkPlaygroundDappScreen.ts +++ b/e2e/src/screens/Dapps/SdkPlaygroundDappScreen.ts @@ -23,11 +23,9 @@ class SdkPlaygroundDappScreen implements Dapp { return $( getSelectorForPlatform({ androidSelector: AndroidSelector.by().xpath( - '//android.view.View[@text="Connect wallet"]', - ), - iosSelector: IOSSelector.by().predicateString( - 'name == "Connect wallet"', + '//android.widget.Button[@text="Connect"]', ), + iosSelector: IOSSelector.by().predicateString('name == "Connect"'), }), ); } @@ -175,7 +173,6 @@ class SdkPlaygroundDappScreen implements Dapp { } async connect(): Promise { - await this.scrollToElement(this.connectButton); await ( await this.connectButton ).waitForEnabled({ diff --git a/e2e/test/configs/browserstack/wdio.android.app.browserstack.conf.ts b/e2e/test/configs/browserstack/wdio.android.app.browserstack.conf.ts index a4f1c30dd..876a281ae 100644 --- a/e2e/test/configs/browserstack/wdio.android.app.browserstack.conf.ts +++ b/e2e/test/configs/browserstack/wdio.android.app.browserstack.conf.ts @@ -1,6 +1,7 @@ /* eslint-disable node/no-process-env */ import path from 'path'; import dotenv from 'dotenv'; +import { getOtherAppsPath } from '../../../src/helpers'; import config from './wdio.shared.browserstack.conf'; dotenv.config({ path: path.join(process.cwd(), '.android.env') }); @@ -20,10 +21,7 @@ config.capabilities = [ /* This setting will tell Appium if it need to install the app or no. */ 'appium:noReset': false, // 'appium:optionalIntentArguments': '--es fixtureServerPort 12345' - 'appium:otherApps': [ - process.env.ANDROID_SDK_TEST_APP_PATH ?? '', - process.env.RN_TEST_APP_PATH ?? '', - ], + 'appium:otherApps': getOtherAppsPath(), 'bstack:options': { deviceName: 'Google Pixel 7', osVersion: '13.0', diff --git a/e2e/test/configs/browserstack/wdio.ios.app.browserstack.conf.ts b/e2e/test/configs/browserstack/wdio.ios.app.browserstack.conf.ts index 60e2b45ac..880cbb9b2 100644 --- a/e2e/test/configs/browserstack/wdio.ios.app.browserstack.conf.ts +++ b/e2e/test/configs/browserstack/wdio.ios.app.browserstack.conf.ts @@ -1,32 +1,20 @@ import path from 'path'; import dotenv from 'dotenv'; +import { getOtherAppsPath } from '../../../src/helpers'; import config from './wdio.shared.browserstack.conf'; dotenv.config({ path: path.join(process.cwd(), '.ios.env') }); -// ============ -// Specs -// ============ -// Placeholder in case we want to have android specific features - -// ============ -// Capabilities -// ============ -// For all capabilities please check -// http://appium.io/docs/en/writing-running-appium/caps/#general-capabilities config.capabilities = [ { // The defaults you need to have in your config platformName: 'iOS', maxInstances: 1, - // For W3C the appium capabilities need to have an extension prefix - // http://appium.io/docs/en/writing-running-appium/caps/ - // This is `appium:` for all Appium Capabilities which can be found here 'appium:deviceName': 'iPhone 15 Pro Max', 'appium:platformVersion': '17.1', 'appium:automationName': 'XCUITest', 'appium:app': process.env.APP_PATH, - 'appium:otherApps': [process.env.RN_TEST_APP_PATH ?? ''], + 'appium:otherApps': getOtherAppsPath(), // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore 'appium:bundleId': process.env.BUNDLE_ID, diff --git a/e2e/test/configs/wdio.conf.ts b/e2e/test/configs/wdio.conf.ts index d637243e4..5f04183bb 100644 --- a/e2e/test/configs/wdio.conf.ts +++ b/e2e/test/configs/wdio.conf.ts @@ -10,7 +10,11 @@ export const config: WebdriverIO.Config = { capabilities: [], services: [], - specs: ['../../specs/*.spec.ts'], + // specs: ['../../specs/*.spec.ts'], + suites: { + js_sdk: ['../../specs/js_sdk.spec.ts'], + android_sdk: ['../../specs/android_sdk.spec.ts'], + }, mochaOpts: { timeout: 360000, }, diff --git a/e2e/test/specs/android_sdk.spec.ts b/e2e/test/specs/android_sdk.spec.ts new file mode 100644 index 000000000..7c7d27f7b --- /dev/null +++ b/e2e/test/specs/android_sdk.spec.ts @@ -0,0 +1,76 @@ +import { WALLET_PASSWORD } from '../../src/Constants'; +import Utils from '../../src/Utils'; +import AndroidSDKDappScreen from '../../src/screens/Dapps/AndroidSDKDappScreen'; +import LockScreen from '../../src/screens/MetaMask/LockScreen'; +import ConnectModalComponent from '../../src/screens/MetaMask/components/ConnectModalComponent'; +import SendTxModalComponent from '../../src/screens/MetaMask/components/SendTxModalComponent'; +import SignModalComponent from '../../src/screens/MetaMask/components/SignModalComponent'; +import SwitchNetworkModalComponent from '../../src/screens/MetaMask/components/SwitchNetworkModalComponent'; +import { beforeEachHook, beforeHook } from '../mocha.hooks'; + +describe('Android SDK (native) E2E', () => { + before(async () => { + await beforeHook(); + }); + + beforeEach(async () => { + await beforeEachHook(); + }); + + it('Smoke Testing on the AndroidSDK Test Dapp', async () => { + await driver.pause(5000); + + await Utils.launchApp(process.env.ANDROID_SDK_TEST_BUNDLE_ID ?? ''); + + await driver.pause(5000); + + await AndroidSDKDappScreen.connect(); + + await driver.pause(3000); + + await LockScreen.unlockMMifLocked(WALLET_PASSWORD); + + await expect( + await ConnectModalComponent.connectApprovalButton, + ).toBeDisplayed(); + + await ConnectModalComponent.tapConnectApproval(); + + if (driver.isIOS) { + await driver.pause(1000); + await Utils.launchApp(process.env.ANDROID_SDK_TEST_BUNDLE_ID ?? ''); + } + + await driver.pause(5000); + + await AndroidSDKDappScreen.sign(); + await AndroidSDKDappScreen.sign2(); + + await SignModalComponent.tapSignApproval(); + + await AndroidSDKDappScreen.goBack(); + + await AndroidSDKDappScreen.batchSigning(); + await AndroidSDKDappScreen.batchSigning(); + + await SignModalComponent.tapSignApproval(); + await SignModalComponent.tapSignApproval(); + await SignModalComponent.tapSignApproval(); + + await AndroidSDKDappScreen.goBack(); + + await AndroidSDKDappScreen.sendTransaction(); + await AndroidSDKDappScreen.sendTransaction2(); + + await SendTxModalComponent.reject(); + + await AndroidSDKDappScreen.goBack(); + + await AndroidSDKDappScreen.switchChain(); + await AndroidSDKDappScreen.switchChain2(); + + await SwitchNetworkModalComponent.switchNetwork(); + + await driver.pause(1000); + }); +}); diff --git a/e2e/test/specs/js_sdk.spec.ts b/e2e/test/specs/js_sdk.spec.ts index a87d25139..d933c2f75 100644 --- a/e2e/test/specs/js_sdk.spec.ts +++ b/e2e/test/specs/js_sdk.spec.ts @@ -4,7 +4,6 @@ import ChromeBrowserScreen from '../../src/screens/Android/ChromeBrowserScreen'; import AndroidOpenWithComponent from '../../src/screens/Android/components/AndroidOpenWithComponent'; import ReactNativeDappScreen from '../../src/screens/Dapps/ReactNativeDappScreen'; import SdkPlaygroundDappScreen from '../../src/screens/Dapps/SdkPlaygroundDappScreen'; -import AndroidSDKDappScreen from '../../src/screens/Dapps/AndroidSDKDappScreen'; import TestDappScreen from '../../src/screens/Dapps/TestDappScreen'; import Web3OnBoardDappScreen from '../../src/screens/Dapps/Web3OnBoardDappScreen'; import LockScreen from '../../src/screens/MetaMask/LockScreen'; @@ -19,7 +18,7 @@ import SafariBrowserScreen from '../../src/screens/iOS/SafariBrowserScreen'; import IOSOpenInComponent from '../../src/screens/iOS/components/IOSOpenInComponent'; import { beforeEachHook, beforeHook } from '../mocha.hooks'; -describe('JS SDK Connection', () => { +describe('JS SDK E2E', () => { before(async () => { await beforeHook(); }); @@ -146,10 +145,6 @@ describe('JS SDK Connection', () => { await SwitchNetworkModalComponent.switchNetwork(); - if (driver.isAndroid) { - await SwitchNetworkModalComponent.switchNetwork(); - } - if (driver.isIOS) { await NetworkSwitchedModalComponent.tapGotItButton(); @@ -187,10 +182,6 @@ describe('JS SDK Connection', () => { await SignModalComponent.tapSignApproval(); - if (driver.isAndroid) { - await SignModalComponent.tapSignApproval(); - } - if (driver.isIOS) { await driver.pause(1000); await Utils.launchApp(BROWSER_BUNDLE_ID); @@ -206,8 +197,9 @@ describe('JS SDK Connection', () => { await SendTxModalComponent.reject(); + await driver.pause(1000); + if (driver.isIOS) { - await driver.pause(1000); await Utils.launchApp(BROWSER_BUNDLE_ID); } }); @@ -243,63 +235,6 @@ describe('JS SDK Connection', () => { await SignModalComponent.tapSignApproval(); }); - it('Connect to the AndroidSDK Test Dapp', async () => { - await driver.pause(5000); - - await Utils.launchApp(process.env.ANDROID_SDK_TEST_BUNDLE_ID ?? ''); - - await driver.pause(5000); - - await AndroidSDKDappScreen.connect(); - - await driver.pause(3000); - - await LockScreen.unlockMMifLocked(WALLET_PASSWORD); - - await expect( - await ConnectModalComponent.connectApprovalButton, - ).toBeDisplayed(); - - await ConnectModalComponent.tapConnectApproval(); - - if (driver.isIOS) { - await driver.pause(1000); - await Utils.launchApp(process.env.ANDROID_SDK_TEST_BUNDLE_ID ?? ''); - } - - await driver.pause(5000); - - await AndroidSDKDappScreen.sign(); - await AndroidSDKDappScreen.sign2(); - - await SignModalComponent.tapSignApproval(); - - await AndroidSDKDappScreen.goBack(); - - await AndroidSDKDappScreen.batchSigning(); - await AndroidSDKDappScreen.batchSigning(); - - await SignModalComponent.tapSignApproval(); - await SignModalComponent.tapSignApproval(); - await SignModalComponent.tapSignApproval(); - - await AndroidSDKDappScreen.goBack(); - - await AndroidSDKDappScreen.sendTransaction(); - await AndroidSDKDappScreen.sendTransaction2(); - - await SendTxModalComponent.reject(); - - await AndroidSDKDappScreen.goBack(); - - await AndroidSDKDappScreen.switchChain(); - await AndroidSDKDappScreen.switchChain2(); - - await SwitchNetworkModalComponent.switchNetwork(); - - await driver.pause(1000); - }); - it.skip('Clear all connections', async () => { // TODO: Make this test work