diff options
| author | Adam Soltys <[email protected]> | 2026-08-02 22:15:22 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-02 22:15:22 -0700 |
| commit | 5f72ee4b16355ce93d46cbb5b9cc22b7c2ff0efa (patch) | |
| tree | f92c4723bee1200b1bb6a295c6472b8920792908 /tools | |
| parent | ccd96f8bd99c863a12c8b84199caf0c44c5edbd9 (diff) | |
| download | coinosv3-5f72ee4b16355ce93d46cbb5b9cc22b7c2ff0efa.tar.gz coinosv3-5f72ee4b16355ce93d46cbb5b9cc22b7c2ff0efa.zip | |
Offline keeps the classic wallet layout
Offline mode forces the settings tab, and the full-page settings layout
was hiding the balance card and tab strip there — walling an offline
user off from their cached balance, history, and the Savings receive
address. Offline now keeps balance + tabs around the settings content.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wvj4aoeMZwA7VUGdJP9Swi
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/offline-e2e.tmp.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/offline-e2e.tmp.js b/tools/offline-e2e.tmp.js new file mode 100644 index 0000000..b917385 --- /dev/null +++ b/tools/offline-e2e.tmp.js @@ -0,0 +1,51 @@ +// Offline assessment: app loads, wallet opens, on-chain receive works, +// nothing crashes when every network call fails. +import puppeteer from 'puppeteer-core'; +import { generateMnemonic } from '@scure/bip39'; +import { wordlist } from '@scure/bip39/wordlists/english'; +import { buildHtml } from '../build.js'; +const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); +let ok = true; +const check = (n, c, d='') => { console.log(` ${c ? '✓' : '✗'} ${n}${d?' — '+d:''}`); if (!c) ok = false; }; +const html = await buildHtml({ minify: false, pwa: false }); +const server = Bun.serve({ port: 5199, fetch: () => new Response(html, { headers: { 'content-type': 'text/html' } }) }); +const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] }); + +// ---- scenario A: cold start fully offline (page already cached / file://) +const page = await browser.newPage(); +const errs = []; +page.on('pageerror', (e) => errs.push(e.message)); +await page.setViewport({ width: 480, height: 900 }); +await page.goto('http://localhost:5199', { waitUntil: 'domcontentloaded' }); +await sleep(300); +await page.setOfflineMode(true); +const bodyText = () => page.evaluate(() => document.body.innerText); +const waitText = async (t2, ms = 15000) => { for (let i = 0; i < ms/250; i++) { if ((await bodyText()).includes(t2)) return true; await sleep(250); } return false; }; +try { + console.log('[offline import]'); + await page.evaluate(() => [...document.querySelectorAll('button')].find(b => b.textContent.includes('Import existing'))?.click()); + await sleep(200); + await page.type('textarea', generateMnemonic(wordlist)); + await page.evaluate(() => [...document.querySelectorAll('button')].find(b => b.textContent.includes('Open wallet'))?.click()); + const opened = await waitText('Receive', 25000) || await waitText('Settings', 5000) || await waitText('offline', 5000); + check('wallet opens offline', opened, (await bodyText()).slice(0, 120).replaceAll('\n',' | ')); + await sleep(4000); + const body1 = await bodyText(); + console.log(' state:', body1.slice(0, 200).replaceAll('\n', ' | ')); + // try the receive tab + await page.evaluate(() => [...document.querySelectorAll('.tabs button')].find(b => b.textContent === 'Receive')?.click()); + await sleep(1500); + const body2 = await bodyText(); + check('on-chain address renders offline', /bc1[a-z0-9]{20,}/.test(body2)); + check('balance card present', await page.evaluate(() => !!document.querySelector('.balance'))); + // settings + advanced (offline transfer) + await page.evaluate(() => [...document.querySelectorAll('.tabs button')].find(b => b.textContent === 'Settings')?.click()); + await sleep(500); + await page.evaluate(() => [...document.querySelectorAll('.settings-nav')].find(b => b.textContent.trim() === 'Advanced')?.click()); + await sleep(500); + check('offline transfer reachable', (await bodyText()).includes('Offline transfer')); + const fatal = errs.filter((e) => !/net::|WebSocket|Failed to fetch|NetworkError|ERR_INTERNET/i.test(e)); + check('no fatal page errors', !fatal.length, fatal.slice(0, 3).join(' | ')); + console.log(' (network-shaped errors swallowed:', errs.length, ')'); +} finally { await browser.close(); server.stop(); } +process.exit(ok ? 0 : 1); |
