test: add vanilla regression baselines

Capture rendered-text and visual baselines before route migration, and detect external CSS dependencies. Do not change verify.mjs assertions; task 02 must remove the known legacy font URL before the audit can pass.
This commit is contained in:
Marcos Paulo
2026-09-05 02:47:28 +00:00
parent 8123965bf2
commit db86edbc21
91 changed files with 811 additions and 6 deletions
+32 -6
View File
@@ -1,18 +1,44 @@
import { readFileSync } from 'node:fs';
const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), 'utf8');
const pages = ['index.html','full-guide/index.html','summary/index.html','models/index.html','agents/index.html','skills/index.html','rules/index.html','skills-review/index.html','hands-on/starter/index.html','hands-on/rules/index.html'];
const pages = [
'index.html',
'full-guide/index.html',
'summary/index.html',
'models/index.html',
'agents/index.html',
'skills/index.html',
'rules/index.html',
'skills-review/index.html',
'hands-on/starter/index.html',
'hands-on/rules/index.html',
];
for (const page of pages) {
const html = read(page);
if (!html.includes('name="viewport"')) throw new Error(`${page} lacks a viewport declaration`);
if (html.match(/<(script|link)[^>]+(src|href)="https?:[^\"]+"/i)) throw new Error(`${page} has an external runtime dependency`);
if (html.match(/<(script|link)[^>]+(src|href)="https?:[^\"]+"/i))
throw new Error(`${page} has an external runtime dependency`);
}
const shared = read('chapters.css');
const skills = read('skills/styles.css');
const guide = read('full-guide/index.html');
const guideAudit = read('full-guide/audit.css');
for (const token of ['@media(max-width:800px)','@media(max-width:520px)']) if (!shared.includes(token)) throw new Error(`shared chapter CSS lacks ${token}`);
for (const token of ['minmax(0,1.3fr)','overflow-wrap:anywhere','@media(max-width:800px)','prefers-reduced-motion']) if (!skills.includes(token)) throw new Error(`skills package CSS lacks ${token}`);
if (!guide.includes('href="audit.css"')) throw new Error('full guide does not load its responsive audit overrides');
for (const token of ['.handoff table','.route-table button','overflow-wrap:anywhere']) if (!guideAudit.includes(token)) throw new Error(`full guide audit CSS lacks ${token}`);
const css = ['styles.css', 'chapters.css', 'skills/styles.css', 'full-guide/audit.css'];
for (const file of css) {
if (/@import|src:\s*url\(['\"]?https?:|url\(['\"]?https?:/i.test(read(file)))
throw new Error(`${file} has an external CSS dependency`);
}
for (const token of ['@media(max-width:800px)', '@media(max-width:520px)'])
if (!shared.includes(token)) throw new Error(`shared chapter CSS lacks ${token}`);
for (const token of [
'minmax(0,1.3fr)',
'overflow-wrap:anywhere',
'@media(max-width:800px)',
'prefers-reduced-motion',
])
if (!skills.includes(token)) throw new Error(`skills package CSS lacks ${token}`);
if (!guide.includes('href="audit.css"'))
throw new Error('full guide does not load its responsive audit overrides');
for (const token of ['.handoff table', '.route-table button', 'overflow-wrap:anywhere'])
if (!guideAudit.includes(token)) throw new Error(`full guide audit CSS lacks ${token}`);
console.log('responsive UI audit passed');