Files
threshing-atlas/scripts/qa/crawl.js
T
ekcSchianoandClaude Opus 5.5 7366af2f7d Release pass: wording, colour-blind-safe colours, map visibility, phone layout
Walked every tab on desktop and phone, clicked every link and button:
- Colours: new map inks and page colours, checked with simulated
  protanopia/deuteranopia/tritanopia (worst pair ~12 CIEDE2000, was 1.4 for
  Red/Green on the map and 9.7 for Orange/Brown on the page). Map label text
  is always dark ink; dragon colour goes on borders. docs/COLOURS.md and
  research/python/check_colours.py.
- Valley map: dragons get a paper halo and a visibility floor (faded ones never
  drop below 0.3; bonding dragons start at 0.5); "no shadow" roll labelled
  correctly.
- Wording: methods updated (strata, the newer form's questions, missing
  answers, a new section on the solver, The Odds cards and genuine attempts);
  findings use readable factor names and no longer claim a date adjustment;
  'Load a newer route export above'; code links include solver.js and
  explorer.js; The Odds shows 93% instead of '1 in 1'.
- Deep Dive route map treats all six dragons alike ('Bond a dragon' row,
  default 'Bond any dragon'; rare sightings separate).
- Phone: Deep Dive no longer overflows (sections and selects can shrink).
- scripts/qa/crawl.js and mapcheck.js for future release checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 17:57:51 +00:00

71 lines
4.3 KiB
JavaScript

// QA crawl: every tab, text dump, links, buttons, console errors. node crawl.js <outdir>
const { chromium } = require("playwright");
const fs = require("fs");
const OUT = process.argv[2];
const BASE = "http://localhost:8765/";
(async () => {
const b = await chromium.launch();
const log = { errors: [], links: [], buttons: [], tabs: {} };
for (const [vpName, vp] of [["desktop", { width: 1440, height: 1000 }], ["phone", { width: 390, height: 844 }]]) {
const p = await b.newPage({ viewport: vp });
p.on("pageerror", (e) => log.errors.push(`${vpName} pageerror: ${e.message}`));
p.on("console", (m) => { if (m.type() === "error" && !/net::ERR|Failed to load resource/.test(m.text())) log.errors.push(`${vpName} console: ${m.text()}`); });
for (const t of ["valley", "odds", "dragons", "deep", "data"]) {
await p.goto(BASE + "#" + t); await p.waitForTimeout(t === "valley" ? 2500 : 1800);
// open every <details> so hidden text is reviewed too
await p.$$eval(`#panel-${t} details`, (ds) => ds.forEach((d) => (d.open = true)));
await p.waitForTimeout(300);
await p.screenshot({ path: `${OUT}/${vpName}-${t}.png`, fullPage: true });
if (vpName === "desktop") {
log.tabs[t] = await p.evaluate((t) => document.querySelector("#panel-" + t).innerText, t);
const links = await p.$$eval(`#panel-${t} a[href], header a[href], footer a[href]`, (as) => as.map((a) => ({ text: a.innerText.trim().slice(0, 60), href: a.getAttribute("href") })));
links.forEach((l) => log.links.push({ tab: t, ...l }));
const btns = await p.$$eval(`#panel-${t} button`, (bs) => bs.map((x) => x.innerText.trim().replace(/\s+/g, " ").slice(0, 50)));
log.buttons.push({ tab: t, n: btns.length, sample: [...new Set(btns)].slice(0, 40) });
}
// overflow check
const sw = await p.evaluate(() => document.documentElement.scrollWidth);
if (sw > vp.width + 1) log.errors.push(`${vpName} ${t}: horizontal overflow ${sw}px`);
}
await p.close();
}
// click every button in every tab (desktop), checking for errors after each
const p = await b.newPage({ viewport: { width: 1440, height: 1000 } });
p.on("pageerror", (e) => log.errors.push(`click pageerror: ${e.message}`));
for (const t of ["valley", "odds", "dragons", "deep", "data"]) {
await p.goto(BASE + "#" + t); await p.waitForTimeout(2000);
const n = await p.$$eval(`#panel-${t} button`, (bs) => bs.length);
let clicked = 0;
for (let i = 0; i < Math.min(n, 120); i++) {
const bs = await p.$$(`#panel-${t} button`);
if (!bs[i]) continue;
const vis = await bs[i].isVisible();
if (!vis) continue;
const label = (await bs[i].innerText()).trim().slice(0, 40);
if (/download|copy/i.test(label)) continue;
try { await bs[i].click({ timeout: 1500 }); clicked++; await p.waitForTimeout(120); } catch (e) { log.errors.push(`${t}: could not click "${label}": ${e.message.split("\n")[0]}`); }
const cur = await p.evaluate(() => location.hash);
if (!cur.startsWith("#" + t)) { await p.goto(BASE + "#" + t); await p.waitForTimeout(1200); }
}
log.tabs[t + "_clicked"] = clicked;
}
// in-page links
await p.goto(BASE); await p.waitForTimeout(2000);
for (const l of log.links.filter((x) => x.href.startsWith("#"))) {
await p.goto(BASE + "#" + l.tab); await p.waitForTimeout(800);
const el = await p.$(`#panel-${l.tab} a[href="${l.href}"]`);
if (!el || !(await el.isVisible())) continue;
await el.click(); await p.waitForTimeout(800);
const sel = await p.evaluate(() => document.querySelector("[role=tab][aria-selected=true]").id);
const target = l.href.slice(1).split("/")[0];
const exists = await p.evaluate((id) => !!document.getElementById(id) || ["valley","odds","dragons","deep","data"].includes(id), target);
l.result = `${sel}${exists ? "" : " MISSING TARGET"}`;
}
fs.writeFileSync(`${OUT}/log.json`, JSON.stringify(log, null, 1));
for (const [t, txt] of Object.entries(log.tabs)) if (typeof txt === "string") fs.writeFileSync(`${OUT}/text-${t}.txt`, txt);
console.log("errors:", log.errors.length, log.errors.slice(0, 20));
console.log("clicked:", Object.entries(log.tabs).filter(([k]) => k.endsWith("_clicked")));
console.log("links:"); log.links.forEach((l) => console.log(" ", l.tab, "|", l.text, "|", l.href, "|", l.result || ""));
await b.close();
})();