{"fx":{"AED":3.6732,"AFN":76.916238,"ALL":102.317329,"AMD":481.616267,"ANG":1.794577,"AOA":655.221553,"ARS":81.969207,"AUD":1.343089,"AWG":1.8,"AZN":1.7025,"BAM":1.614261,"BBD":2,"BDT":84.775754,"BGN":1.617356,"BHD":0.377015,"BIF":1940.93179,"BMD":1,"BND":1.335611,"BOB":6.883324,"BRL":5.1698,"BSD":1,"BTC":0.000054,"BTN":73.603314,"BWP":10.890769,"BYN":2.553493,"BZD":2.015195,"CAD":1.28192,"CDF":1968.605194,"CHF":0.889253,"CLF":0.026934,"CLP":743.201103,"CNH":6.52695,"CNY":6.5432,"COP":3498.827763,"CRC":601.611868,"CUC":0.999757,"CUP":25.750002,"CVE":91.517508,"CZK":21.767701,"DJF":177.984204,"DKK":6.160477,"DOP":58.1879,"DZD":131.135347,"EGP":15.688401,"ERN":14.999681,"ETB":38.380578,"EUR":0.827603,"FJD":2.0594,"FKP":0.747215,"GBP":0.747215,"GEL":3.295,"GGP":0.747215,"GHS":5.865177,"GIP":0.747215,"GMD":51.775005,"GNF":9900.000797,"GTQ":7.803103,"GYD":209.079747,"HKD":7.75215,"HNL":24.277427,"HRK":6.247201,"HTG":67.978168,"HUF":295.195892,"IDR":14112.940636,"ILS":3.24973,"IMP":0.747215,"INR":73.753254,"IQD":1192.518145,"IRR":42105.00339,"ISK":127.030011,"JEP":0.747215,"JMD":143.995324,"JOD":0.709,"JPY":104.271008,"KES":111.400009,"KGS":84.795464,"KHR":4054.500326,"KMF":408.250238,"KPW":900.000073,"KRW":1085.489331,"KWD":0.304948,"KYD":0.833116,"KZT":420.239329,"LAK":9290.000748,"LBP":1519.000122,"LKR":185.75786,"LRD":160.450008,"LSL":14.960001,"LYD":1.35,"MAD":8.998358,"MDL":17.334117,"MGA":3867.375108,"MKD":51.003691,"MMK":1331.69855,"MNT":2855.764265,"MOP":7.98247,"MRO":357.000029,"MRU":37.121155,"MUR":39.903163,"MVR":15.455002,"MWK":765.388159,"MXN":19.864809,"MYR":4.0675,"MZN":74.150003,"NAD":14.960001,"NGN":381.321569,"NIO":34.83301,"NOK":8.836006,"NPR":117.76525,"NZD":1.423995,"OMR":0.385003,"PAB":1,"PEN":3.598707,"PGK":3.518051,"PHP":48.147447,"PKR":160.450013,"PLN":3.665672,"PYG":7034.254563,"QAR":3.64075,"RON":4.0275,"RSD":97.340008,"RUB":73.672606,"RWF":985.000079,"SAR":3.751408,"SBD":8.018641,"SCR":21.205532,"SDG":55.325005,"SEK":8.489209,"SGD":1.336996,"SHP":0.747215,"SLL":10194.893602,"SOS":584.000047,"SRD":14.154001,"SSP":130.26001,"STD":20900.545921,"STN":20.500001,"SVC":8.747973,"SYP":512.818375,"SZL":14.960001,"THB":30.045003,"TJS":11.324825,"TMT":3.51,"TND":2.7105,"TOP":2.288166,"TRY":7.823654,"TTD":6.793277,"TWD":28.256202,"TZS":2318.448187,"UAH":28.0933,"UGX":3680.09987,"USD":1,"UYU":42.677098,"UZS":10440.165624,"VEF":248487.662247,"VES":930536.054919,"VND":23187.74545,"VUV":111.531348,"WST":2.5692,"XAF":542.871898,"XAG":0.041832,"XAU":0.000545,"XCD":2.70255,"XDR":0.696164,"XOF":542.871898,"XPD":0.000439,"XPF":98.759293,"XPT":0.000995,"YER":250.350086,"ZAR":14.964601,"ZMW":21.038963,"ZWL":322.000026}}15a61016571783d971b1ecb95 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// The unread dot either says someone is waiting or it doesn't — it must not
// flash on the way in. render() rebuilds the whole DOM, so any entrance
// animation on the dot replays on every repaint; an earlier build popped it
// seven times in the first seconds after a refresh, which reads as flashing.
//
// Run: bun tools/unread-dot-test.js
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 html = await buildHtml({ minify: true, pwa: false });
const server = Bun.serve({ port: 5233, fetch: () => new Response(html, { headers: { 'content-type': 'text/html' } }) });
const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] });
const page = await browser.newPage();
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 waitText = async (x, ms = 25000) => { for (let i = 0; i < ms / 250; i++) { if ((await page.evaluate(() => document.body.innerText)).toLowerCase().includes(x.toLowerCase())) return true; await sleep(250); } return false; };

