diff options
| author | Adam Soltys <[email protected]> | 2026-11-17 13:14:04 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-17 13:14:04 -0700 |
| commit | a91155b1904384a8b2f151a9c50df06ad068a397 (patch) | |
| tree | 40973820f2abe60a270dd62ec472c8a87b1855e9 /tools/link-preview-test.js | |
| parent | 7b2c4626ae67f9d337d285bdd9170f511a9c14aa (diff) | |
| download | coinosv3-a91155b1904384a8b2f151a9c50df06ad068a397.tar.gz coinosv3-a91155b1904384a8b2f151a9c50df06ad068a397.zip | |
A draft's Preview shows a link as its card. "i added metadata to paff pages, was hoping links to movies would render with a nicely formatted thumbnail" (Adam, 2026-11-17). The registrar already reads paff.club's movie pages (title "Hackers (1995) · from 1:21:50", description, backdrop), and a posted note warms its links' cards before it shows; the composer's Preview ran the same renderer but never asked for the page, so a link not already cached stayed a bare URL. It now asks once the typing settles (half a second), then repaints into the card. link-preview-test (a draft's preview shows the movie card, asked once) and compose-preview-test pass.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6SwkivduFDDkMmnXjZ
Diffstat (limited to 'tools/link-preview-test.js')
| -rw-r--r-- | tools/link-preview-test.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/link-preview-test.js b/tools/link-preview-test.js index 190b220..bf68bbc 100644 --- a/tools/link-preview-test.js +++ b/tools/link-preview-test.js @@ -30,7 +30,9 @@ const server = Bun.serve({ port: 5311, fetch: (req) => { const target = u.searchParams.get('url'); previewHits.push(target); const meta = target === 'https://news.example/story/1' ? { url: target, title: 'Lawmakers doubt the plan', description: 'A story in one line.', image: 'http://localhost:5311/card.png', site: 'News Example' } - : {}; + : target === 'https://movies.example/movie/1382/play?t=4910' + ? { url: target, title: 'Hackers (1995) · from 1:21:50', description: 'Teenage hackers.', image: 'http://localhost:5311/movie.png', site: 'PAFF' } + : {}; return new Response(JSON.stringify(meta), { headers: { 'content-type': 'application/json', 'access-control-allow-origin': '*' } }); } if (u.pathname.endsWith('.png')) return new Response(PNG, { headers: { 'content-type': 'image/png' } }); @@ -117,6 +119,17 @@ try { let kept = 0; // written behind, a second after the card was learned for (let i = 0; i < 12 && !kept; i++) { kept = await page.evaluate(() => JSON.parse((window.coinosCache || localStorage).getItem('coinos-link-previews') || '[]').length); if (!kept) await sleep(300); } check('the card is remembered for next time', kept === 1, kept + ' kept'); + // a draft's preview shows the card too (Adam, 2026-11-17: a paff.club + // movie link stayed a bare URL in Preview), once the typing settles + const opened = await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((n) => (n.getAttribute('aria-label') || n.textContent).trim().toLowerCase() === 'new post'); if (b) { b.click(); return true; } return false; }); + await sleep(400); + const typeDraft = (v) => page.evaluate((val) => { const e = document.querySelector('coinos-text'); e.focus(); e.value = val; e.dispatchEvent(new Event('input', { bubbles: true })); }, v); + await typeDraft('watch this\n\nhttps://movies.example/movie/1382/play?t=4910'); + await page.evaluate(() => [...document.querySelectorAll('button')].find((b) => /preview/i.test(b.getAttribute('aria-label') || ''))?.click()); + let draft = null; + for (let i = 0; i < 20; i++) { draft = await page.evaluate(() => { const p = document.querySelector('.draft-preview'); return p && { card: !!p.querySelector('.link-card'), title: p.querySelector('.link-title')?.textContent }; }); if (draft?.card) break; await sleep(250); } + check('a draft\'s preview shows the link as its card', opened && draft?.card && /Hackers/.test(draft.title || ''), JSON.stringify(draft)); + check('...asked for once the typing settled, not per keystroke', previewHits.filter((u) => u.startsWith('https://movies.example')).length === 1, JSON.stringify(previewHits)); check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | ')); } finally { await browser.close(); server.stop(true); } console.log(ok ? '\n✅ links show as the cards their pages describe' : '\n❌ failed'); |
