aboutsummaryrefslogtreecommitdiffstats
path: root/tools/padlock-flow-test.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-07 08:22:58 -0700
committerAdam Soltys <[email protected]>2026-10-07 08:22:58 -0700
commitfdb044b44019d45bf8f849a4cf64a56efbc54ada (patch)
treec6fdb70985603445e6365c8a0af3579b5faf3b28 /tools/padlock-flow-test.js
parentaf30d3cdc7da7f9e60bc552282f08ea7def3c0dd (diff)
downloadcoinosv3-fdb044b44019d45bf8f849a4cf64a56efbc54ada.tar.gz
coinosv3-fdb044b44019d45bf8f849a4cf64a56efbc54ada.zip
padlock-flow, onboard-backup, amber-login tests follow today's UI
- padlock-flow: the padlock lives behind the balance card's gear (wallet settings), declining lands back there; another wallet is added from the profile's 'Sign into another account' (import tab) and counted in the identity switcher, since the Accounts list is no longer reached from the wallet - onboard-backup: the welcome card lost its blurb (42c8d4e); the way in now says what the wallet is by putting the twelve words on screen at once - amber-login: the starter follows wait on the deep contact-list lookup (follows-overwrite fix), so their signature can come after the wallet opens; keep answering sign requests until things go quiet Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'tools/padlock-flow-test.js')
-rw-r--r--tools/padlock-flow-test.js51
1 files changed, 29 insertions, 22 deletions
diff --git a/tools/padlock-flow-test.js b/tools/padlock-flow-test.js
index e67711f..59aee32 100644
--- a/tools/padlock-flow-test.js
+++ b/tools/padlock-flow-test.js
@@ -1,7 +1,7 @@
// The padlock on a fresh (passwordless) wallet must never cost you your
// session: the set-a-password ask renders over the open wallet, declining it
// lands you exactly where you were, the logo stays a way home, and the
-// Wallets list shows only the on-chain wallet until Spending is set up.
+// wallet settings speak only of the on-chain wallet until Spending is set up.
// Setting a password locks in place: watch-only home, closed padlock.
// Run: bun tools/padlock-flow-test.js
import puppeteer from 'puppeteer-core';
@@ -20,9 +20,8 @@ const page = await browser.newPage();
await page.setViewport({ width: 420, height: 880 });
const click = (sel, t) => page.evaluate((s, x) => { const e = [...document.querySelectorAll(s)].find((n) => n.textContent.trim().toLowerCase().includes(x.toLowerCase())); if (e) { e.click(); return true; } return false; }, sel, t);
-const clickTitle = (t) => page.evaluate((x) => { const b = [...document.querySelectorAll('button')].find((n) => n.title === x); if (b) { b.click(); return true; } return false; }, t);
-// the padlock lives on the Accounts page: open it from the balance card first
-const padlock = async (pg, title) => { await pg.evaluate(() => document.querySelector('.balance-switch')?.click()); await sleep(500); return pg.evaluate((x) => { const b = [...document.querySelectorAll('button')].find((n) => n.title === x); if (b) { b.click(); return true; } return false; }, title); };
+// the padlock lives on the wallet settings: open them from the balance card's gear first
+const padlock = async (pg, title) => { await pg.evaluate(() => document.querySelector('.balance-gear')?.click()); await sleep(500); return pg.evaluate((x) => { const b = [...document.querySelectorAll('button')].find((n) => n.title === x); if (b) { b.click(); return true; } return false; }, title); };
const body = () => page.evaluate(() => document.body.innerText);
const waitText = async (x, ms = 20000) => { for (let i = 0; i < ms / 250; i++) { if ((await body()).toLowerCase().includes(x.toLowerCase())) return true; await sleep(250); } return false; };
@@ -41,8 +40,8 @@ try {
check('wallet open', await waitText('receive'));
await sleep(2000);
- console.log('\n[the Wallets list before opting into Spending]');
- await page.evaluate(() => document.querySelector('.balance-switch')?.click());
+ console.log('\n[the wallet settings before opting into Spending]');
+ await page.evaluate(() => document.querySelector('.balance-gear')?.click());
await sleep(600);
let txt = await body();
check('shows the on-chain wallet', /savings/i.test(txt), txt.slice(0, 140).replace(/\n+/g, ' | '));
@@ -60,7 +59,7 @@ try {
await click('button', 'Not now');
await sleep(600);
txt = await body();
- check('declining lands back where the padlock was tapped (the Accounts page)', /add account/i.test(txt), txt.slice(0, 120).replace(/\n+/g, ' | '));
+ check('declining lands back where the padlock was tapped (the wallet settings)', /security/i.test(txt) && !(await page.$('input[type=password]')), txt.slice(0, 120).replace(/\n+/g, ' | '));
console.log('\n[the logo still means home]');
await page.evaluate(() => document.querySelector('.brand')?.click());
@@ -79,7 +78,7 @@ try {
await sleep(1200);
txt = await body();
check('still home (watch-only), not signed out', /receive/i.test(txt) && /balance/i.test(txt), txt.slice(0, 120).replace(/\n+/g, ' | '));
- await page.evaluate(() => document.querySelector('.balance-switch')?.click()); await sleep(500);
+ await page.evaluate(() => document.querySelector('.balance-gear')?.click()); await sleep(500);
const closed = await page.evaluate(() => [...document.querySelectorAll('button')].some((b) => b.title && /unlock/i.test(b.title)));
check('padlock is closed', closed);
await page.evaluate(() => document.querySelector('.brand')?.click()); await sleep(400);
@@ -95,7 +94,6 @@ try {
const p2 = await ctx2.newPage();
await p2.setViewport({ width: 420, height: 880 });
const click2 = (t) => p2.evaluate((x) => { const e = [...document.querySelectorAll('button')].find((n) => n.textContent.trim().toLowerCase().includes(x.toLowerCase())); if (e) { e.click(); return true; } return false; }, t);
- const clickTitle2 = (t) => p2.evaluate((x) => { const b = [...document.querySelectorAll('button')].find((n) => n.title === x); if (b) { b.click(); return true; } return false; }, t);
const body2 = () => p2.evaluate(() => document.body.innerText);
const waitText2 = async (x, ms = 20000) => { for (let i = 0; i < ms / 250; i++) { if ((await body2()).toLowerCase().includes(x.toLowerCase())) return true; await sleep(250); } return false; };
const importWallet = async () => {
@@ -106,15 +104,25 @@ try {
await click2('Open wallet');
return waitText2('receive');
};
+ // another wallet comes in the way the app offers it now: your profile →
+ // Sign into another account (→ a new one, once others exist) → import
const addWallet = async () => {
- await p2.evaluate(() => document.querySelector('.balance-switch')?.click()); await sleep(600);
- await click2('Add wallet'); await sleep(400);
- await click2('Savings'); await sleep(200);
- await click2('Continue'); await sleep(600);
+ await p2.evaluate(() => document.querySelector('.header-avatar')?.click()); await sleep(800);
+ await click2('Sign into another account'); await sleep(500);
+ await click2('Sign into a new account'); await sleep(500);
+ await click2('Import existing'); await sleep(300); // the sign-in screen's import tab
return importWallet();
};
- const savingsRows = () => p2.evaluate(() => [...document.querySelectorAll('button')].map((e) => e.textContent.trim()).filter((x) => /^[●○] Savings/.test(x)).length);
-
+ // the wallets on this device, as the identity switcher lists them (the
+ // one open plus the others)
+ const walletCount = async () => {
+ await p2.evaluate(() => document.querySelector('.header-avatar')?.click()); await sleep(800);
+ await click2('Sign into another account'); await sleep(500);
+ const n = await p2.evaluate(() => document.querySelectorAll('.confirm-pop .clickable').length + 1);
+ await p2.evaluate(() => document.querySelector('.confirm-pop-backdrop')?.click()); await sleep(300);
+ await p2.evaluate(() => document.querySelector('.brand')?.click()); await sleep(500);
+ return n;
+ };
console.log('\n[a wallet created after a reload still auto-saves]');
await p2.goto('http://localhost:5236/', { waitUntil: 'domcontentloaded' });
await p2.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest'));
@@ -144,16 +152,15 @@ try {
console.log('\n[setting the password kept every saved wallet]');
await p2.reload({ waitUntil: 'domcontentloaded' });
check('reload keeps the locked view on screen', await waitText2('receive'));
- await clickTitle2('Unlock');
+ await padlock(p2, 'Unlock');
await sleep(600);
check('re-entry asks for the password', /unlock saved wallets|enter your password/i.test(await body2()));
await (await p2.$('input[type=password]')).type('hunter22');
await click2('Unlock');
check('password opens it', await waitText2('receive'));
await sleep(1000);
- await p2.evaluate(() => document.querySelector('.balance-switch')?.click()); await sleep(600);
- check('both wallets survived the re-encrypt', (await savingsRows()) === 2, `${await savingsRows()} row(s)`);
- await click2('Back'); await sleep(500);
+ let n = await walletCount();
+ check('both wallets survived the re-encrypt', n === 2, `${n} wallet(s)`);
console.log('\n[a new wallet against a passworded vault: the ask explains itself]');
await p2.reload({ waitUntil: 'domcontentloaded' }); // session restore again: vault password not in memory
@@ -176,14 +183,14 @@ try {
check('the right one saves C and locks in place', await waitText2('receive'));
await p2.reload({ waitUntil: 'domcontentloaded' });
check('locked view survives the reload', await waitText2('receive'));
- await clickTitle2('Unlock');
+ await padlock(p2, 'Unlock');
await sleep(600);
await (await p2.$('input[type=password]')).type('hunter22');
await click2('Unlock');
check('unlocked once more', await waitText2('receive'));
await sleep(1000);
- await p2.evaluate(() => document.querySelector('.balance-switch')?.click()); await sleep(600);
- check('all three wallets are in the vault', (await savingsRows()) === 3, `${await savingsRows()} row(s)`);
+ n = await walletCount();
+ check('all three wallets are in the vault', n === 3, `${n} wallet(s)`);
await ctx2.close();
} catch (e) {
check('run completed', false, e.message);