try {
  await page.goto('http://localhost:5233/', { waitUntil: 'domcontentloaded' });
  await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest'));
  await page.reload({ waitUntil: 'domcontentloaded' });
  await sleep(400);
  await click('button', 'I already have a 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 sleep(10000); // let the coinos room load so there IS unread

  // Now the refresh the report is about.
  await page.evaluate(() => {
    window.__dot = { anims: 0, appear: 0, disappear: 0, renders: 0 };
    addEventListener('animationstart', (e) => { if (e.target && e.target.classList && e.target.classList.contains('header-msgs')) window.__dot.anims++; }, true);
    let had = null;
    new MutationObserver(() => {
      window.__dot.renders++;
      const now = !!document.querySelector('.header-msgs.unread');
      if (had !== null && now !== had) { if (now) window.__dot.appear++; else window.__dot.disappear++; }
      had = now;
    }).observe(document.getElementById('app'), { childList: true, subtree: true });
  });
  await page.reload({ waitUntil: 'domcontentloaded' });
  // re-arm after the reload wipes it
  await page.evaluate(() => {
    window.__dot = { anims: 0, appear: 0, disappear: 0, renders: 0 };
    addEventListener('animationstart', (e) => { if (e.target && e.target.classList && e.target.classList.contains('header-msgs')) window.__dot.anims++; }, true);
    let had = null;
    new MutationObserver(() => {
      window.__dot.renders++;
      const now = !!document.querySelector('.header-msgs.unread');
      if (had !== null && now !== had) { if (now) window.__dot.appear++; else window.__dot.disappear++; }
      had = now;
    }).observe(document.body, { childList: true, subtree: true });
  });
  await sleep(12000);
  const r = await page.evaluate(() => ({ ...window.__dot, dotNow: !!document.querySelector('.header-msgs.unread') }));
  console.log('over 12s after a refresh:');
  const check = (n, c, d = '') => { console.log(` ${c ? '✓' : '✗'} ${n}${d ? ' — ' + d : ''}`); if (!c) ok = false; };
  check('the dot never animates', r.anims === 0, `${r.anims} animation(s) started`);
  check('it settles once and stays', r.appear <= 1 && r.disappear === 0, `+${r.appear} / -${r.disappear}`);
  check('and the repaints it sat through were real', r.renders > 1, `${r.renders} DOM mutations`);
  check('it is showing (there is unread history)', r.dotNow);
} catch (e) {
  console.log(' ✗ run completed —', e.message);
  ok = false;
} finally {
  await browser.close();
  server.stop(true);
}
console.log(ok ? '\n✅ the dot holds still' : '\n❌ failures above');
process.exit(ok ? 0 : 1);