From 5f34f4a5027ae9a8554ed64513761306c106ad59 Mon Sep 17 00:00:00 2001 From: Samuel Salas Date: Thu, 5 Oct 2023 23:27:33 -0600 Subject: [PATCH 1/2] Add fixtures to permission-system-delete-wallet, permission-system-revoke-single-account and add-custom-rpc.spec detox regression test --- bitrise.yml | 8 +- e2e/pages/modals/ConnectedAccountsModal.js | 5 + e2e/specs/add-custom-rpc.spec.js | 33 +++- .../permission-system-delete-wallet.spec.js | 150 ++++++++---------- ...ssion-system-revoke-single-account.spec.js | 67 ++++---- 5 files changed, 134 insertions(+), 129 deletions(-) diff --git a/bitrise.yml b/bitrise.yml index 7b3cea5445d..8eb4e070f03 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -312,7 +312,7 @@ workflows: - content: |- #!/usr/bin/env bash node -v - IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:android:bitrise:debug --testNamePattern='Smoke' + IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:android:bitrise:debug --testNamePattern='Regression' title: Detox Build & Test is_always_run: false - custom-test-results-export@1: @@ -376,7 +376,7 @@ workflows: - content: |- #!/usr/bin/env bash node -v - IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:debug --testNamePattern='Smoke' + IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:debug --testNamePattern='Regression' title: Detox Build & Test is_always_run: false - custom-test-results-export@1: @@ -583,7 +583,7 @@ workflows: curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@$APK_PATH" -F 'data={"custom_id": "'$CUSTOM_ID'"}' | jq -j '.app_url' | envman add --key BROWSERSTACK_APP_URL APK_PATH_FOR_APP_LIVE=$PROJECT_LOCATION/app/build/outputs/apk/qa/release/"$CUSTOM_ID".apk mv "$APK_PATH" "$APK_PATH_FOR_APP_LIVE" - curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$APK_PATH_FOR_APP_LIVE" -F 'data={"custom_id": "'$CUSTOM_ID'"}' + curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$APK_PATH_FOR_APP_LIVE" -F 'data={"custom_id": "'$CUSTOM_ID'"}' curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/recent_apps | jq > browserstack_uploaded_apps.json - deploy-to-bitrise-io@2.2.3: is_always_run: false @@ -757,7 +757,7 @@ workflows: IPA_PATH_FOR_APP_LIVE=ios/build/output/"$CUSTOM_ID".ipa curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@$IPA_PATH" -F 'data={"custom_id": "'$CUSTOM_ID'"}' | jq -j '.app_url' | envman add --key BROWSERSTACK_APP_URL mv "$IPA_PATH" "$IPA_PATH_FOR_APP_LIVE" - curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$IPA_PATH_FOR_APP_LIVE" -F 'data={"custom_id": "'$CUSTOM_ID'"}' + curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$IPA_PATH_FOR_APP_LIVE" -F 'data={"custom_id": "'$CUSTOM_ID'"}' curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/recent_apps | jq > browserstack_uploaded_apps.json - deploy-to-bitrise-io@2.2.3: is_always_run: false diff --git a/e2e/pages/modals/ConnectedAccountsModal.js b/e2e/pages/modals/ConnectedAccountsModal.js index c6a725f70a3..163cbb84aa1 100644 --- a/e2e/pages/modals/ConnectedAccountsModal.js +++ b/e2e/pages/modals/ConnectedAccountsModal.js @@ -53,4 +53,9 @@ export default class ConnectedAccountsModal { static async isNotVisible() { await TestHelpers.checkIfNotVisible(CONNECTED_ACCOUNTS_MODAL_CONTAINER); } + + static async scrollToBottomOfModal() { + await TestHelpers.swipe(CONNECTED_ACCOUNTS_MODAL_CONTAINER, 'down', 'slow'); + await TestHelpers.delay(1000); + } } diff --git a/e2e/specs/add-custom-rpc.spec.js b/e2e/specs/add-custom-rpc.spec.js index 8225daec163..8c57ba752ba 100644 --- a/e2e/specs/add-custom-rpc.spec.js +++ b/e2e/specs/add-custom-rpc.spec.js @@ -10,20 +10,41 @@ import SettingsView from '../pages/Drawer/Settings/SettingsView'; import NetworkListModal from '../pages/modals/NetworkListModal'; import NetworkEducationModal from '../pages/modals/NetworkEducationModal'; -import { CreateNewWallet } from '../viewHelper'; +import { loginToApp } from '../viewHelper'; import TabBarComponent from '../pages/TabBarComponent'; - +import FixtureBuilder from '../fixtures/fixture-builder'; +import { + loadFixture, + startFixtureServer, + stopFixtureServer, +} from '../fixtures/fixture-helper'; +import { getFixturesServerPort } from '../utils'; +import FixtureServer from '../fixtures/fixture-server'; + +const fixtureServer = new FixtureServer(); const GORELI = 'Goerli Test Network'; const XDAI_URL = 'https://rpc.gnosischain.com'; const MAINNET = 'Ethereum Main Network'; describe(Regression('Custom RPC Tests'), () => { + beforeAll(async () => { + await TestHelpers.reverseServerPort(); + const fixture = new FixtureBuilder().build(); + await startFixtureServer(fixtureServer); + await loadFixture(fixtureServer, { fixture }); + await device.launchApp({ + delete: true, + launchArgs: { fixtureServerPort: `${getFixturesServerPort()}` }, + }); + await loginToApp(); + }); + beforeEach(() => { - jest.setTimeout(170000); + jest.setTimeout(150000); }); - it('should create new wallet', async () => { - await CreateNewWallet(); + afterAll(async () => { + await stopFixtureServer(fixtureServer); }); it('should go to settings then networks', async () => { @@ -70,8 +91,6 @@ describe(Regression('Custom RPC Tests'), () => { }); it('should switch to Goreli then dismiss the network education modal', async () => { - await NetworkListModal.isVisible(); - await NetworkListModal.tapTestNetworkSwitch(); await NetworkListModal.isTestNetworkToggleOn(); await NetworkListModal.changeNetwork(GORELI); diff --git a/e2e/specs/permission-system-delete-wallet.spec.js b/e2e/specs/permission-system-delete-wallet.spec.js index abfaef47808..74407817593 100644 --- a/e2e/specs/permission-system-delete-wallet.spec.js +++ b/e2e/specs/permission-system-delete-wallet.spec.js @@ -11,104 +11,92 @@ import WalletView from '../pages/WalletView'; import Browser from '../pages/Drawer/Browser'; import SettingsView from '../pages/Drawer/Settings/SettingsView'; -import { BROWSER_SCREEN_ID } from '../../wdio/screen-objects/testIDs/BrowserScreen/BrowserScreen.testIds'; - import TabBarComponent from '../pages/TabBarComponent'; import SkipAccountSecurityModal from '../pages/modals/SkipAccountSecurityModal'; import ConnectedAccountsModal from '../pages/modals/ConnectedAccountsModal'; -import ConnectModal from '../pages/modals/ConnectModal'; import DeleteWalletModal from '../pages/modals/DeleteWalletModal'; import SecurityAndPrivacyView from '../pages/Drawer/Settings/SecurityAndPrivacy/SecurityAndPrivacyView'; import NetworkListModal from '../pages/modals/NetworkListModal'; -import { - importWalletWithRecoveryPhrase, - testDappConnectButtonCooridinates, -} from '../viewHelper'; +import { loginToApp } from '../viewHelper'; +import FixtureBuilder from '../fixtures/fixture-builder'; +import { withFixtures } from '../fixtures/fixture-helper'; +import MetaMetricsOptIn from '../pages/Onboarding/MetaMetricsOptInView'; +import ProtectYourWalletModal from '../pages/modals/ProtectYourWalletModal'; -const TEST_DAPP = 'https://metamask.github.io/test-dapp/'; const PASSWORD = '12345678'; describe( Regression('Permission System: Deleting wallet after connecting to a dapp'), () => { - beforeEach(() => { + beforeAll(async () => { jest.setTimeout(150000); + await TestHelpers.reverseServerPort(); }); - it('should import wallet and go to the wallet view', async () => { - await importWalletWithRecoveryPhrase(); - }); - - it('should navigate to browser', async () => { - await TabBarComponent.tapBrowser(); - await Browser.isVisible(); - }); - - it('should connect to the test dapp', async () => { - await TestHelpers.delay(3000); - // Tap on search in bottom navbar - await Browser.tapUrlInputBox(); - await Browser.navigateToURL(TEST_DAPP); - await TestHelpers.delay(3000); - await TestHelpers.tapAtPoint( - BROWSER_SCREEN_ID, - testDappConnectButtonCooridinates, + it('should no longer be connected to the dapp after deleting and creating a new wallet', async () => { + await withFixtures( + { + dapp: true, + fixture: new FixtureBuilder() + .withPermissionControllerConnectedToTestDapp() + .build(), + restartDevice: true, + }, + async () => { + await loginToApp(); + + //validate connection to test dapp + await TabBarComponent.tapBrowser(); + await Browser.isVisible(); + await Browser.navigateToTestDApp(); + await Browser.tapNetworkAvatarButtonOnBrowserWhileAccountIsConnectedToDapp(); + await ConnectedAccountsModal.isVisible(); + await NetworkListModal.isNotVisible(); + await ConnectedAccountsModal.scrollToBottomOfModal(); + + //go to settings then security & privacy + await TabBarComponent.tapSettings(); + await SettingsView.tapSecurityAndPrivacy(); + await SecurityAndPrivacyView.scrollToChangePasswordView(); + await SecurityAndPrivacyView.isChangePasswordSectionVisible(); + await SecurityAndPrivacyView.scrollToDeleteWalletButton(); + await SecurityAndPrivacyView.tapDeleteWalletButton(); + + //Delete wallet + await DeleteWalletModal.tapIUnderstandButton(); + await DeleteWalletModal.typeDeleteInInputBox(); + await DeleteWalletModal.tapDeleteMyWalletButton(); + await TestHelpers.delay(2000); + await OnboardingView.isVisible(); + await OnboardingView.deleteWalletToastisNotVisible(); + await OnboardingView.tapCreateWallet(); + + //Create new wallet + await MetaMetricsOptIn.isVisible(); + await MetaMetricsOptIn.tapAgreeButton(); + await CreatePasswordView.isVisible(); + await CreatePasswordView.enterPassword(PASSWORD); + await CreatePasswordView.reEnterPassword(PASSWORD); + await CreatePasswordView.tapIUnderstandCheckBox(); + await CreatePasswordView.tapCreatePasswordButton(); + await ProtectYourWalletView.isVisible(); + await ProtectYourWalletView.tapOnRemindMeLaterButton(); + await SkipAccountSecurityModal.tapIUnderstandCheckBox(); + await SkipAccountSecurityModal.tapSkipButton(); + await WalletView.isVisible(); + await ProtectYourWalletModal.tapRemindMeLaterButton(); + await SkipAccountSecurityModal.tapIUnderstandCheckBox(); + await SkipAccountSecurityModal.tapSkipButton(); + + //should no longer be connected to the dapp + await TabBarComponent.tapBrowser(); + await Browser.isVisible(); + await Browser.tapNetworkAvatarButtonOnBrowser(); + await ConnectedAccountsModal.isNotVisible(); + await NetworkListModal.isVisible(); + }, ); - await ConnectModal.isVisible(); - await ConnectModal.tapConnectButton(); - }); - it('should go to settings then security & privacy', async () => { - await TestHelpers.delay(3500); // need a better way to wait until the toast message disappear - - await TabBarComponent.tapSettings(); - await SettingsView.tapSecurityAndPrivacy(); - }); - - it('should delete wallet from settings and privacy view', async () => { - await SecurityAndPrivacyView.scrollToChangePasswordView(); - await SecurityAndPrivacyView.isChangePasswordSectionVisible(); - await SecurityAndPrivacyView.scrollToDeleteWalletButton(); - await SecurityAndPrivacyView.tapDeleteWalletButton(); - }); - - it('should delete wallet', async () => { - await DeleteWalletModal.tapIUnderstandButton(); - await DeleteWalletModal.typeDeleteInInputBox(); - await DeleteWalletModal.tapDeleteMyWalletButton(); - await TestHelpers.delay(2000); - await OnboardingView.isVisible(); - }); - - it('should create new wallet', async () => { - await OnboardingView.deleteWalletToastisNotVisible(); - await OnboardingView.tapCreateWallet(); - - await CreatePasswordView.isVisible(); - await CreatePasswordView.enterPassword(PASSWORD); - await CreatePasswordView.reEnterPassword(PASSWORD); - await CreatePasswordView.tapIUnderstandCheckBox(); - await CreatePasswordView.tapCreatePasswordButton(); - }); - - it('Should skip backup check', async () => { - await ProtectYourWalletView.isVisible(); - await ProtectYourWalletView.tapOnRemindMeLaterButton(); - - await SkipAccountSecurityModal.tapIUnderstandCheckBox(); - await SkipAccountSecurityModal.tapSkipButton(); - await WalletView.isVisible(); - }); - - it('should go to browser', async () => { - await TabBarComponent.tapBrowser(); - await Browser.isVisible(); - }); - - it('should no longer be connected to the dapp', async () => { - await Browser.tapNetworkAvatarButtonOnBrowser(); - await ConnectedAccountsModal.isNotVisible(); - await NetworkListModal.isVisible(); }); }, ); diff --git a/e2e/specs/permission-system-revoke-single-account.spec.js b/e2e/specs/permission-system-revoke-single-account.spec.js index 44ade24cc69..603d16a17e0 100644 --- a/e2e/specs/permission-system-revoke-single-account.spec.js +++ b/e2e/specs/permission-system-revoke-single-account.spec.js @@ -8,47 +8,40 @@ import TabBarComponent from '../pages/TabBarComponent'; import NetworkListModal from '../pages/modals/NetworkListModal'; import ConnectedAccountsModal from '../pages/modals/ConnectedAccountsModal'; -import ConnectModal from '../pages/modals/ConnectModal'; - -import { CreateNewWallet } from '../viewHelper'; +import FixtureBuilder from '../fixtures/fixture-builder'; +import { withFixtures } from '../fixtures/fixture-helper'; +import { loginToApp } from '../viewHelper'; describe(Regression('Revoke Single Account after connecting to a dapp'), () => { - beforeEach(() => { + beforeAll(async () => { jest.setTimeout(150000); + await TestHelpers.reverseServerPort(); }); - it('should create new wallet', async () => { - await CreateNewWallet(); - }); - - it('should navigate to browser', async () => { - await TabBarComponent.tapBrowser(); - // Check that we are on the browser screen - await Browser.isVisible(); - }); - - it('should connect to the test dapp', async () => { - await Browser.goToTestDappAndTapConnectButton(); - - await ConnectModal.tapConnectButton(); - - await ConnectModal.isNotVisible(); - }); - - it('should revoke accounts', async () => { - await TestHelpers.delay(3000); - await Browser.tapNetworkAvatarButtonOnBrowserWhileAccountIsConnectedToDapp(); - // await Browser.tapNetworkAvatarButtonOnBrowser(); - await ConnectedAccountsModal.tapPermissionsButton(); - await ConnectedAccountsModal.tapDisconnectAllButton(); - await Browser.isAccountToastVisible('Account 1'); - - await TestHelpers.delay(5500); - }); - - it('should no longer be connected to the dapp', async () => { - await Browser.tapNetworkAvatarButtonOnBrowser(); - await ConnectedAccountsModal.isNotVisible(); - await NetworkListModal.isVisible(); + it('should no longer be connected to the dapp after deleting and creating a new wallet', async () => { + await withFixtures( + { + dapp: true, + fixture: new FixtureBuilder() + .withPermissionControllerConnectedToTestDapp() + .build(), + restartDevice: true, + }, + async () => { + await loginToApp(); + await TabBarComponent.tapBrowser(); + await Browser.isVisible(); + await Browser.navigateToTestDApp(); + await Browser.tapNetworkAvatarButtonOnBrowserWhileAccountIsConnectedToDapp(); + await ConnectedAccountsModal.tapPermissionsButton(); + await ConnectedAccountsModal.tapDisconnectAllButton(); + await Browser.isAccountToastVisible('Account 1'); + + await TestHelpers.delay(5500); + await Browser.tapNetworkAvatarButtonOnBrowser(); + await ConnectedAccountsModal.isNotVisible(); + await NetworkListModal.isVisible(); + }, + ); }); }); From 03391058c04b2fb33b7e60e8dc90dca77b9d4590 Mon Sep 17 00:00:00 2001 From: Samuel Salas Date: Fri, 6 Oct 2023 10:12:02 -0600 Subject: [PATCH 2/2] Restore bitrise.yml file. --- bitrise.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitrise.yml b/bitrise.yml index 8eb4e070f03..f617b74208d 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -312,7 +312,7 @@ workflows: - content: |- #!/usr/bin/env bash node -v - IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:android:bitrise:debug --testNamePattern='Regression' + IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:android:bitrise:debug --testNamePattern='Smoke' title: Detox Build & Test is_always_run: false - custom-test-results-export@1: @@ -376,7 +376,7 @@ workflows: - content: |- #!/usr/bin/env bash node -v - IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:debug --testNamePattern='Regression' + IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:debug --testNamePattern='Smoke' title: Detox Build & Test is_always_run: false - custom-test-results-export@1: