From 66821fd93d72c1b81cd467a13e2d43a364dafea4 Mon Sep 17 00:00:00 2001 From: SamuelSalas Date: Tue, 16 Apr 2024 05:37:53 -0600 Subject: [PATCH] test: 8735 research appium upgrading app version (#8896) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/d01b2c5b-7295-4aba-bd80-9abb4c7939ae ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've clearly explained what problem this PR is solving and how it is solved. - [ ] I've linked related issues - [ ] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: Cal Leung --- bitrise.yml | 39 ++++++++++++------- wdio.conf.js | 13 ++++++- wdio/config/android.config.browserstack.js | 5 ++- .../android.config.browserstack.local.js | 3 +- wdio/features/Performance/UpgradeApp.feature | 25 ++++++++++++ wdio/helpers/Gestures.js | 2 +- wdio/screen-objects/Modals/TabBarModal.js | 1 + .../Onboarding/OnboardingCarousel.js | 6 +++ .../testIDs/Screens/Settings.testIds.js | 10 ----- wdio/step-definitions/common-steps.js | 35 ++++++++++++++++- 10 files changed, 109 insertions(+), 30 deletions(-) create mode 100644 wdio/features/Performance/UpgradeApp.feature diff --git a/bitrise.yml b/bitrise.yml index 22853f25fdcc..d1406d6211e6 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -15,6 +15,7 @@ pipelines: stages: - create_build_release: {} - deploy_build_release: {} + - create_build_qa: {} #Generate QA builds for E2E app upgrade tests - release_notify: {} #Releases MetaMask apps and stores ipa into App(TestFlight) Store release_ios_to_store_pipeline: @@ -138,6 +139,7 @@ stages: - run_tag_smoke_swaps_android: {} - run_tag_smoke_core_ios: {} - run_tag_smoke_core_android: {} + - run_tag_upgrade_android: {} run_e2e_ios_android_stage: workflows: - ios_e2e_test: {} @@ -416,6 +418,20 @@ workflows: - TEST_SUITE: 'Regression' after_run: - android_e2e_test + run_tag_upgrade_android: + meta: + bitrise.io: + stack: linux-docker-android-20.04 + machine_type_id: elite-xl + envs: + - PRODUCTION_APP_URL: 'bs://3f81fdb66cba8140909d1ff0a05bc2ace97b307f' # Last production's QA build + - PRODUCTION_BUILD_VERSION_NAME: 7.20.0 + - PRODUCTION_BUILD_VERSION_NUMBER: 1308 + - CUCUMBER_TAG_EXPRESSION: '@upgrade and @androidApp' + - PRODUCTION_BUILD_STRING: 'MetaMask-QA v$PRODUCTION_BUILD_VERSION_NAME ($PRODUCTION_BUILD_VERSION_NUMBER)' + - NEW_BUILD_STRING: 'MetaMask-QA v$VERSION_NAME ($VERSION_NUMBER)' + after_run: + - run_android_appium_test ### Seperating workflows so they run concurrently during smoke runs run_tag_smoke_confirmations_ios: @@ -892,6 +908,15 @@ workflows: bitrise.io: stack: linux-docker-android-20.04 machine_type_id: elite-xl + run_android_appium_test: + meta: + bitrise.io: + stack: linux-docker-android-20.04 + machine_type_id: elite-xl + before_run: + - build_android_qa + after_run: + - wdio_android_e2e_test build_android_qa: before_run: - code_setup @@ -987,20 +1012,6 @@ workflows: inputs: - deploy_path: browserstack_uploaded_apps.json title: Bitrise Deploy Browserstack Uploaded Apps - - build-router-start@0: - inputs: - - workflows: |- - wdio_android_e2e_test - - wait_for_builds: 'false' - - abort_on_fail: 'yes' - - access_token: $BITRISE_START_BUILD_ACCESS_TOKEN - - environment_key_list: BROWSERSTACK_APP_URL - - BROWSERSTACK_DEVICE - - BROWSERSTACK_OS_VERSION - - BROWSERSTACK_TAG_EXPRESSION wdio_android_e2e_test: before_run: - code_setup diff --git a/wdio.conf.js b/wdio.conf.js index 14f218656f69..f8039c174f77 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -160,7 +160,18 @@ export const config = { // your test setup with almost no effort. Unlike plugins, they don't add new // commands. Instead, they hook themselves up into the test process. /** services: ['chromedriver','appium'], ***/ - services: ['appium'], + services: [ + [ + 'appium', + { + args: { + address: 'localhost', + port: 4723 + }, + logPath: './' + } + ] + ], // Appium service with custom chrome driver path /*services: [ diff --git a/wdio/config/android.config.browserstack.js b/wdio/config/android.config.browserstack.js index 92f8a591fc42..66209e38ccd5 100644 --- a/wdio/config/android.config.browserstack.js +++ b/wdio/config/android.config.browserstack.js @@ -19,9 +19,10 @@ config.capabilities = [ build: 'Android QA E2E Smoke Tests', device: process.env.BROWSERSTACK_DEVICE || 'Google Pixel 6', os_version: process.env.BROWSERSTACK_OS_VERSION || '12.0', - app: process.env.BROWSERSTACK_APP_URL, + app: process.env.PRODUCTION_APP_URL || process.env.BROWSERSTACK_APP_URL, 'browserstack.debug': true, 'browserstack.local': true, + 'browserstack.midSessionInstallApps' : [process.env.BROWSERSTACK_APP_URL], }, ]; @@ -29,7 +30,7 @@ config.waitforTimeout = 10000; config.connectionRetryTimeout = 90000; config.connectionRetryCount = 3; config.cucumberOpts.tagExpression = - process.env.BROWSERSTACK_TAG_EXPRESSION || '@performance and @androidApp'; // pass tag to run tests specific to android + process.env.CUCUMBER_TAG_EXPRESSION || '@performance and @androidApp'; // pass tag to run tests specific to android config.onPrepare = function (config, capabilities) { removeSync('./wdio/reports'); diff --git a/wdio/config/android.config.browserstack.local.js b/wdio/config/android.config.browserstack.local.js index 5c39d43df447..0240bb844090 100644 --- a/wdio/config/android.config.browserstack.local.js +++ b/wdio/config/android.config.browserstack.local.js @@ -18,9 +18,10 @@ config.capabilities = [ build: 'Android QA E2E Tests', device: 'Google Pixel 3a', os_version: '9.0', - app: process.env.BROWSERSTACK_APP_URL, // TODO: Add package ID when upload to BrowserStack + app: process.env.PRODUCTION_APP_URL || process.env.BROWSERSTACK_APP_URL, 'browserstack.debug': true, 'browserstack.local': true, + 'browserstack.midSessionInstallApps' : [process.env.BROWSERSTACK_APP_URL], }, ]; diff --git a/wdio/features/Performance/UpgradeApp.feature b/wdio/features/Performance/UpgradeApp.feature new file mode 100644 index 000000000000..28c7529ccae6 --- /dev/null +++ b/wdio/features/Performance/UpgradeApp.feature @@ -0,0 +1,25 @@ +@androidApp +@upgrade +@fixturesSkipOnboarding +Feature: Measure the app launch times for warm starts + + Scenario: Measure warm start launch time after importing a wallet + Given the app displayed the splash animation + And I have imported my wallet + And I tap No Thanks on the Enable security check screen + And I tap No thanks on the onboarding welcome tutorial + And I close the Whats New modal + And I am on the wallet view + When I tap on the Settings tab option + And I scroll up + And In settings I tap on "About MetaMask" + Then version "PRODUCTION_BUILD_STRING" is displayed for app upgrade step + When I install upgrade the app + And I relaunch the app + And the splash animation completes + And I fill my password in the Login screen + And I log into my wallet + And I tap on the Settings tab option + And In settings I tap on "About MetaMask" + Then version "NEW_BUILD_STRING" is displayed for app upgrade step + And removed test app diff --git a/wdio/helpers/Gestures.js b/wdio/helpers/Gestures.js index 2ba2f1e79bfe..39ce51feb845 100644 --- a/wdio/helpers/Gestures.js +++ b/wdio/helpers/Gestures.js @@ -67,7 +67,7 @@ const Actions = { class Gestures { static async waitAndTap(element) { const elem = await element; - await elem.waitForDisplayed(); + await elem.waitForDisplayed({timeout: 25000}); (await elem).touchAction(Actions.TAP); } diff --git a/wdio/screen-objects/Modals/TabBarModal.js b/wdio/screen-objects/Modals/TabBarModal.js index 9608fd74a25b..b9ca62a07769 100644 --- a/wdio/screen-objects/Modals/TabBarModal.js +++ b/wdio/screen-objects/Modals/TabBarModal.js @@ -52,6 +52,7 @@ class TabBarModal { } async tapSettingButton() { + await driver.pause(10000); await Gestures.waitAndTap(this.settingsButton); } diff --git a/wdio/screen-objects/Onboarding/OnboardingCarousel.js b/wdio/screen-objects/Onboarding/OnboardingCarousel.js index afb31a9f989d..dff49a47a0b4 100644 --- a/wdio/screen-objects/Onboarding/OnboardingCarousel.js +++ b/wdio/screen-objects/Onboarding/OnboardingCarousel.js @@ -42,6 +42,12 @@ class WelcomeScreen { } } + async waitForSplashAnimationToComplete() { + const elem = await this.splashScreenMetamaskAnimationId; + await elem.waitForExist(); + await elem.waitForExist({ reverse: true }); + } + async isScreenDisplayed() { expect(this.screen).toBeDisplayed(); } diff --git a/wdio/screen-objects/testIDs/Screens/Settings.testIds.js b/wdio/screen-objects/testIDs/Screens/Settings.testIds.js index 517b84908317..2af2c3732fcc 100644 --- a/wdio/screen-objects/testIDs/Screens/Settings.testIds.js +++ b/wdio/screen-objects/testIDs/Screens/Settings.testIds.js @@ -1,11 +1 @@ -export const GENERAL_SETTINGS = 'general-settings'; -export const SECURITY_SETTINGS = 'security-settings'; -export const ADVANCED_SETTINGS = 'advanced-settings'; -export const CONTACTS_SETTINGS = 'contacts-settings'; -export const NETWORKS_SETTINGS = 'networks-settings'; -export const ON_RAMP_SETTINGS = 'on-ramp-settings'; -export const EXPERIMENTAL_SETTINGS = 'experimental-settings'; -export const ABOUT_METAMASK_SETTINGS = 'about-metamask-settings'; -export const REQUEST_SETTINGS = 'request-settings'; -export const CONTACT_SETTINGS = 'contact-settings'; export const LOCK_SETTINGS = 'lock-settings'; diff --git a/wdio/step-definitions/common-steps.js b/wdio/step-definitions/common-steps.js index 9d77cbba24ab..6077e1ddb897 100644 --- a/wdio/step-definitions/common-steps.js +++ b/wdio/step-definitions/common-steps.js @@ -14,6 +14,7 @@ import OnboardingWizardModal from '../screen-objects/Modals/OnboardingWizardModa import LoginScreen from '../screen-objects/LoginScreen'; import TermOfUseScreen from '../screen-objects/Modals/TermOfUseScreen'; import WhatsNewModal from '../screen-objects/Modals/WhatsNewModal'; +import Gestures from "../helpers/Gestures"; Then(/^the Welcome screen is displayed$/, async () => { await WelcomeScreen.isScreenDisplayed(); @@ -139,6 +140,13 @@ Then(/^"([^"]*)?" is displayed/, async (text) => { await CommonScreen.isTextDisplayed(text); }); +Then(/^version "([^"]*)?" is displayed for app upgrade step/, async (text) => { + const appUpgradeText = process.env[text]; + const timeout = 1000; + await driver.pause(timeout); + await CommonScreen.isTextDisplayed(appUpgradeText); +}); + Then(/^"([^"]*)?" is not displayed/, async (text) => { const timeout = 1000; await driver.pause(timeout); @@ -168,7 +176,8 @@ Then( When(/^I log into my wallet$/, async () => { await LoginScreen.tapUnlockButton(); - await WalletMainScreen.isVisible(); + await driver.pause(10000); + await WalletMainScreen.isMainWalletViewVisible(); }); When(/^I kill the app$/, async () => {3 @@ -264,3 +273,27 @@ When(/^I tap on the Settings tab option$/, async () => { When(/^I tap on the Activity tab option$/, async () => { await TabBarModal.tapActivityButton(); }); + +When(/^I install upgrade the app$/, async () => { + await driver.installApp(process.env.BROWSERSTACK_APP_URL) +}); + +When(/^I scroll up$/, async () => { + await Gestures.swipeUp(0.5); +}); + +Then(/^removed test app$/, async () => { + const platform = await driver.getPlatform(); + // TODO: Use environment variables for bundle IDs + if (platform === 'iOS') { + await driver.removeApp('io.metamask.MetaMask-QA'); + } + + if (platform === 'Android') { + await driver.removeApp('io.metamask.qa'); + } +}); + +Given(/^the splash animation completes$/, async () => { + await WelcomeScreen.waitForSplashAnimationToComplete(); +});