-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [POM] fix change language flaky tests and migrate tests to Page…
… Object Model (#28777) ## **Description** - Fix change language flaky tests. There are multiple reasons for the flakiness, including taking actions during the loading spinner and excessive misuse of refresh page - Migrate change language e2e tests to Page Object Model - Created base pages for advanced settings page and general settings page - For some special language-related locators, as they are only used in this specific test, I didn't migrate them to POM methods. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27155?quickstart=1) ## **Related issues** Fixes:#27904 #28698 #27390 ## **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.
- Loading branch information
Showing
4 changed files
with
175 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export type RawLocator = string | { css: string; text: string }; | ||
export type RawLocator = | ||
| string | ||
| { css?: string; text?: string } | ||
| { tag: string; text: string }; |
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,32 @@ | ||
import { Driver } from '../../../webdriver/driver'; | ||
|
||
class AdvancedSettings { | ||
private readonly driver: Driver; | ||
|
||
private readonly downloadDataButton = '[data-testid="export-data-button"]'; | ||
|
||
private readonly downloadStateLogsButton = | ||
'[data-testid="advanced-setting-state-logs"]'; | ||
|
||
constructor(driver: Driver) { | ||
this.driver = driver; | ||
} | ||
|
||
async check_pageIsLoaded(): Promise<void> { | ||
try { | ||
await this.driver.waitForMultipleSelectors([ | ||
this.downloadStateLogsButton, | ||
this.downloadDataButton, | ||
]); | ||
} catch (e) { | ||
console.log( | ||
'Timeout while waiting for Advanced Settings page to be loaded', | ||
e, | ||
); | ||
throw e; | ||
} | ||
console.log('Advanced Settings page is loaded'); | ||
} | ||
} | ||
|
||
export default AdvancedSettings; |
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,61 @@ | ||
import { Driver } from '../../../webdriver/driver'; | ||
|
||
class GeneralSettings { | ||
private readonly driver: Driver; | ||
|
||
private readonly generalSettingsPageTitle = { | ||
text: 'General', | ||
tag: 'h4', | ||
}; | ||
|
||
private readonly loadingOverlaySpinner = '.loading-overlay__spinner'; | ||
|
||
private readonly selectLanguageField = '[data-testid="locale-select"]'; | ||
|
||
constructor(driver: Driver) { | ||
this.driver = driver; | ||
} | ||
|
||
async check_pageIsLoaded(): Promise<void> { | ||
try { | ||
await this.check_noLoadingOverlaySpinner(); | ||
await this.driver.waitForMultipleSelectors([ | ||
this.generalSettingsPageTitle, | ||
this.selectLanguageField, | ||
]); | ||
} catch (e) { | ||
console.log( | ||
'Timeout while waiting for General Settings page to be loaded', | ||
e, | ||
); | ||
throw e; | ||
} | ||
console.log('General Settings page is loaded'); | ||
} | ||
|
||
/** | ||
* Change the language of MM on General Settings page | ||
* | ||
* @param languageToSelect - The language to select | ||
*/ | ||
async changeLanguage(languageToSelect: string): Promise<void> { | ||
console.log( | ||
'Changing language to ', | ||
languageToSelect, | ||
'on general settings page', | ||
); | ||
await this.check_noLoadingOverlaySpinner(); | ||
await this.driver.clickElement(this.selectLanguageField); | ||
await this.driver.clickElement({ | ||
text: languageToSelect, | ||
tag: 'option', | ||
}); | ||
await this.check_noLoadingOverlaySpinner(); | ||
} | ||
|
||
async check_noLoadingOverlaySpinner(): Promise<void> { | ||
await this.driver.assertElementNotPresent(this.loadingOverlaySpinner); | ||
} | ||
} | ||
|
||
export default GeneralSettings; |
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