Skip to content

Commit

Permalink
use object as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
chloeYue committed Nov 5, 2024
1 parent 358507a commit a32c082
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 72 deletions.
49 changes: 31 additions & 18 deletions test/e2e/page-objects/flows/onboarding.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
console.log('Starting the import of SRP onboarding flow');
await driver.navigate();

const startOnboardingPage = new StartOnboardingPage(driver);
await startOnboardingPage.check_pageIsLoaded();
await startOnboardingPage.checkTermsCheckbox();
Expand Down Expand Up @@ -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<void> => {
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();
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/tests/network/multi-rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 6 additions & 3 deletions test/e2e/tests/onboarding/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a32c082

Please sign in to comment.