diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/pos-test.js | 20 | ||||
| -rw-r--r-- | tools/signup-quick-test.js | 9 |
2 files changed, 28 insertions, 1 deletions
diff --git a/tools/pos-test.js b/tools/pos-test.js index 55349cb..2b6a0b7 100644 --- a/tools/pos-test.js +++ b/tools/pos-test.js @@ -30,7 +30,7 @@ const ctx = { }; const feature = posFeature(ctx); window.__feature = feature; function render() { document.querySelector('#app').replaceChildren(feature.screenView() || h('div', { id: 'closed' }, 'closed')); } -window.test = { open: () => { feature.openPos(); }, init: () => { feature.init(); render(); }, +window.test = { open: () => { feature.openPos(); }, request: () => { feature.openAmountRequest(); }, init: () => { feature.init(); render(); }, cards: () => { document.querySelector('#app').replaceChildren(...feature.posSettingsCards()); }, settle: (ok) => { const w = watch; watch = null; w.cb({ step: ok ? 'done' : 'failed' }); }, get watch() { return watch && watch.id; }, get cancelled() { return cancelled; }, get sales() { return (state.pos || {}).sales || []; }, ui }; render(); `; @@ -128,6 +128,24 @@ try { check("the old device-wide flag is dropped on start (it can't say whose it was)", await page.evaluate(() => (test.ui.pos = null, true)) && (await boot('owner')) && await page.evaluate(() => localStorage.getItem('btc-wallet-pos-mode') === null)); check('another wallet on the same device does not start in point of sale', !(await boot('someone-else'))); check('the owner still does, after anyone else has been in', await boot('owner')); + + console.log('\n[Receive ā Amount]'); + await page.evaluate(() => { localStorage.removeItem('btc-wallet-pos-mode:owner'); test.ui.pos = null; test.request(); }); await pause(50); + let rq = await text(); + check('opens as Request an amount, without the till around it', /Request an amount/.test(rq) && !/ask for a tip|Tips today|Sales today/i.test(rq) && !(await page.$('.pos-sale')), rq.slice(0, 200)); + const before = await page.evaluate(() => test.sales.length); + await type('.pos-amount', '2100'); + await page.click('#pos-charge'); await pause(100); + rq = await text(); + check('straight to the invoice, no tip prompt', /Scan to pay/i.test(rq) && /2,100/.test(rq) && !!(await page.$('.pos-qr')), rq.slice(0, 200)); + const req = await page.evaluate(() => test.sales[test.sales.length - 1]); + check('the request is for the amount, no tip, and marked', req.billSat === 2100 && req.tipSat === 0 && req.request === true, JSON.stringify(req)); + await page.evaluate(() => test.settle(true)); await pause(100); + check('paid, with Done back to Receive', /Done/.test(await text()) && !/New sale/.test(await text())); + await click('Done'); await pause(50); + check('Done closes it', !!(await page.$('#closed'))); + await page.evaluate(() => { test.ui.pos = null; test.open(); }); await pause(50); + check("the till's sales list leaves requests out", !(await text()).includes('2,100'), String(before)); check('no browser errors', errors.length === 0); } finally { await browser.close(); server.stop(true); } console.log('\nā
point of sale'); diff --git a/tools/signup-quick-test.js b/tools/signup-quick-test.js index d648a70..d184457 100644 --- a/tools/signup-quick-test.js +++ b/tools/signup-quick-test.js @@ -83,6 +83,15 @@ try { let s = await shape(); check('in, on Spending alone (no Savings face, no name on it)', s.faces === 1 && !s.carousel && !s.label, JSON.stringify({ faces: s.faces, carousel: s.carousel, label: s.label })); check('a quiet line asks for a way back in', /add a way back into your account/i.test(s.body)); + for (let i = 0; i < 60 && !(await page.$('#recv-amount')); i++) await sleep(250); + check('Receive has an Amount button', !!(await page.$('#recv-amount'))); + check('no History heading on an empty wallet', !/\bHISTORY\b/.test(await page.evaluate(() => document.body.innerText))); + if (process.env.SHOT3) await page.screenshot({ path: process.env.SHOT3 }); + await page.click('#recv-amount'); await sleep(500); + check('Amount opens the amount pad', !!(await page.$('.pos-amount')) && /request an amount/i.test(await text())); + if (process.env.SHOT4) await page.screenshot({ path: process.env.SHOT4 }); + await click('back'); await sleep(500); + check('Back returns to Receive', !(await page.$('.pos-amount')) && !!(await page.$('#recv-amount'))); const acct = await page.evaluate(() => JSON.parse(sessionStorage.getItem('btc-wallet-accounts') || '{}')); const a0 = (acct.accounts || [])[0] || {}; check('the account: spending-only, phrase unseen, saved to the device', a0.kind === 'spending' && a0.savingsLater && a0.seedSeen === false && a0.persisted, JSON.stringify({ kind: a0.kind, later: a0.savingsLater, seen: a0.seedSeen, persisted: a0.persisted })); |
