From 2772773d6d1b214eaf435f56e439ef8ec56b9bed Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 22 Nov 2026 09:57:40 -0700 Subject: v3.coinos.io/hats opens the hat shop. "Someone in the coinos group is asking where to get hats. Can we make the hat shop have a linkable url like v3.coinos.io/hats that I can direct him to?" (Adam, 2026-11-22). The shop was a screen with no address, reached from the profile editor or the About page. The /hats path now opens it once a wallet is up; someone who arrives with no wallet gets the way in first and the shop when the wallet is made. The address bar says /hats for as long as the shop is on screen, so the link can be copied from there, and goes back to / when the shop is left. New hats-link-test passes (no wallet, with a wallet, the bar, leaving); features-smoke passes. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg --- tools/hats-link-test.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tools/hats-link-test.js (limited to 'tools') diff --git a/tools/hats-link-test.js b/tools/hats-link-test.js new file mode 100644 index 0000000..411dbd3 --- /dev/null +++ b/tools/hats-link-test.js @@ -0,0 +1,46 @@ +// v3.coinos.io/hats opens the hat shop. "Someone in the coinos group is +// asking where to get hats. Can we make the hat shop have a linkable url +// like v3.coinos.io/hats that I can direct him to?" (Adam, 2026-11-22). +// With a wallet the link lands in the shop; the bar says /hats while the +// shop is on screen and / again once it is left; someone with no wallet +// gets the shop after making one. +// Run: bun tools/hats-link-test.js +import puppeteer, { seedWords, skipSeedCheck } from './puppeteer.js'; +import { buildHtml } from '../build.js'; +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: 5348, fetch: (req) => { const p = new URL(req.url).pathname; if (p === '/verify-worker.js' || p.startsWith('/punks')) return new Response(Bun.file('dist' + p)); if (p.startsWith('/hats/')) return Response.json({ owned: [], equipped: null }); return 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 errs = []; +page.on('pageerror', (e) => errs.push(String(e))); +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 waitText = async (x, ms = 25000) => { for (let i = 0; i < ms / 250; i++) { if ((await text()).toLowerCase().includes(x.toLowerCase())) return true; await sleep(250); } return false; }; +const path = () => page.evaluate(() => location.pathname); +try { + await page.setViewport({ width: 390, height: 844 }); + await page.goto('http://localhost:5348/', { waitUntil: 'domcontentloaded' }); + await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest')); + // no wallet yet: the link, then a new wallet, then the shop + await page.goto('http://localhost:5348/hats', { waitUntil: 'domcontentloaded' }); await waitText('create a new wallet', 20000); await sleep(400); + check('with no wallet the link shows the way in, not the shop', !(await text()).includes('Hat shop')); + await click('create a new wallet'); await sleep(600); + await seedWords(page); + await skipSeedCheck(page); + check('...and the shop opens once the wallet is made', await waitText('Hat shop', 25000)); + // with a wallet: straight in + await page.goto('http://localhost:5348/hats', { waitUntil: 'domcontentloaded' }); + check('with a wallet /hats opens the hat shop', await waitText('Hat shop', 25000)); + await sleep(600); + check('the bar says /hats', (await path()) === '/hats', await path()); + await page.evaluate(() => [...document.querySelectorAll('button')].find((n) => /\bback\b/i.test(n.textContent))?.click()); await sleep(900); + const t = await text(); + check('Back leaves the shop', !t.includes('Hat shop')); + check('...and the bar is / again', (await path()) === '/', await path()); + check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | ')); +} finally { await browser.close(); server.stop(true); } +console.log(ok ? '\n✅ /hats opens the hat shop' : '\n❌ failed'); +process.exit(ok ? 0 : 1); -- cgit v1.2.3