Some checks are pending
Test and SonarQube / quality (push) Waiting to run
- Export the region-type picker handlers and magRunPageQuality to the page (they threw "not defined", so the picker never opened and Find missed text / Verify OCR did nothing) - Add a unit test that fails when an inline mag* handler is not exported - Quality audit: pixel-level clipping check on all four box edges, duplicate-article detection, detected full-page advertisements skipped and shown green (no manual button) - Driving mode text is karaoke-style (whole article, current sentence and word highlighted) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
19 lines
1.1 KiB
JavaScript
19 lines
1.1 KiB
JavaScript
// Every function named in an inline on*="..." handler (in magazine.js markup or the section HTML)
|
|
// must be exported on `root` in magazine.js -- an unexported one fails silently in the browser
|
|
// (e.g. the region-type picker never opening).
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
const js = readFileSync(new URL('../static/js/magazine.js', import.meta.url), 'utf8');
|
|
const html = readFileSync(new URL('../static/sections/s-magazine.html', import.meta.url), 'utf8');
|
|
const exported = new Set([...js.matchAll(/^root\.(\w+)\s*=/gm)].map((m) => m[1]));
|
|
const handlerCalls = (text) => [...text.matchAll(/\son(?:click|change|input|focus|blur|keydown|keyup|mousedown|submit)=\\?["']([^"']*)/g)]
|
|
.flatMap((m) => [...m[1].matchAll(/\b(mag\w+)\s*\(/g)].map((c) => c[1]));
|
|
|
|
test('every mag* inline handler is exported on window', () => {
|
|
const used = new Set([...handlerCalls(js), ...handlerCalls(html)]);
|
|
const missing = [...used].filter((name) => !exported.has(name)).sort();
|
|
assert.deepEqual(missing, []);
|
|
});
|