Skip to content

Commit feb5d41

Browse files
authored
test(e2e): add bitcoin assets network filter cases (#47587)
## **Description** **Context** Bitcoin is a Snap-backed network in the extension: its account readiness, asset metadata, and balances flow through the Bitcoin Snap, the unified asset state, and the network-filter modal before anything renders in the homepage asset list. This PR closes a coverage gap in the Bitcoin E2E assets suite by mirroring what the Tron assets suite already does in `test/e2e/tests/assets/tron.spec.ts`. **Problem** `test/e2e/tests/btc/assets.spec.ts` verified the asset list for an empty account and the asset list plus native BTC details for a funded account, but it never exercised the network filter. Nothing asserted that: - selecting **All networks** surfaces other chains' assets alongside Bitcoin, or - the **Bitcoin-only** current-network filter renders *only* Bitcoin assets and hides assets from other chains. A regression in network-scoped filtering of unified asset state would therefore reach users unnoticed, because the existing cases only ever ran with Bitcoin selected. **Solution** Add a `Networks filter` describe block to `test/e2e/tests/btc/assets.spec.ts` with one isolated browser fixture per case: - `All networks filter shows other chains alongside Bitcoin` — logs in, switches to Bitcoin, waits for the Bitcoin row, selects All networks, then asserts both `Bitcoin` and `Ethereum` are in the list. - `Current network filter shows only Bitcoin assets` — logs in, switches to Bitcoin, then asserts the exact list is `['Bitcoin']` and that `Ethereum` is absent. Implementation notes for reviewers: - Reuses the existing `mockBtcAssetsFunded` static mocks and the existing `FixtureBuilderV2` setup; only `selectAllNetworksFromNetworkSelect` and `HOMEPAGE_BALANCE_ASSERTION_TIMEOUT_MS` are newly imported. No new fixture wrapper, flow, page-object API, mock, or page-object selector was added. - No Bitcoin local node/seeder is started for these cases. Network filtering is read-only and fully deterministic from the existing Esplora, token metadata, price, and default Ethereum fixture data — this matches the Tron filter tests, which run with `localNode: false`. `withFixtures` defaults to an Anvil node, so the default Ethereum account is funded and its row appears under All networks. - Spec stays POM-clean: existing flows and page-object `check*` methods only, no selectors or direct driver UI calls in the spec, no local UI helper, no hardcoded delay, and no `try`/`catch`. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: expand send E2E coverage ## **Manual testing steps** 1. Run the extension and get to an unlocked wallet that has a Bitcoin (Snap) account. 2. Go to the homepage asset list. 3. Open the network filter in the header and select **All networks**. 4. Verify Bitcoin is listed alongside assets from other chains (e.g. Ethereum). 5. Open the network filter again and select **Bitcoin** (current network only). 6. Verify only the Bitcoin asset is listed. 7. Verify Ethereum is not visible anywhere in the asset list while Bitcoin is the current network. <!-- ## **Screenshots/Recordings** ### **Before** ### **After** --> ## **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 changes with no production code, security, or data-handling impact. > > **Overview** > Adds **network filter** coverage to the Bitcoin assets E2E suite, aligned with the existing Tron assets pattern in `tron.spec.ts`. > > A new **`Networks filter`** block in `test/e2e/tests/btc/assets.spec.ts` introduces two cases on top of the existing `mockBtcAssetsFunded` setup: one selects **All networks** and expects **Bitcoin** and **Ethereum** in the token list; the other keeps **Bitcoin** as the current network and asserts the list is Bitcoin-only with **Ethereum** absent. Both reuse `selectAllNetworksFromNetworkSelect`, `HOMEPAGE_BALANCE_ASSERTION_TIMEOUT_MS`, and existing `TokensTab` checks—no new mocks, fixtures, or page-object APIs. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 884ae15. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 6eab056 commit feb5d41

1 file changed

Lines changed: 57 additions & 2 deletions

File tree

‎test/e2e/tests/btc/assets.spec.ts‎

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { Suite } from 'mocha';
22
import { Mockttp } from 'mockttp';
3-
import { DEFAULT_BTC_BALANCE } from '../../constants';
3+
import {
4+
DEFAULT_BTC_BALANCE,
5+
HOMEPAGE_BALANCE_ASSERTION_TIMEOUT_MS,
6+
} from '../../constants';
47
import FixtureBuilderV2 from '../../fixtures/fixture-builder-v2';
58
import { withFixtures } from '../../helpers';
69
import { login } from '../../page-objects/flows/login.flow';
7-
import { switchToNetworkFromNetworkSelect } from '../../page-objects/flows/network.flow';
10+
import {
11+
selectAllNetworksFromNetworkSelect,
12+
switchToNetworkFromNetworkSelect,
13+
} from '../../page-objects/flows/network.flow';
814
import AssetDetailsPage from '../../page-objects/pages/asset/asset-details';
915
import TokensTab from '../../page-objects/pages/home/tokens-tab';
1016
import HomePage from '../../page-objects/pages/home/homepage';
@@ -116,4 +122,53 @@ describe('BTC Account - Assets', function (this: Suite) {
116122
},
117123
);
118124
});
125+
126+
describe('Networks filter', function () {
127+
it('All networks filter shows other chains alongside Bitcoin', async function () {
128+
await withFixtures(
129+
{
130+
fixtures: new FixtureBuilderV2().build(),
131+
title: this.test?.fullTitle(),
132+
testSpecificMock: mockBtcAssetsFunded,
133+
},
134+
async ({ driver }) => {
135+
await login(driver);
136+
const homePage = new HomePage(driver);
137+
await switchToNetworkFromNetworkSelect(driver, 'Bitcoin');
138+
await homePage.checkPageIsLoaded();
139+
140+
const tokensTab = new TokensTab(driver);
141+
await tokensTab.checkTokenNameVisible('Bitcoin', {
142+
timeout: HOMEPAGE_BALANCE_ASSERTION_TIMEOUT_MS,
143+
});
144+
await selectAllNetworksFromNetworkSelect(driver);
145+
await tokensTab.checkTokenExistsInList('Bitcoin');
146+
await tokensTab.checkTokenExistsInList('Ethereum');
147+
},
148+
);
149+
});
150+
151+
it('Current network filter shows only Bitcoin assets', async function () {
152+
await withFixtures(
153+
{
154+
fixtures: new FixtureBuilderV2().build(),
155+
title: this.test?.fullTitle(),
156+
testSpecificMock: mockBtcAssetsFunded,
157+
},
158+
async ({ driver }) => {
159+
await login(driver);
160+
const homePage = new HomePage(driver);
161+
await switchToNetworkFromNetworkSelect(driver, 'Bitcoin');
162+
await homePage.checkPageIsLoaded();
163+
164+
const tokensTab = new TokensTab(driver);
165+
await tokensTab.checkTokenNameVisible('Bitcoin', {
166+
timeout: HOMEPAGE_BALANCE_ASSERTION_TIMEOUT_MS,
167+
});
168+
await tokensTab.checkOnlyAssetsArePresent(['Bitcoin']);
169+
await tokensTab.checkAssetIsAbsent('Ethereum');
170+
},
171+
);
172+
});
173+
});
119174
});

0 commit comments

Comments
 (0)