diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/lock-wallet-test.js | 9 | ||||
| -rw-r--r-- | tools/padlock-ask-test.js | 14 | ||||
| -rw-r--r-- | tools/padlock-flow-test.js | 25 |
3 files changed, 25 insertions, 23 deletions
diff --git a/tools/lock-wallet-test.js b/tools/lock-wallet-test.js index 03db663..13d2b91 100644 --- a/tools/lock-wallet-test.js +++ b/tools/lock-wallet-test.js @@ -82,17 +82,18 @@ try { await sleep(1000); console.log('\n[the padlock still asks — locking needs a password]'); + // the padlock lives on the Accounts page (the balance card's switcher opens it) + await page.evaluate(() => document.querySelector('.balance-switch')?.click()); + await sleep(600); await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((n) => n.title === 'Lock wallet'); if (b) b.click(); }); await sleep(600); txt = await body(); check('padlock asks even after "Not now"', /protect this device/i.test(txt), txt.slice(0, 120).replace(/\n+/g, ' | ')); await click('button', 'Not now'); await sleep(600); - check('and declining lands home', await waitText('receive')); + check('and declining lands back on the Accounts page', /add account/i.test(await body())); console.log('\n[now with a password]'); - await click('button', 'Wallets'); - await sleep(800); await click('button', 'Change password'); await sleep(800); const fields = await page.$$('input[type=password]'); @@ -138,7 +139,7 @@ try { check('backing out deletes nothing', (await vaultSize()) > 0); console.log('\n[delete all is the destructive one]'); - await click('button', 'Wallets'); + await page.evaluate(() => document.querySelector('.balance-switch')?.click()); await sleep(800); await click('button', 'Delete all'); await sleep(600); diff --git a/tools/padlock-ask-test.js b/tools/padlock-ask-test.js index e2837e5..f1fa3cf 100644 --- a/tools/padlock-ask-test.js +++ b/tools/padlock-ask-test.js @@ -35,27 +35,25 @@ try { await click('button', 'Open wallet'); await waitText('receive', 20000); - // open my own profile (the header avatar) - await page.evaluate(() => document.querySelector('.header-avatar')?.click()); + // open the Accounts page (the balance card's switcher) — the padlock lives there + await page.evaluate(() => document.querySelector('.balance-switch')?.click()); await sleep(900); - const onProfile = await page.evaluate(() => !!document.querySelector('.profile-avatar, .chat-avatar.profile-avatar')); - check('profile page is open', onProfile, (await bodyText()).slice(0, 60).replace(/\n/g, ' | ')); + check('Accounts page is open', /add account/i.test(await bodyText()), (await bodyText()).slice(0, 60).replace(/\n/g, ' | ')); // tap the padlock — the ask must appear without navigating anywhere const tapped = await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((e) => /lock/i.test(e.getAttribute('aria-label') || '')); if (!b) return false; b.click(); return true; }); - check('padlock is reachable from the profile page', tapped); + check('padlock is reachable from the Accounts page', tapped); await sleep(500); const text = await bodyText(); check('the ask appears on the tap', /protect this device/i.test(text), text.split('\n').slice(0, 3).join(' | ')); - // declining lands back on the profile, not somewhere else + // declining lands back on the Accounts page, not somewhere else await click('button', 'not now'); await sleep(600); - const back = await page.evaluate(() => !!document.querySelector('.profile-avatar')); - check('declining lands back on the profile page', back, (await bodyText()).slice(0, 60).replace(/\n/g, ' | ')); + check('declining lands back on the Accounts page', /add account/i.test(await bodyText()), (await bodyText()).slice(0, 60).replace(/\n/g, ' | ')); } finally { await browser.close(); server.stop(true); } diff --git a/tools/padlock-flow-test.js b/tools/padlock-flow-test.js index e36d7ec..e67711f 100644 --- a/tools/padlock-flow-test.js +++ b/tools/padlock-flow-test.js @@ -21,6 +21,8 @@ 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); }; 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; }; @@ -40,7 +42,7 @@ try { await sleep(2000); console.log('\n[the Wallets list before opting into Spending]'); - await click('button', 'Wallets'); + await page.evaluate(() => document.querySelector('.balance-switch')?.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, ' | ')); @@ -50,7 +52,7 @@ try { check('back home', await waitText('receive')); console.log('\n[padlock with no password: declining is free]'); - await clickTitle('Lock wallet'); + await padlock(page, 'Lock wallet'); await sleep(500); txt = await body(); check('it asks for a password in place', (await page.$$('input[type=password]')).length >= 2, txt.slice(0, 120).replace(/\n+/g, ' | ')); @@ -58,8 +60,7 @@ try { await click('button', 'Not now'); await sleep(600); txt = await body(); - check('declining lands back home', /receive/i.test(txt) && /balance/i.test(txt), txt.slice(0, 120).replace(/\n+/g, ' | ')); - check('not on the wallets list', !/add wallet|delete all/i.test(txt)); + check('declining lands back where the padlock was tapped (the Accounts page)', /add account/i.test(txt), txt.slice(0, 120).replace(/\n+/g, ' | ')); console.log('\n[the logo still means home]'); await page.evaluate(() => document.querySelector('.brand')?.click()); @@ -68,7 +69,7 @@ try { check('logo goes home, not to a password prompt', /receive/i.test(txt) && !/unlock saved|enter your password/i.test(txt), txt.slice(0, 120).replace(/\n+/g, ' | ')); console.log('\n[setting a password locks in place]'); - await clickTitle('Lock wallet'); + await padlock(page, 'Lock wallet'); await sleep(500); const fields = await page.$$('input[type=password]'); check('password form is up', fields.length >= 2, `${fields.length} field(s)`); @@ -78,11 +79,13 @@ 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); 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); console.log('\n[and the padlock now asks for the password]'); - await clickTitle('Unlock'); + await padlock(page, 'Unlock'); await sleep(600); txt = await body(); check('unlock needs the password', /password/i.test(txt), txt.slice(0, 120).replace(/\n+/g, ' | ')); @@ -104,7 +107,7 @@ try { return waitText2('receive'); }; const addWallet = async () => { - await click2('Wallets'); await sleep(600); + 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); @@ -126,7 +129,7 @@ try { await sleep(1000); check('wallet B open', await addWallet()); await sleep(2000); - await clickTitle2('Lock wallet'); + await padlock(p2, 'Lock wallet'); await sleep(600); txt = await body2(); check('padlock offers to SET a password (B is saved, vault is passwordless)', @@ -148,7 +151,7 @@ try { await click2('Unlock'); check('password opens it', await waitText2('receive')); await sleep(1000); - await click2('Wallets'); await sleep(600); + 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); @@ -158,7 +161,7 @@ try { await sleep(1000); check('wallet C open', await addWallet()); await sleep(2000); - await clickTitle2('Lock wallet'); + await padlock(p2, 'Lock wallet'); await sleep(600); txt = await body2(); check('it says WHICH password it wants', /already saved on this device/i.test(txt), txt.slice(0, 160).replace(/\n+/g, ' | ')); @@ -179,7 +182,7 @@ try { await click2('Unlock'); check('unlocked once more', await waitText2('receive')); await sleep(1000); - await click2('Wallets'); await sleep(600); + 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)`); await ctx2.close(); } catch (e) { |
