From a32c082b50e9d9c9c7bd95fbd5862907d4d90d62 Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Tue, 5 Nov 2024 12:18:46 +0100 Subject: [PATCH] use object as parameter --- .../e2e/page-objects/flows/onboarding.flow.ts | 49 ++++++++++++------- test/e2e/tests/network/multi-rpc.spec.ts | 4 +- .../importing-private-key-account.spec.ts | 16 +++--- .../account-syncing/new-user-sync.spec.ts | 8 +-- .../onboarding-with-opt-out.spec.ts | 16 +++--- .../sync-after-adding-account.spec.ts | 32 ++++++------ .../sync-after-modifying-account-name.spec.ts | 16 +++--- .../sync-after-onboarding.spec.ts | 8 +-- test/e2e/tests/onboarding/onboarding.spec.ts | 9 ++-- .../onboarding-infura-call-privacy.spec.ts | 2 +- 10 files changed, 88 insertions(+), 72 deletions(-) diff --git a/test/e2e/page-objects/flows/onboarding.flow.ts b/test/e2e/page-objects/flows/onboarding.flow.ts index a7c985592434..adf591330798 100644 --- a/test/e2e/page-objects/flows/onboarding.flow.ts +++ b/test/e2e/page-objects/flows/onboarding.flow.ts @@ -41,17 +41,23 @@ export const createNewWalletOnboardingFlow = async ( /** * Import SRP onboarding flow * - * @param driver - The WebDriver instance. - * @param seedPhrase - The seed phrase to import. Defaults to E2E_SRP. - * @param password - The password to use. Defaults to WALLET_PASSWORD. + * @param options - The options object. + * @param options.driver - The WebDriver instance. + * @param [options.seedPhrase] - The seed phrase to import. + * @param [options.password] - The password to use. */ -export const importSRPOnboardingFlow = async ( - driver: Driver, - seedPhrase: string = E2E_SRP, - password: string = WALLET_PASSWORD, -) => { +export const importSRPOnboardingFlow = async ({ + driver, + seedPhrase = E2E_SRP, + password = WALLET_PASSWORD, +}: { + driver: Driver; + seedPhrase?: string; + password?: string; +}): Promise => { console.log('Starting the import of SRP onboarding flow'); await driver.navigate(); + const startOnboardingPage = new StartOnboardingPage(driver); await startOnboardingPage.check_pageIsLoaded(); await startOnboardingPage.checkTermsCheckbox(); @@ -92,17 +98,24 @@ export const completeCreateNewWalletOnboardingFlow = async ( /** * Complete import SRP onboarding flow * - * @param driver - The WebDriver instance. - * @param seedPhrase - The seed phrase to import. Defaults to E2E_SRP. - * @param password - The password to use. Defaults to WALLET_PASSWORD. + * @param options - The options object. + * @param options.driver - The WebDriver instance. + * @param [options.seedPhrase] - The seed phrase to import. Defaults to E2E_SRP. + * @param [options.password] - The password to use. Defaults to WALLET_PASSWORD. + * @returns A promise that resolves when the onboarding flow is complete. */ -export const completeImportSRPOnboardingFlow = async ( - driver: Driver, - seedPhrase: string = E2E_SRP, - password: string = WALLET_PASSWORD, -) => { - console.log('start to complete import srp onboarding flow '); - await importSRPOnboardingFlow(driver, seedPhrase, password); +export const completeImportSRPOnboardingFlow = async ({ + driver, + seedPhrase = E2E_SRP, + password = WALLET_PASSWORD, +}: { + driver: Driver; + seedPhrase?: string; + password?: string; +}): Promise => { + console.log('Starting to complete import SRP onboarding flow'); + await importSRPOnboardingFlow({ driver, seedPhrase, password }); + const onboardingCompletePage = new OnboardingCompletePage(driver); await onboardingCompletePage.check_pageIsLoaded(); await onboardingCompletePage.check_walletReadyMessageIsDisplayed(); diff --git a/test/e2e/tests/network/multi-rpc.spec.ts b/test/e2e/tests/network/multi-rpc.spec.ts index dd1098e855d1..ac693361435d 100644 --- a/test/e2e/tests/network/multi-rpc.spec.ts +++ b/test/e2e/tests/network/multi-rpc.spec.ts @@ -80,7 +80,7 @@ describe('MultiRpc:', function (this: Suite) { }, async ({ driver, ganacheServer }) => { - await completeImportSRPOnboardingFlow(driver); + await completeImportSRPOnboardingFlow({ driver }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_ganacheBalanceIsDisplayed(ganacheServer); @@ -348,7 +348,7 @@ describe('MultiRpc:', function (this: Suite) { }, async ({ driver }: { driver: Driver }) => { - await importSRPOnboardingFlow(driver); + await importSRPOnboardingFlow({ driver }); const onboardingCompletePage = new OnboardingCompletePage(driver); await onboardingCompletePage.check_pageIsLoaded(); await onboardingCompletePage.navigateToDefaultPrivacySettings(); diff --git a/test/e2e/tests/notifications/account-syncing/importing-private-key-account.spec.ts b/test/e2e/tests/notifications/account-syncing/importing-private-key-account.spec.ts index 822296bd6fa8..7b9e2378b058 100644 --- a/test/e2e/tests/notifications/account-syncing/importing-private-key-account.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/importing-private-key-account.spec.ts @@ -39,11 +39,11 @@ describe('Account syncing - Import With Private Key @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); @@ -83,11 +83,11 @@ describe('Account syncing - Import With Private Key @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); diff --git a/test/e2e/tests/notifications/account-syncing/new-user-sync.spec.ts b/test/e2e/tests/notifications/account-syncing/new-user-sync.spec.ts index 0a7c47cdd4d4..992027dd7840 100644 --- a/test/e2e/tests/notifications/account-syncing/new-user-sync.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/new-user-sync.spec.ts @@ -86,11 +86,11 @@ describe('Account syncing - New User @no-mmi', function () { }, async ({ driver }) => { // Onboard with import flow using SRP from new account created above - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - walletSrp, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: walletSrp, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); diff --git a/test/e2e/tests/notifications/account-syncing/onboarding-with-opt-out.spec.ts b/test/e2e/tests/notifications/account-syncing/onboarding-with-opt-out.spec.ts index 79d53f80c62a..f9574a27cb10 100644 --- a/test/e2e/tests/notifications/account-syncing/onboarding-with-opt-out.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/onboarding-with-opt-out.spec.ts @@ -45,11 +45,11 @@ describe('Account syncing - Opt-out Profile Sync @no-mmi', function () { }, }, async ({ driver }) => { - await importSRPOnboardingFlow( + await importSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const onboardingCompletePage = new OnboardingCompletePage(driver); await onboardingCompletePage.check_pageIsLoaded(); await onboardingCompletePage.navigateToDefaultPrivacySettings(); @@ -154,11 +154,11 @@ describe('Account syncing - Opt-out Profile Sync @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - walletSrp, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: walletSrp, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); diff --git a/test/e2e/tests/notifications/account-syncing/sync-after-adding-account.spec.ts b/test/e2e/tests/notifications/account-syncing/sync-after-adding-account.spec.ts index 1c0746364770..31f92520f13e 100644 --- a/test/e2e/tests/notifications/account-syncing/sync-after-adding-account.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/sync-after-adding-account.spec.ts @@ -38,11 +38,11 @@ describe('Account syncing - Add Account @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); @@ -81,11 +81,11 @@ describe('Account syncing - Add Account @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); @@ -135,11 +135,11 @@ describe('Account syncing - Add Account @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); @@ -176,11 +176,11 @@ describe('Account syncing - Add Account @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); diff --git a/test/e2e/tests/notifications/account-syncing/sync-after-modifying-account-name.spec.ts b/test/e2e/tests/notifications/account-syncing/sync-after-modifying-account-name.spec.ts index b4144661a9ee..45ee3ab23a85 100644 --- a/test/e2e/tests/notifications/account-syncing/sync-after-modifying-account-name.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/sync-after-modifying-account-name.spec.ts @@ -38,11 +38,11 @@ describe('Account syncing - Rename Accounts @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); @@ -80,11 +80,11 @@ describe('Account syncing - Rename Accounts @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); diff --git a/test/e2e/tests/notifications/account-syncing/sync-after-onboarding.spec.ts b/test/e2e/tests/notifications/account-syncing/sync-after-onboarding.spec.ts index 36e0653ffa79..5bebe7220e49 100644 --- a/test/e2e/tests/notifications/account-syncing/sync-after-onboarding.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/sync-after-onboarding.spec.ts @@ -37,11 +37,11 @@ describe('Account syncing - Onboarding @no-mmi', function () { }, }, async ({ driver }) => { - await completeImportSRPOnboardingFlow( + await completeImportSRPOnboardingFlow({ driver, - NOTIFICATIONS_TEAM_SEED_PHRASE, - NOTIFICATIONS_TEAM_PASSWORD, - ); + seedPhrase: NOTIFICATIONS_TEAM_SEED_PHRASE, + password: NOTIFICATIONS_TEAM_PASSWORD, + }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); diff --git a/test/e2e/tests/onboarding/onboarding.spec.ts b/test/e2e/tests/onboarding/onboarding.spec.ts index 9acd7f7768f6..9ea81f040998 100644 --- a/test/e2e/tests/onboarding/onboarding.spec.ts +++ b/test/e2e/tests/onboarding/onboarding.spec.ts @@ -56,7 +56,7 @@ describe('MetaMask onboarding @no-mmi', function () { title: this.test?.fullTitle(), }, async ({ driver }: { driver: Driver }) => { - await completeImportSRPOnboardingFlow(driver); + await completeImportSRPOnboardingFlow({ driver }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); await homePage.check_expectedBalanceIsDisplayed(); @@ -165,7 +165,10 @@ describe('MetaMask onboarding @no-mmi', function () { title: this.test?.fullTitle(), }, async ({ driver, secondaryGanacheServer }) => { - await importSRPOnboardingFlow(driver, TEST_SEED_PHRASE); + await importSRPOnboardingFlow({ + driver, + seedPhrase: TEST_SEED_PHRASE, + }); const onboardingCompletePage = new OnboardingCompletePage(driver); await onboardingCompletePage.check_pageIsLoaded(); @@ -210,7 +213,7 @@ describe('MetaMask onboarding @no-mmi', function () { title: this.test?.fullTitle(), }, async ({ driver }) => { - await importSRPOnboardingFlow(driver); + await importSRPOnboardingFlow({ driver }); const onboardingCompletePage = new OnboardingCompletePage(driver); await onboardingCompletePage.check_pageIsLoaded(); diff --git a/test/e2e/tests/privacy/onboarding-infura-call-privacy.spec.ts b/test/e2e/tests/privacy/onboarding-infura-call-privacy.spec.ts index b18d713d9474..1644cb068a3a 100644 --- a/test/e2e/tests/privacy/onboarding-infura-call-privacy.spec.ts +++ b/test/e2e/tests/privacy/onboarding-infura-call-privacy.spec.ts @@ -146,7 +146,7 @@ describe('MetaMask onboarding @no-mmi', function () { testSpecificMock: mockInfura, }, async ({ driver, mockedEndpoint: mockedEndpoints }) => { - await importSRPOnboardingFlow(driver); + await importSRPOnboardingFlow({ driver }); // Check no requests before completing onboarding // Intended delay to ensure we cover at least 1 polling loop of time for the network request