Skip to content

Commit 014ecbd

Browse files
committed
fix: CI synpress issues vol.2
1 parent 3b71c7a commit 014ecbd

File tree

1 file changed

+47
-97
lines changed

1 file changed

+47
-97
lines changed

e2e/setup/wallet.setup.ts

Lines changed: 47 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'node:path';
22
import { defineWalletSetup } from '@synthetixio/synpress';
3-
import { getExtensionId } from '@synthetixio/synpress/playwright';
3+
import { getExtensionId, MetaMask } from '@synthetixio/synpress/playwright';
44
import dotenv from 'dotenv';
55

66
dotenv.config({ path: path.resolve('e2e/.env') });
@@ -14,104 +14,54 @@ if (!SEED_PHRASE || !PASSWORD) {
1414
);
1515
}
1616

17-
/**
18-
* Fill the MetaMask 13.x SRP input via per-word fields.
19-
*
20-
* MM 13.x `SrpInputImport` starts as a single `<Textarea>` and transitions
21-
* to individual `<TextField>` inputs after the first word + Space. Synpress's
22-
* `.type(phrase)` races with the React DOM swap on CI/xvfb, leaving the
23-
* Continue button disabled.
24-
*
25-
* Approach: type the first word into the textarea, press Space to switch to
26-
* per-word mode, then `.fill()` each remaining word — exactly how MetaMask's
27-
* own Playwright tests handle it.
28-
*/
29-
async function fillSrpPerWord(
30-
page: import('@playwright/test').Page,
31-
seedPhrase: string,
32-
) {
33-
const words = seedPhrase.split(' ');
34-
35-
const textarea = page.getByTestId('srp-input-import__srp-note');
36-
await textarea.fill(words[0]);
37-
await textarea.press('Space');
38-
39-
for (let i = 1; i < words.length; i++) {
40-
const field = page.getByTestId(`import-srp__srp-word-${i}`);
41-
await field.fill(words[i]);
42-
if (i < words.length - 1) {
43-
await field.press('Space');
44-
}
45-
}
46-
}
47-
4817
const walletSetup = defineWalletSetup(PASSWORD, async (context, walletPage) => {
4918
const extensionId = await getExtensionId(context, 'MetaMask');
50-
const homeUrl = `chrome-extension://${extensionId}/home.html`;
51-
52-
await walletPage
53-
.locator('[data-testid="onboarding-import-wallet"]')
54-
.click();
55-
await walletPage.getByTestId('onboarding-import-with-srp-button').click();
56-
57-
await fillSrpPerWord(walletPage, SEED_PHRASE);
58-
59-
await walletPage.getByTestId('import-srp-confirm').click();
60-
61-
// Create password.
62-
await walletPage
63-
.locator('[data-testid="create-password-new-input"]')
64-
.fill(PASSWORD);
65-
await walletPage
66-
.locator('[data-testid="create-password-confirm-input"]')
67-
.fill(PASSWORD);
68-
await walletPage.locator('[data-testid="create-password-terms"]').click();
69-
await walletPage.locator('[data-testid="create-password-submit"]').click();
70-
71-
// Analytics opt-out.
72-
await walletPage.locator('#metametrics-opt-in').click();
73-
await walletPage.locator('[data-testid="metametrics-i-agree"]').click();
74-
75-
// Post-import: navigate home, unlock if needed, complete onboarding.
76-
await walletPage.goto(homeUrl);
77-
await walletPage.waitForTimeout(2000);
78-
79-
const lockInput = walletPage.locator('[data-testid="unlock-password"]');
80-
if (await lockInput.isVisible().catch(() => false)) {
81-
await lockInput.fill(PASSWORD);
82-
await walletPage.locator('[data-testid="unlock-submit"]').click();
83-
await walletPage.waitForTimeout(2000);
84-
}
85-
86-
const openWalletBtn = walletPage.locator(
87-
'[data-testid="onboarding-complete-done"]',
88-
);
89-
if (await openWalletBtn.isVisible().catch(() => false)) {
90-
await openWalletBtn.click();
91-
await walletPage.waitForTimeout(3000);
92-
}
93-
94-
// Enable test networks in Advanced settings.
95-
await walletPage.goto(`${homeUrl}#settings/advanced`);
96-
await walletPage.waitForTimeout(2000);
97-
98-
await walletPage
99-
.locator('.tab-bar__tab')
100-
.filter({ hasText: 'Advanced' })
101-
.click();
102-
await walletPage.waitForTimeout(1000);
103-
104-
const offToggle = walletPage.locator(
105-
'[data-testid="advanced-setting-show-testnet-conversion"] label.toggle-button--off:not(.show-fiat-on-testnets-toggle)',
106-
);
107-
if ((await offToggle.count()) > 0) {
108-
await offToggle.click();
109-
await walletPage
110-
.locator(
111-
'[data-testid="advanced-setting-show-testnet-conversion"] label.toggle-button--on:not(.show-fiat-on-testnets-toggle)',
112-
)
113-
.waitFor({ state: 'visible', timeout: 5000 });
114-
}
19+
const metamask = new MetaMask(context, walletPage, PASSWORD, extensionId);
20+
21+
await metamask.importWallet(SEED_PHRASE);
22+
23+
// const homeUrl = `chrome-extension://${extensionId}/home.html`;
24+
25+
// // Post-import: navigate home, unlock if needed, complete onboarding.
26+
// await walletPage.goto(homeUrl);
27+
// await walletPage.waitForTimeout(2000);
28+
29+
// const lockInput = walletPage.locator('[data-testid="unlock-password"]');
30+
// if (await lockInput.isVisible().catch(() => false)) {
31+
// await lockInput.fill(PASSWORD);
32+
// await walletPage.locator('[data-testid="unlock-submit"]').click();
33+
// await walletPage.waitForTimeout(2000);
34+
// }
35+
36+
// const openWalletBtn = walletPage.locator(
37+
// '[data-testid="onboarding-complete-done"]',
38+
// );
39+
// if (await openWalletBtn.isVisible().catch(() => false)) {
40+
// await openWalletBtn.click();
41+
// await walletPage.waitForTimeout(3000);
42+
// }
43+
44+
// // Enable test networks in Advanced settings.
45+
// await walletPage.goto(`${homeUrl}#settings/advanced`);
46+
// await walletPage.waitForTimeout(2000);
47+
48+
// await walletPage
49+
// .locator('.tab-bar__tab')
50+
// .filter({ hasText: 'Advanced' })
51+
// .click();
52+
// await walletPage.waitForTimeout(1000);
53+
54+
// const offToggle = walletPage.locator(
55+
// '[data-testid="advanced-setting-show-testnet-conversion"] label.toggle-button--off:not(.show-fiat-on-testnets-toggle)',
56+
// );
57+
// if ((await offToggle.count()) > 0) {
58+
// await offToggle.click();
59+
// await walletPage
60+
// .locator(
61+
// '[data-testid="advanced-setting-show-testnet-conversion"] label.toggle-button--on:not(.show-fiat-on-testnets-toggle)',
62+
// )
63+
// .waitFor({ state: 'visible', timeout: 5000 });
64+
// }
11565
});
11666

11767
const WALLET_SETUP_CACHE_KEY = 'wallet-setup';

0 commit comments

Comments
 (0)