Skip to content

Commit 0ab66ec

Browse files
authored
test: remove withSolanaAccountSnap as we have default Multichain support in all our e2e (#40327)
<!-- 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 removes the `withSolanaAccountSnap` method, as we have default Multichain support in all our e2e, so we don't need the duplicated setup of feature flags etc (which is already set by default). All specs start the wallet with multichain accounts, meaning this method is now obsolete/missleading/duplicated. Instead of `withSolanaAccountSnap` we can use `withFixtures` out of the box. This simplifies test setup and makes the tests also easier to debug and maintain. Additional changes: - whenever it was possible, used FixtureBuilderV2 instead of the legacy one (see data below) - removed dead code Note: e2e quality gate is disabled due to the number of specs changed, causing the ci to timeout due to extra test runs. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/40327?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. All ci tests should continue to pass ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** This data is for the migration of V2 fixtures (before and after): <img width="3059" height="1541" alt="image" src="https://github.com/user-attachments/assets/19a37600-8c86-4e74-80ef-3dd63f679b22" /> ### **After** <img width="3059" height="1541" alt="image" src="https://github.com/user-attachments/assets/6f697891-9aef-49c9-805a-59c2862019c6" /> ## **Pre-merge author checklist** - [ ] 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). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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] > **Medium Risk** > Broad test-harness refactor touching many E2E specs and mocks; risk is primarily increased CI flakiness or missing setup (login/network/account) causing false failures rather than production impact. > > **Overview** > Removes the bespoke Solana E2E harness `withSolanaAccountSnap` in favor of using `withFixtures` directly across Solana/multichain specs, updating tests to explicitly log in, switch to Solana where needed, and pass `fixtures`/`dappOptions`/`testSpecificMock` per scenario. > > Refactors Solana test mocking by introducing `buildSolanaTestSpecificMock` (and `SolanaMockOptions`) plus a more flexible `mockSolanaBalanceQuote` signature, and updates affected swap/SPL/tx tests accordingly. Adds a reusable `addAccount` flow for creating/switching multichain accounts, extends `FixtureBuilderV2` with `withShowNativeTokenAsMainBalanceDisabled`, and tweaks `HomePage.checkPageIsLoaded` to wait on the balance section rather than the send button. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 891c68a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2d97697 commit 0ab66ec

19 files changed

Lines changed: 544 additions & 498 deletions

‎test/e2e/fixtures/fixture-builder-v2.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ class FixtureBuilderV2 {
160160
});
161161
}
162162

163+
withShowNativeTokenAsMainBalanceDisabled(): this {
164+
return this.withPreferencesController({
165+
preferences: {
166+
showNativeTokenAsMainBalance: false,
167+
},
168+
});
169+
}
170+
163171
build() {
164172
return this.fixture;
165173
}

‎test/e2e/flask/multichain-api/non-evm/wallet_createSession.spec.ts‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import { strict as assert } from 'assert';
22
import { By } from 'selenium-webdriver';
3-
import { largeDelayMs } from '../../../helpers';
3+
import { largeDelayMs, withFixtures } from '../../../helpers';
4+
import { SOLANA_MAINNET_SCOPE } from '../../../constants';
5+
import FixtureBuilderV2 from '../../../fixtures/fixture-builder-v2';
6+
import { loginWithBalanceValidation } from '../../../page-objects/flows/login.flow';
7+
import { addAccount } from '../../../page-objects/flows/add-account.flow';
48
import TestDappMultichain from '../../../page-objects/pages/test-dapp-multichain';
59
import { DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS } from '../testHelpers';
6-
import { withSolanaAccountSnap } from '../../../tests/solana/common-solana';
710

