Skip to content

Commit f855a5e

Browse files
authored
test: fix flaky test Port Stream Chunking can load the wallet UI with a huge background state (~128MB) (#38395)
<!-- 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** Controllers take longer than usual to load if we use a wallet with a big state, causing the spec to fail as controllers are not loaded within 10 seconds (the css class which indicates that). This increases the timeout for this specific test. <img width="1050" height="812" alt="image" src="https://github.com/user-attachments/assets/1fb3f83d-12e4-42fe-abc6-28de9c2e3c4c" /> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/38395?quickstart=1) ## **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. Check ci -- note the spec was run multiple times due to the e2e quality gate, and it passed 100% of times ## **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/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.
1 parent 718bbf7 commit f855a5e

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

test/e2e/tests/port-stream-chunking/port-stream-chunking.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { Mockttp } from 'mockttp';
33
import { Browser } from 'selenium-webdriver';
44
import { getEventPayloads, withFixtures } from '../../helpers';
55
import FixtureBuilder from '../../fixtures/fixture-builder';
6-
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
76
import HomePage from '../../page-objects/pages/home/homepage';
87
import { MOCK_META_METRICS_ID } from '../../constants';
8+
import { PAGES } from '../../webdriver/driver';
9+
import LoginPage from '../../page-objects/pages/login-page';
910

1011
const isFirefox = process.env.SELENIUM_BROWSER === Browser.FIREFOX;
1112

@@ -61,7 +62,12 @@ describe('Port Stream Chunking', function () {
6162
testSpecificMock: mockSegment,
6263
},
6364
async ({ driver, mockedEndpoint }) => {
64-
await loginWithBalanceValidation(driver);
65+
// We need an unusual amount of time because of the large background state
66+
await driver.navigate(PAGES.HOME, { waitForControllersTimeout: 20000 });
67+
const loginPage = new LoginPage(driver);
68+
await loginPage.checkPageIsLoaded();
69+
await loginPage.loginToHomepage();
70+
6571
const homepage = new HomePage(driver);
6672
// Just check that the balance is displayed (wallet is usable)
6773
await homepage.checkExpectedBalanceIsDisplayed();

test/e2e/webdriver/driver.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,14 +1047,19 @@ class Driver {
10471047
* @param {object} [options] - optional parameter to specify additional options.
10481048
* @param {boolean} [options.waitForControllers] - optional parameter to specify whether to wait for the controllers to be loaded.
10491049
* Defaults to true.
1050+
* @param {number} [options.waitForControllersTimeout] - optional parameter to specify the timeout in milliseconds for waiting
1051+
* for the controllers to be loaded. Defaults to 10000 (10 seconds).
10501052
* @returns {Promise} promise resolves when the page has finished loading
10511053
* @throws {Error} Will throw an error if the navigation fails or the page does not load within the timeout period.
10521054
*/
1053-
async navigate(page = PAGES.HOME, { waitForControllers = true } = {}) {
1055+
async navigate(
1056+
page = PAGES.HOME,
1057+
{ waitForControllers = true, waitForControllersTimeout = 10000 } = {},
1058+
) {
10541059
const response = await this.driver.get(`${this.extensionUrl}/${page}.html`);
10551060
// Wait for asynchronous JavaScript to load
10561061
if (waitForControllers) {
1057-
await this.waitForControllersLoaded();
1062+
await this.waitForControllersLoaded(waitForControllersTimeout);
10581063
}
10591064
return response;
10601065
}
@@ -1065,13 +1070,15 @@ class Driver {
10651070
* This function waits until an element with the class 'controller-loaded' is located,
10661071
* indicating that the controllers have finished loading.
10671072
*
1073+
* @param {number} [timeout] - optional timeout in milliseconds for waiting for the controllers to be loaded.
1074+
* Defaults to 10000 (10 seconds).
10681075
* @returns {Promise<void>} A promise that resolves when the controllers are loaded.
10691076
* @throws {Error} Will throw an error if the element is not located within the timeout period.
10701077
*/
1071-
async waitForControllersLoaded() {
1078+
async waitForControllersLoaded(timeout = 10000) {
10721079
await this.driver.wait(
10731080
until.elementLocated(this.buildLocator('.controller-loaded')),
1074-
10 * 1000,
1081+
timeout,
10751082
);
10761083
}
10771084

0 commit comments

Comments
 (0)