Skip to content

Commit

Permalink
chore: Split tests into suites and create workflows for the different…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
christopherferreira9 authored Feb 8, 2024
1 parent 285d158 commit 66a6dd3
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 185 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/e2e-android-sdk-tests.yml
Original file line number Diff line number Diff line change
@@ -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

73 changes: 73 additions & 0 deletions .github/workflows/e2e-js-sdk-android-tests.yml
Original file line number Diff line number Diff line change
@@ -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

72 changes: 72 additions & 0 deletions .github/workflows/e2e-js-sdk-ios-tests.yml
Original file line number Diff line number Diff line change
@@ -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
89 changes: 0 additions & 89 deletions .github/workflows/e2e-tests.yml

This file was deleted.

5 changes: 4 additions & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 7 additions & 3 deletions e2e/src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -36,8 +41,7 @@ class Utils {

static async launchMetaMask(): Promise<void> {
console.log(`Launching MetaMask on ${PLATFORM}`);
const metamaskBundleId = process.env.BUNDLE_ID as string;
await driver.activateApp(metamaskBundleId);
await driver.activateApp(METAMASK_BUNDLE_ID);
}

/*
Expand Down
20 changes: 20 additions & 0 deletions e2e/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -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;
};
7 changes: 2 additions & 5 deletions e2e/src/screens/Dapps/SdkPlaygroundDappScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"'),
}),
);
}
Expand Down Expand Up @@ -175,7 +173,6 @@ class SdkPlaygroundDappScreen implements Dapp {
}

async connect(): Promise<void> {
await this.scrollToElement(this.connectButton);
await (
await this.connectButton
).waitForEnabled({
Expand Down
Loading

0 comments on commit 66a6dd3

Please sign in to comment.