Skip to content

Commit 5dbfbc2

Browse files
authored
fix: flaky test Settings Does not fetch ENS data for ENS Domain when ENS and IPFS switched off (#37983)
<!-- 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** The spec is flaky as sometimes we get a failed request, because we stopped the mock server. This changes the approach and keeps the mock server open. We only let pass through the ens req This will avoid errors while other API requests happen on the background, as we keep the rest of the mocks as usual <img width="401" height="126" alt="image" src="https://github.com/user-attachments/assets/24f60101-e9e6-4376-823f-454cc61a1ba7" /> https://github.com/search?q=org%3AMetaMask+%22failed+to+generate+nonce%22&type=code [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37983?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 ## **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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Stabilizes the ENS/IPFS settings e2e test by keeping the mock server running and pass-through ENS requests instead of stopping the server. > > - **E2E Tests (`test/e2e/tests/settings/ipfs-ens-resolution.spec.ts`)**: > - Import `MockedEndpoint` and add `ensDomainPassthrough` helper to pass through `ENS_NAME_URL` and `ENS_DESTINATION_URL`. > - Replace ad-hoc server handling with `testSpecificMock: ensDomainPassthrough`; remove manual server stop. > - Goal: avoid request failures by keeping mocks active while allowing ENS requests to pass through. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7b076d8. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 771fa62 commit 5dbfbc2

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

test/e2e/tests/settings/ipfs-ens-resolution.spec.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MockttpServer } from 'mockttp';
1+
import { MockedEndpoint, MockttpServer } from 'mockttp';
22
import { tinyDelayMs, withFixtures } from '../../helpers';
33
import FixtureBuilder from '../../fixture-builder';
44
import HeaderNavbar from '../../page-objects/pages/header-navbar';
@@ -59,15 +59,26 @@ describe('Settings', function () {
5959
});
6060

6161
it('Does not fetch ENS data for ENS Domain when ENS and IPFS switched off', async function () {
62-
let server: MockttpServer;
62+
async function ensDomainPassthrough(
63+
mockServer: MockttpServer,
64+
): Promise<MockedEndpoint[]> {
65+
// We want the browser to handle the request error
66+
const ensNamePassThrough = await mockServer
67+
.forGet(ENS_NAME_URL)
68+
.thenPassThrough();
69+
// This should never be hit, but in case it is, then we'll catch it
70+
const ensDomainsPassThrough = await mockServer
71+
.forGet(ENS_DESTINATION_URL)
72+
.thenPassThrough();
73+
74+
return [ensNamePassThrough, ensDomainsPassThrough];
75+
}
6376

6477
await withFixtures(
6578
{
6679
fixtures: new FixtureBuilder().build(),
6780
title: this.test?.fullTitle(),
68-
testSpecificMock: (mockServer: MockttpServer) => {
69-
server = mockServer;
70-
},
81+
testSpecificMock: ensDomainPassthrough,
7182
},
7283
async ({ driver }) => {
7384
await loginWithBalanceValidation(driver);
@@ -84,10 +95,6 @@ describe('Settings', function () {
8495
await privacySettings.toggleIpfsGateway();
8596
await privacySettings.toggleEnsDomainResolution();
8697

87-
// Now that we no longer need the MetaMask UI, and want the browser
88-
// to handle the request error, we need to stop the server
89-
await server.stop();
90-
9198
try {
9299
await driver.openNewPage(ENS_NAME_URL);
93100
} catch (e) {

0 commit comments

Comments
 (0)