test(ui): capture console errors and exceptions during the UI check (V10 3)

- verify-ui.cjs collects console error/warning, uncaught exceptions, and log
  entries over the whole run; prints CONSOLE_EVENTS
- run with the user's three-sheet workbook: 0 events

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
ypshimandClaude Haiku 5.5 committed 2026-10-21 18:11:57 +09:00
1 parent 353931c767
commit 0b7ae1ef3f
1 file changed
+14 -1
+14 -1
View File
@@ -25,11 +25,21 @@ async function main() {
let seq = 0;
const waiting = new Map();
// Console and exception events, collected from the first navigation onward (V10 ③).
const consoleEvents = [];
ws.onmessage = (ev) => {
const m = JSON.parse(ev.data);
if (m.id && waiting.has(m.id)) {
waiting.get(m.id)(m);
waiting.delete(m.id);
} else if (m.method === 'Runtime.consoleAPICalled' && ['error', 'warning'].includes(m.params.type)) {
const text = m.params.args.map((a) => a.value ?? a.description ?? '').join(' ');
consoleEvents.push(`console.${m.params.type}: ${text}`);
} else if (m.method === 'Runtime.exceptionThrown') {
const d = m.params.exceptionDetails;
consoleEvents.push(`exception: ${d.exception?.description || d.text}`);
} else if (m.method === 'Log.entryAdded' && ['error', 'warning'].includes(m.params.entry.level)) {
consoleEvents.push(`log.${m.params.entry.level}: ${m.params.entry.text} ${m.params.entry.url || ''}`.trim());
}
};
const send = (method, params = {}) =>
@@ -51,6 +61,7 @@ async function main() {
await send('Page.enable');
await send('Runtime.enable');
await send('Log.enable');
await send('DOM.enable');
await send('Emulation.setDeviceMetricsOverride', { width: 1600, height: 1000, deviceScaleFactor: 1, mobile: false });
await send('Page.navigate', { url: APP_URL });
@@ -90,7 +101,9 @@ async function main() {
console.log('PRESSED', label, await evalJs(`[...document.querySelectorAll('#views button')].filter((b) => b.getAttribute('aria-pressed') === 'true').map((b) => b.textContent).join(',')`));
}
// V10 ③ — console errors surfaced by the page (checked via a reload with error capture).
// V10 ③ — every console error/warning and uncaught exception seen during the run above.
console.log(`CONSOLE_EVENTS ${consoleEvents.length}`);
for (const e of consoleEvents) console.log(` ${e}`);
ws.close();
}