aboutsummaryrefslogtreecommitdiffstats
path: root/prod.yml
blob: 30921e6672f8102f5d5d6e7c3585191f90f0f926 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
generated by cgit v1.2.3 (git 2.51.0) at 2026-10-23 17:42:42 +0000
 


'.chat-name') || {}).textContent === 'coinos'); if (e) e.click(); });
const snap = () => page.evaluate(() => ({
  text: document.body.innerText.replace(/\s+/g, ' ').slice(0, 300),
  bubbles: document.querySelectorAll('.chat-bubble').length,
  rows: document.querySelectorAll('.chat-thread-row').length,
  avaImg: document.querySelectorAll('.ava-img').length,
  avaImgData: [...document.querySelectorAll('.ava-img')].filter((e) => /url\("?data:/.test(e.style.backgroundImage)).length,
  fallback: document.querySelectorAll('.chat-avatar.fallback').length,
  header: !!document.querySelector('.header-ava'),
  headerIsImg: !!document.querySelector('.header-ava.ava-img'),
  offlineBanner: document.body.innerText.includes('offline') || document.body.innerText.includes('Offline'),
}));
await page.setViewport({ width: 420, height: 860 });
await page.goto('http://localhost:5234/', { waitUntil: 'domcontentloaded' });
await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest'));
await page.reload({ waitUntil: 'domcontentloaded' }); await sleep(400);
await click('button', 'Create a new wallet'); await sleep(300);
await click('button', 'Have an existing seed'); await sleep(300);
await page.waitForSelector('textarea'); await page.type('textarea', generateMnemonic(wordlist));
await click('button', 'Open wallet'); await waitText('receive', 15000);
await openMessages(); await sleep(800); await openCoinos();
console.log('online room:', await waitText('GM Coinos community', 30000));
await sleep(6000); // thumbnails, profiles, caches settle
console.log('online snapshot:', JSON.stringify(await snap()));
const sw = await page.evaluate(async () => { const r = await navigator.serviceWorker.getRegistration(); const ks = await caches.keys(); const c = ks.length ? await (await caches.open(ks[0])).keys() : []; return { reg: !!r, active: !!(r && r.active), caches: ks, cached: c.length }; });
console.log('sw:', JSON.stringify(sw));
const cdp = await page.target().createCDPSession(); await cdp.send('Network.enable');
await cdp.send('Network.emulateNetworkConditions', { offline: true, latency: 0, downloadThroughput: -1, uploadThroughput: -1 });
await sleep(500);
try { await page.reload({ waitUntil: 'domcontentloaded', timeout: 20000 }); } catch (e) { console.log('reload:', e.message.slice(0, 100)); }
await sleep(5000);
console.log('offline boot:', JSON.stringify(await snap()));
await openMessages(); await sleep(1500);
console.log('offline messages home:', JSON.stringify(await snap()));
await openCoinos(); await sleep(1500);
const room = await snap();
console.log('offline room:', JSON.stringify(room).slice(0, 300));
let ok = true;
const check = (n, c, d = '') => { console.log(` ${c ? '✓' : '✗'} ${n}${d ? ' — ' + d : ''}`); if (!c) ok = false; };
check('the room shows cached messages offline', room.bubbles >= 20, `${room.bubbles} bubbles`);
check('most faces paint from local thumbnails', room.avaImgData >= room.avaImg * 0.6, `${room.avaImgData} of ${room.avaImg}`);
check('names resolve from the profile cache', !/npub1[a-z0-9]{8}/.test(room.text.slice(0, 120)) || room.text.includes('Adam'), room.text.slice(40, 120));
await page.screenshot({ path: process.argv[2] || '/tmp/offline.png' });
await browser.close(); server.stop(true);
console.log(ok ? '\nALL GOOD' : '\nFAILURES');
process.exit(ok ? 0 : 1);