Skip to content

Commit 1a27e14

Browse files
fix: add missing mock for portfolio site in e2e testing (#31034)
<!-- 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** This PR is to fix the missing mock for portfolio site in specs: - test/e2e/tests/portfolio/portfolio-site.spec.ts - test/e2e/tests/bridge/bridge-button-opens-portfolio.spec.ts - test/e2e/tests/phishing-controller/phishing-detection.spec.js <!-- 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? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/31034?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **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 398221b commit 1a27e14

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

privacy-snapshot.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,6 @@
8484
"unresponsive-rpc.url",
8585
"user-storage.api.cx.metamask.io",
8686
"verify.walletconnect.com",
87-
"www.4byte.directory"
87+
"www.4byte.directory",
88+
"api.web3modal.org"
8889
]

test/e2e/tests/bridge/bridge-test-utils.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SMART_CONTRACTS } from '../../seeder/smart-contracts';
99
import { CHAIN_IDS } from '../../../../shared/constants/network';
1010
import { Driver } from '../../webdriver/driver';
1111
import type { FeatureFlagResponse } from '../../../../shared/types/bridge';
12+
import { emptyHtmlPage } from '../../mock-e2e';
1213
import {
1314
DEFAULT_FEATURE_FLAGS_RESPONSE,
1415
ETH_CONVERSION_RATE_USD,
@@ -62,7 +63,7 @@ export class BridgePage {
6263
};
6364

6465
verifyPortfolioTab = async () => {
65-
await this.driver.switchToWindowWithTitle('MetaMask Portfolio - Bridge');
66+
await this.driver.switchToWindowWithTitle('E2E Test Page');
6667
await this.driver.waitForUrlContaining({
6768
url: 'portfolio.metamask.io/bridge',
6869
});
@@ -101,16 +102,15 @@ const mockServer =
101102
};
102103
}),
103104
);
104-
const portfolioMock = async () =>
105-
await mockServer_
106-
.forGet('https://portfolio.metamask.io/bridge')
107-
.always()
108-
.thenCallback(() => {
109-
return {
110-
statusCode: 200,
111-
json: {},
112-
};
113-
});
105+
const portfolioMock = mockServer_
106+
.forGet(`https://portfolio.metamask.io/bridge`)
107+
.always()
108+
.thenCallback(() => {
109+
return {
110+
statusCode: 200,
111+
body: emptyHtmlPage(),
112+
};
113+
});
114114
return Promise.all([...featureFlagMocks, portfolioMock]);
115115
};
116116

test/e2e/tests/phishing-controller/mocks.js

+10
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ async function setupPhishingDetectionMocks(
112112
body: emptyHtmlPage(blockProvider),
113113
};
114114
});
115+
116+
await mockServer
117+
.forGet(`https://portfolio.metamask.io`)
118+
.always()
119+
.thenCallback(() => {
120+
return {
121+
statusCode: 200,
122+
body: emptyHtmlPage(),
123+
};
124+
});
115125
}
116126

117127
/**

test/e2e/tests/portfolio/portfolio-site.spec.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import { MockttpServer } from 'mockttp';
22
import { withFixtures } from '../../helpers';
3-
import { PORTFOLIO_PAGE_TITLE, MOCK_META_METRICS_ID } from '../../constants';
3+
import { MOCK_META_METRICS_ID } from '../../constants';
44
import FixtureBuilder from '../../fixture-builder';
55
import { emptyHtmlPage } from '../../mock-e2e';
66
import HomePage from '../../page-objects/pages/home/homepage';
77
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
8+
import MockedPage from '../../page-objects/pages/mocked-page';
89

910
describe('Portfolio site', function () {
1011
async function mockPortfolioSite(mockServer: MockttpServer) {
1112
return await mockServer
1213
.forGet('https://portfolio.metamask.io/')
1314
.withQuery({
1415
metamaskEntry: 'ext_portfolio_button',
15-
metametricsId: 'null',
16+
metametricsId: MOCK_META_METRICS_ID,
17+
metricsEnabled: 'true',
18+
marketingEnabled: 'false',
1619
})
1720
.thenCallback(() => {
1821
return {
@@ -38,12 +41,15 @@ describe('Portfolio site', function () {
3841
async ({ driver }) => {
3942
await loginWithBalanceValidation(driver);
4043
await new HomePage(driver).openPortfolioPage();
41-
await driver.switchToWindowWithTitle(PORTFOLIO_PAGE_TITLE);
44+
await driver.switchToWindowWithTitle('E2E Test Page');
4245

4346
// Verify site
4447
await driver.waitForUrl({
4548
url: `https://portfolio.metamask.io/?metamaskEntry=ext_portfolio_button&metametricsId=${MOCK_META_METRICS_ID}&metricsEnabled=true&marketingEnabled=false`,
4649
});
50+
await new MockedPage(driver).check_displayedMessage(
51+
'Empty page by MetaMask',
52+
);
4753
},
4854
);
4955
});

0 commit comments

Comments
 (0)