diff options
| author | Adam Soltys <[email protected]> | 2026-10-07 08:12:38 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-07 08:12:38 -0700 |
| commit | faad243486666eb4cbefcd7ff813329e707106dd (patch) | |
| tree | ce25612f6ed8fdd9355b08d7e07efb5c6b429c7f /tools/feed-editor-relays-test.js | |
| parent | 78cf670939133fc4f656f0f42b21a59431a53842 (diff) | |
| download | coinosv3-faad243486666eb4cbefcd7ff813329e707106dd.tar.gz coinosv3-faad243486666eb4cbefcd7ff813329e707106dd.zip | |
Feed tests: catch up with Articles, Popular as the default feed, timed feed defs and the tint that fades on sight
- feed-media-views: the mode switch has an Articles button now
- feed-media-cache: the live watch's since-only subscription isn't part of the crawl
- feed-switch-seed: seeded feeds carry their edit time (the feeds sync merge drops one without)
- feed-editor-relays: nos.lol is a local stand-in relay, so the test doesn't depend on reaching it
- feed-streaming: the stub wallet opens on Following (no remembered feed = Popular); the held picture
answers repeat fetches once released; the new-post tint is recorded as it paints (it fades on sight)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'tools/feed-editor-relays-test.js')
| -rw-r--r-- | tools/feed-editor-relays-test.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/feed-editor-relays-test.js b/tools/feed-editor-relays-test.js index 7e3edb5..5a808a7 100644 --- a/tools/feed-editor-relays-test.js +++ b/tools/feed-editor-relays-test.js @@ -10,16 +10,21 @@ 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: true, pwa: false }); -const server = Bun.serve({ port: 0, fetch: () => new Response(html, { headers: { 'content-type': 'text/html' } }) }); +// nos.lol itself is a stand-in served here (an empty relay: EOSE to every +// REQ), so the test doesn't hang on whether the real one answers today +const server = Bun.serve({ port: 0, + fetch: (req, srv) => (new URL(req.url).pathname === '/relay' && srv.upgrade(req) ? undefined : new Response(html, { headers: { 'content-type': 'text/html' } })), + websocket: { message: (ws, data) => { try { const m = JSON.parse(data); if (m[0] === 'REQ') ws.send(JSON.stringify(['EOSE', m[1]])); } catch {} } } }); +const RELAY = 'ws://localhost:' + server.port + '/relay'; const browser = await puppeteer.launch({ executablePath: process.env.CHROME || '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] }); const page = await browser.newPage(); const errs = []; page.on('pageerror', (e) => errs.push(String(e))); // record what the page asks which relay, without letting it publish anything -await page.evaluateOnNewDocument(() => { +await page.evaluateOnNewDocument((stand) => { window.__reqs = []; const Real = window.WebSocket; window.WebSocket = function (url, ...a) { - const ws = new Real(url, ...a); + const ws = new Real(/^wss:\/\/nos\.lol\/?$/.test(String(url)) ? stand : url, ...a); const send = ws.send.bind(ws); ws.send = (data) => { try { const m = JSON.parse(data); if (m[0] === 'REQ') window.__reqs.push({ url: String(url), filters: m.slice(2) }); if (m[0] === 'EVENT') return; } catch {} @@ -28,7 +33,7 @@ await page.evaluateOnNewDocument(() => { return ws; }; window.WebSocket.prototype = Real.prototype; Object.assign(window.WebSocket, Real); -}); +}, RELAY); const click = (t) => page.evaluate((x) => { const e = [...document.querySelectorAll('button')].find((n) => n.textContent.trim().toLowerCase().includes(x)); if (e) { e.click(); return true; } return false; }, t); const text = () => page.evaluate(() => document.body.innerText); const waitFor = async (fn, ms = 15000) => { for (let i = 0; i < ms / 200; i++) { if (await page.evaluate(fn)) return true; await sleep(200); } return false; }; |
