#!/usr/bin/env node /* UI smoke test: boots wuxia.html in jsdom with a canvas 2D stub, then drives the real UI through creation -> days -> panels -> combat. */ const { JSDOM } = require('/app/node_modules/.pnpm/jsdom@29.1.1/node_modules/jsdom'); const fs = require('fs'); const html = fs.readFileSync('/root/Wuxia/wuxia.html', 'utf8'); function makeCtxStub() { const gradient = { addColorStop() { } }; const handler = { get(target, prop) { if (prop === 'createLinearGradient' || prop === 'createRadialGradient' || prop === 'createPattern') return () => gradient; if (prop === 'measureText') return () => ({ width: 10 }); if (prop === 'getImageData') return (x, y, w, h) => ({ data: new Uint8ClampedArray(w * h * 4) }); if (typeof prop === 'string') { if (!(prop in target)) target[prop] = (...args) => undefined; return target[prop]; } return undefined; }, set(target, prop, v) { target[prop] = v; return true; }, }; return new Proxy({}, handler); } const errors = []; const origErr = console.error; console.error = (...a) => { errors.push(a.map(x => (x && x.stack) ? x.stack.split('\n')[0] : String(x)).join(' ')); }; const dom = new JSDOM(html.replace('