Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(settings): add helper functions for recovery phrase replacement flow

Steven Enamakel885912d2d4c2
diff --git a/app/test/playwright/specs/settings-recovery-phrase-replace.spec.ts b/app/test/playwright/specs/settings-recovery-phrase-replace.spec.ts
index dc8e53305f..558beffc7f 100644
--- a/app/test/playwright/specs/settings-recovery-phrase-replace.spec.ts
+++ b/app/test/playwright/specs/settings-recovery-phrase-replace.spec.ts
@@ -70,6 +70,14 @@ const importInstead = (page: Page) =>
page.getByRole('button', { name: 'I already have a recovery phrase' });
const cancelButton = (page: Page) => page.getByRole('button', { name: 'Cancel' });
const copyButton = (page: Page) => page.getByRole('button', { name: 'Copy to Clipboard' });
+const createWalletMenuItem = (page: Page) =>
+ page.getByRole('menuitem', { name: 'Create a New Wallet' });
+
+async function enterReplacementGate(page: Page): Promise<void> {
+ await replaceButton(page).click();
+ await createWalletMenuItem(page).click();
+ await expect(confirmReplace(page)).toBeVisible();
+}
async function gotoRecoveryPhrase(page: Page) {
await page.goto('/#/settings/recovery-phrase');
@@ -92,6 +100,7 @@ async function gotoRecoveryPhrase(page: Page) {
async function ensureConfiguredWallet(page: Page) {
if (!(await walletState()).configured) {
await gotoRecoveryPhrase(page);
+ await page.getByRole('button', { name: 'Reveal recovery phrase' }).click();
await expect(copyButton(page)).toBeVisible({ timeout: 30_000 });
await page.locator('#mnemonic-confirm-checkbox').check();
await page.getByRole('button', { name: 'Save Recovery Phrase' }).click();
@@ -129,7 +138,8 @@ test.describe('Recovery phrase — the replace gate', () => {
test('clicking Replace wallet shows the gate, not the new phrase', async ({ page }) => {
await replaceButton(page).click();
-
+ await expect(createWalletMenuItem(page)).toBeVisible();
+ await createWalletMenuItem(page).click();
await expect(confirmReplace(page)).toBeVisible();
await expect(importInstead(page)).toBeVisible();
await expect(cancelButton(page)).toBeVisible();
@@ -142,8 +152,7 @@ test.describe('Recovery phrase — the replace gate', () => {
expect(before.configured).toBe(true);
expect(before.addresses.length).toBeGreaterThan(0);
- await replaceButton(page).click();
- await expect(confirmReplace(page)).toBeVisible();
+ await enterReplacementGate(page);
await cancelButton(page).click();
@@ -160,8 +169,7 @@ test.describe('Recovery phrase — the replace gate', () => {
test('navigating away from the open gate does not replace the wallet', async ({ page }) => {
const before = await walletState();
- await replaceButton(page).click();
- await expect(confirmReplace(page)).toBeVisible();
+ await enterReplacementGate(page);
// Abandoning the flow mid-gate is the likeliest real-world exit, and must
// be as safe as pressing Cancel.
@@ -175,8 +183,7 @@ test.describe('Recovery phrase — the replace gate', () => {
test('re-entering the panel after Cancel starts from view mode, not the gate', async ({
page,
}) => {
- await replaceButton(page).click();
- await expect(confirmReplace(page)).toBeVisible();
+ await enterReplacementGate(page);
await cancelButton(page).click();
await expect(replaceButton(page)).toBeVisible();
@@ -194,7 +201,7 @@ test.describe('Recovery phrase — the replace gate', () => {
}) => {
const before = await walletState();
- await replaceButton(page).click();
+ await enterReplacementGate(page);
await importInstead(page).click();
// Import mode: word slots, and no generated phrase to copy. The slots are