diff options
Diffstat (limited to 'tools/gift-profile-setup-test.js')
| -rw-r--r-- | tools/gift-profile-setup-test.js | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/tools/gift-profile-setup-test.js b/tools/gift-profile-setup-test.js index 9304d1a..04e58c5 100644 --- a/tools/gift-profile-setup-test.js +++ b/tools/gift-profile-setup-test.js @@ -53,7 +53,11 @@ try { page.on('pageerror', (e) => errors.push(String(e))); await page.setViewport({ width: 390, height: 844, deviceScaleFactor: 2 }); await toSeed(page, 'Happy birthday! š <b>not bold</b>'); - await click(page, 'skip verification'); + check('a heads-up comes before the words', /no one is looking/i.test(await text(page)) && await page.evaluate(() => !document.querySelector('.words'))); + await click(page, 'show seed phrase'); + check('...then the words, with Next', await page.evaluate(() => document.querySelectorAll('.words .w').length === 12) && await click(page, 'next')); + check('...then one word to pick, or Skip', await waitText(page, /which one is word #5/i, 5000) && await page.evaluate(() => document.querySelectorAll('.quiz-opt').length === 4)); + await click(page, 'skip'); check('the seed done: the wizard asks for a username', await waitText(page, /now pick a username/i, 10000), (await text(page)).slice(0, 200)); check('...with the claim form (or its wait) and Not now', await page.evaluate(() => !!document.querySelector('.onb')) && /not now/i.test(await text(page))); if (process.argv[2]) await page.screenshot({ path: process.argv[2] }); @@ -66,30 +70,25 @@ try { p2.on('pageerror', (e) => errors.push(String(e))); await p2.setViewport({ width: 390, height: 844, deviceScaleFactor: 2 }); await toSeed(p2); - check('Verify backup opens the word check', await click(p2, 'verify') && await waitText(p2, /word #?\d/i, 5000)); - await sleep(500); - // the verify page doesn't show the words: read them from the account - const filled = await p2.evaluate(() => { - const accs = JSON.parse(sessionStorage.getItem('btc-wallet-accounts') || '{}'); - const list = Array.isArray(accs) ? accs : accs.accounts || accs.list || []; - const m = list.map((a) => a.mnemonic).filter(Boolean).pop(); if (!m) return false; - const w = m.split(' '); - for (const lab of document.querySelectorAll('label.field')) { - const n = Number(lab.querySelector('.lab').textContent.match(/\d+/)[0]); - const inp = lab.querySelector('input'); - const set = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set; - set.call(inp, w[n - 1]); inp.dispatchEvent(new Event('input', { bubbles: true })); - } - return true; - }); + await click(p2, 'show seed phrase'); + const fifth = await p2.evaluate(() => document.querySelectorAll('.words .w .t')[4]?.textContent.trim()); + check('Next opens the word check', await click(p2, 'next') && await waitText(p2, /which one is word #5/i, 5000)); + // a wrong pick says so and stays + const wrongOk = await p2.evaluate((right) => { + const b = [...document.querySelectorAll('.quiz-opt')].find((x) => x.textContent.trim() !== right); b?.click(); return !!b; + }, fifth); + await sleep(300); + check('...a wrong word is marked, and the check stays', wrongOk && await p2.evaluate(() => !!document.querySelector('.quiz-opt.wrong')) && /not that one/i.test(await text(p2))); + const filled = await p2.evaluate((right) => { + const b = [...document.querySelectorAll('.quiz-opt')].find((x) => x.textContent.trim() === right); b?.click(); return !!b; + }, fifth); if (filled) { - await click(p2, 'open wallet'); check('a verified seed leads to the username step too', await waitText(p2, /now pick a username/i, 10000)); await click(p2, 'not now'); let gone = false; for (let i = 0; i < 20 && !gone; i++) { await sleep(250); gone = !(await p2.evaluate(() => !!document.querySelector('.onb'))); } check('Not now: into the wallet, the wizard gone', gone, (await text(p2)).slice(0, 200)); - } else console.log(' (accounts not in localStorage ā verify path not driven)'); + } else check('the right word is among the choices', false); check('no page errors', errors.length === 0, errors.join(' | ')); } finally { await browser.close(); server.stop(true); } console.log(ok ? '\nā
a gift\'s new wallet is offered a name, a picture and a cover' : '\nā failed'); |