811
describe('Multichain API - Non EVM', function () {
9-
const SOLANA_SCOPE = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp';
1012
describe("Call `wallet_createSession` with both EVM and Solana scopes that match the user's enabled networks", function () {
1113
it('should only select the specified scopes requested by the user', async function () {
12-
await withSolanaAccountSnap(
14+
await withFixtures(
1315
{
1416
...DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS,
17+
fixtures: new FixtureBuilderV2().build(),
1518
title: this.test?.fullTitle(),
1619
},
17-
async (driver, _, extensionId) => {
20+
async ({ driver, extensionId }) => {
21+
await loginWithBalanceValidation(driver);
1822
const requestScopesToNetworkMap = {
1923
'eip155:1': 'Ethereum',
20-
[SOLANA_SCOPE]: 'Solana',
24+
[SOLANA_MAINNET_SCOPE]: 'Solana',
2125
};
2226

2327
const requestScopes = Object.keys(requestScopesToNetworkMap);
@@ -72,17 +76,20 @@ describe('Multichain API - Non EVM', function () {
7276

7377
describe('Connect wallet to the multichain dapp via `externally_connectable`, call `wallet_createSession` with Solana scope, without any accounts requested', function () {
7478
it('should automatically select the current active Solana account', async function () {
75-
await withSolanaAccountSnap(
79+
await withFixtures(
7680
{
7781
...DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS,
82+
fixtures: new FixtureBuilderV2().build(),
7883
title: this.test?.fullTitle(),
79-
numberOfAccounts: 2,
8084
},
81-
async (driver, _, extensionId) => {
85+
async ({ driver, extensionId }) => {
86+
await loginWithBalanceValidation(driver);
87+
await addAccount({ driver, switchToAccount: 'Account 1' });
88+
8289
const testDapp = new TestDappMultichain(driver);
8390
await testDapp.openTestDappPage();
8491
await testDapp.connectExternallyConnectable(extensionId);
85-
await testDapp.initCreateSessionScopes([SOLANA_SCOPE]);
92+
await testDapp.initCreateSessionScopes([SOLANA_MAINNET_SCOPE]);
8693

8794
const editButtons = await driver.findElements('[data-testid="edit"]');
8895
await editButtons[0].click();

‎test/e2e/flask/multichain-api/non-evm/wallet_invokeMethod.spec.ts‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
import { strict as assert } from 'assert';
22
import { isObject } from 'lodash';
3-
import { WINDOW_TITLES } from '../../../constants';
3+
import { SOLANA_MAINNET_SCOPE, WINDOW_TITLES } from '../../../constants';
44
import TestDappMultichain from '../../../page-objects/pages/test-dapp-multichain';
55
import { DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS } from '../testHelpers';
6-
import { withSolanaAccountSnap } from '../../../tests/solana/common-solana';
6+
import { buildSolanaTestSpecificMock } from '../../../tests/solana/common-solana';
7+
import { withFixtures } from '../../../helpers';
8+
import FixtureBuilderV2 from '../../../fixtures/fixture-builder-v2';
9+
import { loginWithBalanceValidation } from '../../../page-objects/flows/login.flow';
710
import SnapTransactionConfirmation from '../../../page-objects/pages/confirmations/snap-transaction-confirmation';
811
import SnapSignInConfirmation from '../../../page-objects/pages/confirmations/snap-sign-in-confirmation';
912

1013
describe('Multichain API - Non EVM', function () {
11-
const SOLANA_SCOPE = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp';
1214
describe('Calling `wallet_invokeMethod`', function () {
1315
describe('signIn method', function () {
1416
it('Should match selected method to the expected confirmation UI', async function () {
15-
await withSolanaAccountSnap(
17+
await withFixtures(
1618
{
1719
...DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS,
20+
fixtures: new FixtureBuilderV2().build(),
1821
title: this.test?.fullTitle(),
1922
},
20-
async (driver, _, extensionId) => {
23+
async ({ driver, extensionId }) => {
24+
await loginWithBalanceValidation(driver);
2125
const testDapp = new TestDappMultichain(driver);
2226
await testDapp.openTestDappPage();
2327
await testDapp.connectExternallyConnectable(extensionId);
24-
await testDapp.initCreateSessionScopes([SOLANA_SCOPE]);
28+
await testDapp.initCreateSessionScopes([SOLANA_MAINNET_SCOPE]);
2529
await driver.clickElementAndWaitForWindowToClose({
2630
text: 'Connect',
2731
tag: 'button',
@@ -32,7 +36,7 @@ describe('Multichain API - Non EVM', function () {
3236
);
3337

3438
await testDapp.invokeMethod({
35-
scope: SOLANA_SCOPE,
39+
scope: SOLANA_MAINNET_SCOPE,
3640
method: 'signIn',
3741
});
3842

@@ -47,17 +51,21 @@ describe('Multichain API - Non EVM', function () {
4751

4852
describe('signAndSendTransaction method', function () {
4953
it('Should match selected method to the expected confirmation UI', async function () {
50-
await withSolanaAccountSnap(
54+
await withFixtures(
5155
{
5256
...DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS,
57+
fixtures: new FixtureBuilderV2().build(),
5358
title: this.test?.fullTitle(),
54-
mockGetTransactionSuccess: true,
59+
testSpecificMock: buildSolanaTestSpecificMock({
60+
mockGetTransactionSuccess: true,
61+
}),
5562
},
56-
async (driver, _, extensionId) => {
63+
async ({ driver, extensionId }) => {
64+
await loginWithBalanceValidation(driver);
5765
const testDapp = new TestDappMultichain(driver);
5866
await testDapp.openTestDappPage();
5967
await testDapp.connectExternallyConnectable(extensionId);
60-
await testDapp.initCreateSessionScopes([SOLANA_SCOPE]);
68+
await testDapp.initCreateSessionScopes([SOLANA_MAINNET_SCOPE]);
6169
await driver.clickElementAndWaitForWindowToClose({
6270
text: 'Connect',
6371
tag: 'button',
@@ -70,7 +78,7 @@ describe('Multichain API - Non EVM', function () {
7078
const invokeMethod = 'signAndSendTransaction';
7179

7280
await testDapp.invokeMethod({
73-
scope: SOLANA_SCOPE,
81+
scope: SOLANA_MAINNET_SCOPE,
7482
method: invokeMethod,
7583
});
7684

@@ -86,7 +94,7 @@ describe('Multichain API - Non EVM', function () {
8694
);
8795

8896
const transactionResult = await testDapp.getInvokeMethodResult({
89-
scope: SOLANA_SCOPE,
97+
scope: SOLANA_MAINNET_SCOPE,
9098
method: invokeMethod,
9199
});
92100
const parsedTransactionResult = JSON.parse(transactionResult);

‎test/e2e/flask/snaps/test-snap-protocol.spec.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
import { openTestSnapClickButtonAndInstall } from '../../page-objects/flows/install-test-snap.flow';
22
import { DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS } from '../multichain-api/testHelpers';
33
import { DAPP_ONE_URL, WINDOW_TITLES } from '../../constants';
4-
import { withSolanaAccountSnap } from '../../tests/solana/common-solana';
4+
import { buildSolanaTestSpecificMock } from '../../tests/solana/common-solana';
5+
import { withFixtures } from '../../helpers';
6+
import FixtureBuilder from '../../fixtures/fixture-builder';
7+
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
58
import ConnectAccountConfirmation from '../../page-objects/pages/confirmations/connect-account-confirmation';
69
import TestDappMultichain from '../../page-objects/pages/test-dapp-multichain';
710

811
describe('Test Protocol Snaps', function () {
912
it('can call getBlockHeight exposed by Snap', async function () {
10-
await withSolanaAccountSnap(
13+
await withFixtures(
1114
{
15+
fixtures: new FixtureBuilder().build(),
1216
title: this.test?.fullTitle(),
13-
withProtocolSnap: true,
1417
...DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS,
18+
testSpecificMock: buildSolanaTestSpecificMock({
19+
withProtocolSnap: true,
20+
}),
1521
},
16-
async (driver, mockServer, extensionId) => {
22+
async ({ driver, mockServer, extensionId }) => {
23+
await loginWithBalanceValidation(driver);
1724
const mockBlockHeight = 368556246;
1825
await mockServer
1926
.forPost('https://api.devnet.solana.com/')

0 commit comments

Comments
 (0)