-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [POM] Create onboarding related page object modal base pages an…
…d migrate e2e tests (#28036) ## **Description** This PR migrates onboarding e2e tests to Page Object Model (POM) pattern, improving test stability and maintainability. Changes include: - Migrate test `test/e2e/tests/onboarding/onboarding.spec.js` to POM - Migrate test `test/e2e/tests/onboarding/onboarding.spec.js` to TypeScript - Created all onboarding-related pages and functions - Avoided unnecessary delays - Reduced flakiness - I will create follow-up PRs after this one is merged to avoid having a very big PR. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27155?quickstart=1) ## **Related issues** Fixes: ##27989 ## **Manual testing steps** Check code readability, make sure tests pass. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Chloe Gao <chloe.gao@consensys.net> Co-authored-by: chloeYue <105063779+chloeYue@users.noreply.github.com> Co-authored-by: seaona <54408225+seaona@users.noreply.github.com>
- Loading branch information
1 parent
1698011
commit 639e46f
Showing
17 changed files
with
1,369 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Driver } from '../../webdriver/driver'; | ||
import OnboardingMetricsPage from '../pages/onboarding/onboarding-metrics-page'; | ||
import OnboardingPasswordPage from '../pages/onboarding/onboarding-password-page'; | ||
import OnboardingSrpPage from '../pages/onboarding/onboarding-srp-page'; | ||
import StartOnboardingPage from '../pages/onboarding/start-onboarding-page'; | ||
import SecureWalletPage from '../pages/onboarding/secure-wallet-page'; | ||
import OnboardingCompletePage from '../pages/onboarding/onboarding-complete-page'; | ||
|
||
export const importSRPOnboardingFlow = async (driver: Driver) => { | ||
console.log('start import srp onboarding flow '); | ||
await driver.navigate(); | ||
const startOnboardingPage = new StartOnboardingPage(driver); | ||
await startOnboardingPage.check_pageIsLoaded(); | ||
await startOnboardingPage.checkTermsCheckbox(); | ||
await startOnboardingPage.clickImportWalletButton(); | ||
|
||
const onboardingMetricsPage = new OnboardingMetricsPage(driver); | ||
await onboardingMetricsPage.check_pageIsLoaded(); | ||
await onboardingMetricsPage.clickNoThanksButton(); | ||
|
||
const onboardingSrpPage = new OnboardingSrpPage(driver); | ||
await onboardingSrpPage.check_pageIsLoaded(); | ||
await onboardingSrpPage.fillSrp(); | ||
await onboardingSrpPage.clickConfirmButton(); | ||
|
||
const onboardingPasswordPage = new OnboardingPasswordPage(driver); | ||
await onboardingPasswordPage.check_pageIsLoaded(); | ||
await onboardingPasswordPage.createImportedWalletPassword(); | ||
}; | ||
|
||
export const completeCreateNewWalletOnboardingFlow = async (driver: Driver) => { | ||
console.log('start to complete create new wallet onboarding flow '); | ||
await driver.navigate(); | ||
const startOnboardingPage = new StartOnboardingPage(driver); | ||
await startOnboardingPage.check_pageIsLoaded(); | ||
await startOnboardingPage.checkTermsCheckbox(); | ||
await startOnboardingPage.clickCreateWalletButton(); | ||
|
||
const onboardingMetricsPage = new OnboardingMetricsPage(driver); | ||
await onboardingMetricsPage.check_pageIsLoaded(); | ||
await onboardingMetricsPage.clickNoThanksButton(); | ||
|
||
const onboardingPasswordPage = new OnboardingPasswordPage(driver); | ||
await onboardingPasswordPage.check_pageIsLoaded(); | ||
await onboardingPasswordPage.createWalletPassword(); | ||
|
||
const secureWalletPage = new SecureWalletPage(driver); | ||
await secureWalletPage.check_pageIsLoaded(); | ||
await secureWalletPage.revealAndConfirmSRP(); | ||
|
||
const onboardingCompletePage = new OnboardingCompletePage(driver); | ||
await onboardingCompletePage.check_pageIsLoaded(); | ||
await onboardingCompletePage.check_congratulationsMessageIsDisplayed(); | ||
await onboardingCompletePage.completeOnboarding(); | ||
}; | ||
|
||
export const completeImportSRPOnboardingFlow = async (driver: Driver) => { | ||
console.log('start to complete import srp onboarding flow '); | ||
await importSRPOnboardingFlow(driver); | ||
const onboardingCompletePage = new OnboardingCompletePage(driver); | ||
await onboardingCompletePage.check_pageIsLoaded(); | ||
await onboardingCompletePage.check_walletReadyMessageIsDisplayed(); | ||
await onboardingCompletePage.completeOnboarding(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
test/e2e/page-objects/pages/onboarding/onboarding-complete-page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { Driver } from '../../../webdriver/driver'; | ||
|
||
class OnboardingCompletePage { | ||
private driver: Driver; | ||
|
||
private readonly congratulationsMessage = { | ||
text: 'Congratulations!', | ||
tag: 'h2', | ||
}; | ||
|
||
private readonly defaultPrivacySettingsButton = { | ||
text: 'Manage default privacy settings', | ||
tag: 'button', | ||
}; | ||
|
||
private readonly installCompleteMessage = { | ||
text: 'Your MetaMask install is complete!', | ||
tag: 'h2', | ||
}; | ||
|
||
private readonly onboardingCompleteDoneButton = | ||
'[data-testid="onboarding-complete-done"]'; | ||
|
||
private readonly pinExtensionDoneButton = | ||
'[data-testid="pin-extension-done"]'; | ||
|
||
private readonly pinExtensionMessage = { | ||
text: 'Click browser extension icon to access it instantly', | ||
tag: 'p', | ||
}; | ||
|
||
private readonly pinExtensionNextButton = | ||
'[data-testid="pin-extension-next"]'; | ||
|
||
private readonly walletReadyMessage = { | ||
text: 'Your wallet is ready', | ||
tag: 'h2', | ||
}; | ||
|
||
constructor(driver: Driver) { | ||
this.driver = driver; | ||
} | ||
|
||
async check_pageIsLoaded(): Promise<void> { | ||
try { | ||
await this.driver.waitForMultipleSelectors([ | ||
this.defaultPrivacySettingsButton, | ||
this.onboardingCompleteDoneButton, | ||
]); | ||
} catch (e) { | ||
console.log( | ||
'Timeout while waiting for onboarding wallet creation complete page to be loaded', | ||
e, | ||
); | ||
throw e; | ||
} | ||
console.log('Onboarding wallet creation complete page is loaded'); | ||
} | ||
|
||
async clickCreateWalletDoneButton(): Promise<void> { | ||
await this.driver.clickElementAndWaitToDisappear( | ||
this.onboardingCompleteDoneButton, | ||
); | ||
} | ||
|
||
async completeOnboarding(): Promise<void> { | ||
console.log('Complete onboarding'); | ||
await this.clickCreateWalletDoneButton(); | ||
await this.driver.waitForSelector(this.installCompleteMessage); | ||
await this.driver.clickElement(this.pinExtensionNextButton); | ||
|
||
// Wait until the onboarding carousel has stopped moving otherwise the click has no effect. | ||
await this.driver.waitForSelector(this.pinExtensionMessage); | ||
await this.driver.waitForElementToStopMoving(this.pinExtensionDoneButton); | ||
await this.driver.clickElementAndWaitToDisappear( | ||
this.pinExtensionDoneButton, | ||
); | ||
} | ||
|
||
async navigateToDefaultPrivacySettings(): Promise<void> { | ||
await this.driver.clickElementAndWaitToDisappear( | ||
this.defaultPrivacySettingsButton, | ||
); | ||
} | ||
|
||
async check_congratulationsMessageIsDisplayed(): Promise<void> { | ||
await this.driver.waitForSelector(this.congratulationsMessage); | ||
} | ||
|
||
async check_walletReadyMessageIsDisplayed(): Promise<void> { | ||
await this.driver.waitForSelector(this.walletReadyMessage); | ||
} | ||
} | ||
|
||
export default OnboardingCompletePage; |
38 changes: 38 additions & 0 deletions
38
test/e2e/page-objects/pages/onboarding/onboarding-metrics-page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Driver } from '../../../webdriver/driver'; | ||
|
||
class OnboardingMetricsPage { | ||
private driver: Driver; | ||
|
||
private readonly metametricsMessage = { | ||
text: 'Help us improve MetaMask', | ||
tag: 'h2', | ||
}; | ||
|
||
private readonly noThanksButton = '[data-testid="metametrics-no-thanks"]'; | ||
|
||
constructor(driver: Driver) { | ||
this.driver = driver; | ||
} | ||
|
||
async check_pageIsLoaded(): Promise<void> { | ||
try { | ||
await this.driver.waitForMultipleSelectors([ | ||
this.metametricsMessage, | ||
this.noThanksButton, | ||
]); | ||
} catch (e) { | ||
console.log( | ||
'Timeout while waiting for onboarding metametrics page to be loaded', | ||
e, | ||
); | ||
throw e; | ||
} | ||
console.log('Onboarding metametrics page is loaded'); | ||
} | ||
|
||
async clickNoThanksButton(): Promise<void> { | ||
await this.driver.clickElementAndWaitToDisappear(this.noThanksButton); | ||
} | ||
} | ||
|
||
export default OnboardingMetricsPage; |
Oops, something went wrong.