Skip to content

Commit d3196e2

Browse files
authored
test: split mixed settings page objects into one page object per screen (#47790)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Several settings page objects covered more than one screen. For example, `PrivacySettings` also handled Security and password, the SRP reveal flow and passkeys, and `PreferencesAndDisplaySettings` also handled Assets, Language and Account identicon. As a result, those routes had no page object in the route registry, and the methods were hard to find. This PR gives each settings screen its own page object: <img width="715" height="337" alt="image" src="https://github.com/user-attachments/assets/757ec531-f404-40d0-a572-2fd2001caf1e" /> - **Preferences and display:** `LanguageSettings`, `AccountIdenticonSettings` - **Security and password:** `SecurityAndPasswordSettings`, `AutoLockSettings`, `ManageWalletRecoverySettings`, `RegisterPasskeySettings`, `TurnOffPasskeySettings`, plus `RevealSrpPage` for `/seed` and `/seed/:keyringId` - **Privacy:** `ThirdPartyApisSettings` - **Other tabs:** `AssetsSettings`, `DeveloperToolsSettings`, `ShieldManagePlanPage` It also: - Groups the page objects for tabs with sub-pages into folders (`preferences-and-display/`, `security-and-password/`, `privacy/`), the same way `shield/` is organized. - Moves steps that cross screens into flows: `changeLanguage` and `openRevealSrp` in `settings.flow.ts`. - Removes the unused `advanced-settings.ts`. - Updates the route registry to map these screens. It also maps some existing page objects that were not registered yet: notification sections, Shield claim views, rewards, `/confirmation`, snap install, review permissions, suggested NFT and NFT image. Route coverage goes to 99 of 146 routes (71%). The specs were updated only to use the new page objects; what they test is unchanged. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: ## **Manual testing steps** 1. Run `yarn test:e2e:route-coverage` and check that the settings sub-routes now show a page object. 2. Open the extension and go to Settings > Security and password > Manage wallet recovery, then pick a Secret Recovery Phrase. Check that the reveal page still opens. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <img width="604" height="201" alt="image" src="https://github.com/user-attachments/assets/a5c77ec8-2e7a-4e50-a4b4-99413df34ec4" /> <img width="857" height="503" alt="image" src="https://github.com/user-attachments/assets/43b4494d-e478-47ba-a3c1-68adda47bb22" /> ### **After** <img width="576" height="196" alt="image" src="https://github.com/user-attachments/assets/30e9e808-3e46-4ab7-8656-975e0af41534" /> <img width="821" height="663" alt="image" src="https://github.com/user-attachments/assets/d7d59adc-9e75-4bc2-8c41-ca31afb5c1a6" /> ## **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/main/.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/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only E2E page-object and route-registry refactor with no production code changes. > > **Overview** > Refactors E2E settings coverage so **each settings screen has its own page object**, matching Settings V2 layout instead of overloaded helpers on `PrivacySettings` and `PreferencesAndDisplaySettings`. > > **New structure:** folders under `preferences-and-display/`, `security-and-password/`, and `privacy/`, plus dedicated types such as `AssetsSettings`, `DeveloperToolsSettings`, `RevealSrpPage`, `ManageWalletRecoverySettings`, passkey sub-pages, `ThirdPartyApisSettings`, and `ShieldManagePlanPage`. The monolithic `privacy-settings.ts`, old preferences file, and unused `advanced-settings.ts` are removed. > > **Flows:** `settings.flow.ts` gains shared steps like `navigateToSecurityAndPassword`, `openRevealSrp`, and `changeLanguage`; specs and flows now call the right screen object (e.g. SRP reveal via `RevealSrpPage` instead of privacy helpers). > > **Route registry:** many previously `null` routes now map to page objects (settings sub-routes, `/seed`, rewards, confirmations, snap install, etc.). `SettingsPage` drops tab-specific actions that moved to child objects. > > Test behavior is intended to stay the same; only navigation and page-object boundaries change. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dbaeedf. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 93f6c52 commit d3196e2

58 files changed

Lines changed: 1548 additions & 1428 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎test/e2e/dist/vault-decryption-chrome.spec.ts‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import { WALLET_PASSWORD, WINDOW_TITLES } from '../constants';
77
import { withFixtures } from '../helpers';
88
import HeaderNavbar from '../page-objects/pages/home/header-navbar';
99
import HomePage from '../page-objects/pages/home/homepage';
10-
import PrivacySettings from '../page-objects/pages/settings/privacy-settings';
10+
import RevealSrpPage from '../page-objects/pages/reveal-srp-page';
11+
import SecurityAndPasswordSettings from '../page-objects/pages/settings/security-and-password/security-and-password-settings';
1112
import SettingsPage from '../page-objects/pages/settings/settings-page';
1213
import VaultDecryptorPage from '../page-objects/pages/vault/decryptor-page';
1314
import { completeCreateNewWalletOnboardingFlowWithCustomSettings } from '../page-objects/flows/onboarding.flow';
15+
import { openRevealSrp } from '../page-objects/flows/settings.flow';
1416

1517
const VAULT_DECRYPTOR_PAGE = 'https://metamask.github.io/vault-decryptor';
1618

@@ -191,12 +193,12 @@ describe('Vault Decryptor Page', function () {
191193
await settingsPage.goToSecurityAndPasswordSettings();
192194

193195
// fill password to reveal SRP and get the SRP
194-
const privacySettings = new PrivacySettings(driver);
195-
await privacySettings.checkSecurityAndPasswordPageIsLoaded();
196-
await privacySettings.openRevealSrpQuiz();
197-
await privacySettings.completeRevealSrpQuiz();
198-
await privacySettings.fillPasswordToRevealSrp(WALLET_PASSWORD);
199-
const seedPhrase = await privacySettings.getSrpInRevealSrpDialog();
196+
await new SecurityAndPasswordSettings(driver).checkPageIsLoaded();
197+
await openRevealSrp(driver);
198+
const revealSrpPage = new RevealSrpPage(driver);
199+
await revealSrpPage.completeRevealSrpQuiz();
200+
await revealSrpPage.fillPasswordToRevealSrp(WALLET_PASSWORD);
201+
const seedPhrase = await revealSrpPage.getSrpText();
200202

201203
// compare the SRP values
202204
await driver.switchToWindowWithTitle('MetaMask Vault Decryptor');
@@ -250,12 +252,12 @@ describe('Vault Decryptor Page', function () {
250252
await settingsPage.goToSecurityAndPasswordSettings();
251253

252254
// fill password to reveal SRP and get the SRP
253-
const privacySettings = new PrivacySettings(driver);
254-
await privacySettings.checkSecurityAndPasswordPageIsLoaded();
255-
await privacySettings.openRevealSrpQuiz();
256-
await privacySettings.completeRevealSrpQuiz();
257-
await privacySettings.fillPasswordToRevealSrp(WALLET_PASSWORD);
258-
const seedPhrase = await privacySettings.getSrpInRevealSrpDialog();
255+
await new SecurityAndPasswordSettings(driver).checkPageIsLoaded();
256+
await openRevealSrp(driver);
257+
const revealSrpPage = new RevealSrpPage(driver);
258+
await revealSrpPage.completeRevealSrpQuiz();
259+
await revealSrpPage.fillPasswordToRevealSrp(WALLET_PASSWORD);
260+
const seedPhrase = await revealSrpPage.getSrpText();
259261

260262
// retry-logic to ensure the file is written before copying it
261263
const extensionPath = await getExtensionStorageFilePath(driver);

‎test/e2e/flask/multi-srp/import-srp.spec.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import HeaderNavbar from '../../page-objects/pages/home/header-navbar';
1414
import AccountListPage from '../../page-objects/pages/accounts/list-page';
1515
import HomePage from '../../page-objects/pages/home/homepage';
1616
import AccountDetailsPage from '../../page-objects/pages/accounts/details-page';
17-
import PrivacySettings from '../../page-objects/pages/settings/privacy-settings';
17+
import RevealSrpPage from '../../page-objects/pages/reveal-srp-page';
1818
import { mockActiveNetworks } from './common-multi-srp';
1919

2020
const TEST_SRP_WORDS_FOR_UI_TEST = [
@@ -71,10 +71,11 @@ describe('Multi SRP - Import SRP', function (this: Suite) {
7171
await accountListPage.clickMultichainAccountMenuItem('Account details');
7272
const accountDetailsPage = new AccountDetailsPage(driver);
7373
await accountDetailsPage.clickRevealRow();
74-
const privacySettings = new PrivacySettings(driver);
75-
await privacySettings.completeRevealSrpQuiz();
76-
await privacySettings.fillPasswordToRevealSrp(testPassword);
77-
await privacySettings.checkSrpTextIsDisplayed(SECOND_TEST_E2E_SRP);
74+
const revealSrpPage = new RevealSrpPage(driver);
75+
await revealSrpPage.checkPageIsLoaded();
76+
await revealSrpPage.completeRevealSrpQuiz();
77+
await revealSrpPage.fillPasswordToRevealSrp(testPassword);
78+
await revealSrpPage.checkSrpTextIsDisplayed(SECOND_TEST_E2E_SRP);
7879
},
7980
);
8081
});

‎test/e2e/page-objects/flows/identity.flow.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import HeaderNavbar from '../pages/home/header-navbar';
22
import HomePage from '../pages/home/homepage';
3-
import PrivacySettings from '../pages/settings/privacy-settings';
3+
import RevealSrpPage from '../pages/reveal-srp-page';
4+
import SecurityAndPasswordSettings from '../pages/settings/security-and-password/security-and-password-settings';
45
import SettingsPage from '../pages/settings/settings-page';
56
import { Driver } from '../../webdriver/driver';
67
import {
@@ -12,6 +13,7 @@ import {
1213
completeImportSRPOnboardingFlow,
1314
} from './onboarding.flow';
1415
import { waitUntilAccountTreeSyncIdle } from './add-account.flow';
16+
import { openRevealSrp } from './settings.flow';
1517

1618
export const completeOnboardFlowIdentity = async (
1719
driver: Driver,
@@ -57,11 +59,12 @@ export const getSRP = async (driver: Driver) => {
5759
await settingsPage.checkPageIsLoaded();
5860
await settingsPage.goToSecurityAndPasswordSettings();
5961

60-
const privacySettings = new PrivacySettings(driver);
61-
await privacySettings.checkSecurityAndPasswordPageIsLoaded();
62-
await privacySettings.openRevealSrpQuiz();
63-
await privacySettings.completeRevealSrpQuiz();
64-
await privacySettings.fillPasswordToRevealSrp(IDENTITY_TEAM_PASSWORD);
65-
const srp = await privacySettings.getSrpInRevealSrpDialog();
62+
await new SecurityAndPasswordSettings(driver).checkPageIsLoaded();
63+
await openRevealSrp(driver);
64+
65+
const revealSrpPage = new RevealSrpPage(driver);
66+
await revealSrpPage.completeRevealSrpQuiz();
67+
await revealSrpPage.fillPasswordToRevealSrp(IDENTITY_TEAM_PASSWORD);
68+
const srp = await revealSrpPage.getSrpText();
6669
return srp;
6770
};

‎test/e2e/page-objects/flows/multi-srp.flow.ts‎

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import AccountListPage from '../pages/accounts/list-page';
44
import TokensTab from '../pages/home/tokens-tab';
55
import HeaderNavbar from '../pages/home/header-navbar';
66
import HomePage from '../pages/home/homepage';
7-
import PrivacySettings from '../pages/settings/privacy-settings';
8-
import SettingsPage from '../pages/settings/settings-page';
7+
import RevealSrpPage from '../pages/reveal-srp-page';
8+
import ManageWalletRecoverySettings from '../pages/settings/security-and-password/manage-wallet-recovery-settings';
9+
import SecurityAndPasswordSettings from '../pages/settings/security-and-password/security-and-password-settings';
10+
import { navigateToSecurityAndPassword, openRevealSrp } from './settings.flow';
911

1012
export const SECOND_TEST_E2E_SRP =
1113
'bench top weekend buyer spoon side resist become detect gauge eye feed';
@@ -44,17 +46,13 @@ export async function verifySrp(
4446
srp: string,
4547
srpIndex: number,
4648
): Promise<void> {
47-
await new HeaderNavbar(driver).openSettingsPage();
48-
const settingsPage = new SettingsPage(driver);
49-
await settingsPage.checkPageIsLoaded();
50-
await settingsPage.goToSecurityAndPasswordSettings();
49+
await navigateToSecurityAndPassword(driver);
50+
await openRevealSrp(driver, srpIndex);
5151

52-
const privacySettings = new PrivacySettings(driver);
53-
await privacySettings.checkSecurityAndPasswordPageIsLoaded();
54-
await privacySettings.openRevealSrpQuiz(srpIndex);
55-
await privacySettings.completeRevealSrpQuiz();
56-
await privacySettings.fillPasswordToRevealSrp(WALLET_PASSWORD);
57-
await privacySettings.checkSrpTextIsDisplayed(srp);
52+
const revealSrpPage = new RevealSrpPage(driver);
53+
await revealSrpPage.completeRevealSrpQuiz();
54+
await revealSrpPage.fillPasswordToRevealSrp(WALLET_PASSWORD);
55+
await revealSrpPage.checkSrpTextIsDisplayed(srp);
5856
}
5957

6058
/**
@@ -70,13 +68,13 @@ export async function verifyAccountBelongsToSrp(
7068
driver: Driver,
7169
{ accountName, srpIndex }: { accountName: string; srpIndex: number },
7270
): Promise<void> {
73-
await new HeaderNavbar(driver).openSettingsPage();
74-
const settingsPage = new SettingsPage(driver);
75-
await settingsPage.checkPageIsLoaded();
76-
await settingsPage.goToSecurityAndPasswordSettings();
71+
await navigateToSecurityAndPassword(driver);
72+
await new SecurityAndPasswordSettings(driver).openManageWalletRecovery();
7773

78-
const privacySettings = new PrivacySettings(driver);
79-
await privacySettings.checkSecurityAndPasswordPageIsLoaded();
80-
await privacySettings.openSrpList();
81-
await privacySettings.checkAccountBelongsToSrp({ accountName, srpIndex });
74+
const manageWalletRecoverySettings = new ManageWalletRecoverySettings(driver);
75+
await manageWalletRecoverySettings.checkPageIsLoaded();
76+
await manageWalletRecoverySettings.checkAccountBelongsToSrp({
77+
accountName,
78+
srpIndex,
79+
});
8280
}

‎test/e2e/page-objects/flows/settings.flow.ts‎

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { Driver } from '../../webdriver/driver';
22
import HomePage from '../pages/home/homepage';
33
import SettingsPage from '../pages/settings/settings-page';
4-
import PreferencesAndDisplaySettings from '../pages/settings/preferences-and-display-settings';
4+
import AssetsSettings from '../pages/settings/assets-settings';
5+
import LanguageSettings from '../pages/settings/preferences-and-display/language-settings';
6+
import ManageWalletRecoverySettings from '../pages/settings/security-and-password/manage-wallet-recovery-settings';
7+
import PreferencesAndDisplaySettings from '../pages/settings/preferences-and-display/preferences-and-display-settings';
58
import NetworksPage from '../pages/networks/networks-page';
69
import HeaderNavbar from '../pages/home/header-navbar';
7-
import PrivacySettings from '../pages/settings/privacy-settings';
8-
import ChangePasswordPage from '../pages/settings/change-password-page';
10+
import RevealSrpPage from '../pages/reveal-srp-page';
11+
import SecurityAndPasswordSettings from '../pages/settings/security-and-password/security-and-password-settings';
12+
import ChangePasswordPage from '../pages/settings/security-and-password/change-password-page';
913
import { lockAndWaitForLoginPage } from './login.flow';
1014

1115
/**
@@ -57,13 +61,30 @@ export const enableNativeTokenAsMainBalance = async (
5761
await settingsPage.checkPageIsLoaded();
5862
await settingsPage.goToAssetsSettings();
5963

60-
const assetsSettings = new PreferencesAndDisplaySettings(driver);
61-
await assetsSettings.checkAssetsPageIsLoaded();
64+
const assetsSettings = new AssetsSettings(driver);
65+
await assetsSettings.checkPageIsLoaded();
6266
await assetsSettings.toggleShowNativeTokenAsMainBalance();
6367

6468
await closeSettings(driver);
6569
};
6670

71+
/**
72+
* Change the language from Settings → Preferences and display → Language.
73+
* Expects Settings to be open.
74+
*
75+
* @param driver - The WebDriver instance
76+
* @param language - The language name as shown in the list, e.g. 'Dansk'
77+
*/
78+
export async function changeLanguage(
79+
driver: Driver,
80+
language: string,
81+
): Promise<void> {
82+
await new PreferencesAndDisplaySettings(driver).openLanguageSettings();
83+
const languageSettings = new LanguageSettings(driver);
84+
await languageSettings.checkPageIsLoaded();
85+
await languageSettings.selectLanguage(language);
86+
}
87+
6788
export async function navigateToSecurityAndPassword(
6889
driver: Driver,
6990
): Promise<void> {
@@ -72,8 +93,26 @@ export async function navigateToSecurityAndPassword(
7293
const settingsPage = new SettingsPage(driver);
7394
await settingsPage.checkPageIsLoaded();
7495
await settingsPage.goToSecurityAndPasswordSettings();
75-
const privacySettings = new PrivacySettings(driver);
76-
await privacySettings.checkSecurityAndPasswordPageIsLoaded();
96+
const securityAndPasswordSettings = new SecurityAndPasswordSettings(driver);
97+
await securityAndPasswordSettings.checkPageIsLoaded();
98+
}
99+
100+
/**
101+
* Open the reveal page for a Secret Recovery Phrase, from Settings → Security
102+
* and password through the SRP list. Expects Security and password to be open.
103+
*
104+
* @param driver - The WebDriver instance
105+
* @param srpIndex - The 1-based index of the Secret Recovery Phrase
106+
*/
107+
export async function openRevealSrp(
108+
driver: Driver,
109+
srpIndex: number = 1,
110+
): Promise<void> {
111+
await new SecurityAndPasswordSettings(driver).openManageWalletRecovery();
112+
const manageWalletRecoverySettings = new ManageWalletRecoverySettings(driver);
113+
await manageWalletRecoverySettings.checkPageIsLoaded();
114+
await manageWalletRecoverySettings.selectSrp(srpIndex);
115+
await new RevealSrpPage(driver).checkPageIsLoaded();
77116
}
78117

79118
/**
@@ -94,8 +133,7 @@ export async function changePasswordAndLockWallet(
94133
): Promise<void> {
95134
await navigateToSecurityAndPassword(driver);
96135

97-
const privacySettings = new PrivacySettings(driver);
98-
await privacySettings.openChangePassword();
136+
await new SecurityAndPasswordSettings(driver).openChangePassword();
99137

100138
const changePasswordPage = new ChangePasswordPage(driver);
101139
await changePasswordPage.checkPageIsLoaded();

0 commit comments

Comments
 (0)