From 86d9818abfc160dac031bb292abe28d6f28fc624 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 7 Oct 2026 12:02:51 -0700 Subject: Browser tests: public relays answered in the page, never reached A suite run let ~90 throwaway test wallets subscribe and publish on public relays from one home address, and nos.lol and relay.damus.io banned it. tools/puppeteer.js wraps puppeteer-core: every socket to a non-local host gets an in-page stand-in relay (EVENT -> OK, REQ -> EOSE). Tests that read real content launch with { relays: 'read' } (real reads, publishes answered in place); feed-live, chat-layout and cordn-ui launch with { relays: 'live' }. LIVE_RELAYS=read|1|host,... overrides per run. profile-key-qr: measure the QR again if a repaint swapped it out. Co-Authored-By: Claude Opus 5.5 --- tools/profile-key-qr-test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools/profile-key-qr-test.js') diff --git a/tools/profile-key-qr-test.js b/tools/profile-key-qr-test.js index fb3c846..f67fc3d 100644 --- a/tools/profile-key-qr-test.js +++ b/tools/profile-key-qr-test.js @@ -2,7 +2,7 @@ // really says the npub printed under it. // // Run: bun tools/profile-key-qr-test.js -import puppeteer from 'puppeteer-core'; +import puppeteer from './puppeteer.js'; import jsQR from 'jsqr'; import { generateMnemonic } from '@scure/bip39'; import { wordlist } from '@scure/bip39/wordlists/english'; @@ -43,7 +43,9 @@ try { await page.waitForSelector('.npub-qr svg', { timeout: 5000 }); const npub = await page.evaluate(() => document.querySelector('.npub-box').textContent.trim()); check('the key is shown', /^npub1[a-z0-9]{58}$/.test(npub), npub); - const box = await (await page.$('.npub-qr')).boundingBox(); + // a repaint can swap the box out between finding and measuring it + let box = null; + for (let i = 0; i < 20 && !box; i++) { box = await (await page.$('.npub-qr'))?.boundingBox().catch(() => null); if (!box) await sleep(100); } check('the QR fits a phone screen', box.width <= 420 && box.x >= 0, JSON.stringify(box)); // read it back the way a camera would: from pixels const shot = join(tmpdir(), 'profile-key-qr.png'); -- cgit v1.2.3