mirror of
https://github.com/bitbaum/heidi.git
synced 2026-12-05 11:08:47 +01:00
* chore(chatkit): the broken-word audit runs on every page audit:responsive now also lays out every word with findBrokenWords from @bitbaum/chatkit/audit (chatkit ^0.13 -> ^0.14.2) and fails on one drawn across two lines, at rest and with the header's dropdowns open. Its first run found three, fixed in CSS, never by trimming copy: - the footer's language list: two 56px columns inside one grid cell drew «Schwiizerd / ütsch» on every page; one column, break-words. - the listening row: «Wissenschaftsma / gazin» beside «Подписаться» at 320; the row wraps and the button drops under the name instead. - the answer card's «Schriftdeutsch» badge at the end of a long label: inline-block, nowrap, so it moves to the next line whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * fix(vocabulary): a known word is never cut — break-words, not wrap-anywhere The word audit found «Entschuldigung» split across two lines on the vocabulary list at 320px in de, fr and ru. The list is words we wrote, so it gets a column wide enough for them (AGENTS.md); wrap-anywhere and hyphens-auto were willing to cut them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * fix(vocabulary): on a phone the German sits under the dialect word, so no word is cut break-words still cuts a word whose column is narrower than it, and the third column of the row was ~100px at 320px against «Entschuldigung» at ~110px. Below sm the row is two lines (word, then its German); from sm it is the three columns it was. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE --------- Co-authored-by: Claude <noreply@anthropic.com>
447 lines
21 KiB
JavaScript
447 lines
21 KiB
JavaScript
/**
|
|
* Every page, at every phone width, in every language — does anything run off
|
|
* the side of the screen?
|
|
*
|
|
* WHY THIS EXISTS AS A SCRIPT RATHER THAN A TEST. Horizontal overflow is a
|
|
* LAYOUT fact: it depends on the real width of real glyphs in a real font at a
|
|
* real viewport, and no amount of reading the source finds it. It was reported
|
|
* three times from a phone before anything caught it, and each time the fix
|
|
* was applied to the one page in the screenshot while three others stayed
|
|
* broken — because nobody could see them.
|
|
*
|
|
* WHAT IT CHECKS, and the second one is the one that matters:
|
|
*
|
|
* OVER an element's box extends past the viewport. Before `overflow-x: clip`
|
|
* went on the body this made the whole DOCUMENT scroll sideways; now it
|
|
* is clipped, so `document.scrollWidth` no longer reveals it and this
|
|
* has to measure the elements themselves.
|
|
* CLIP an element's content is wider than the element and the element does
|
|
* not scroll — text cut off and unreachable. The same defect, one level
|
|
* down, and invisible without measuring.
|
|
* WORD a word drawn across two lines — "Te / rm", "Di / re / ct / or / y".
|
|
* Nothing overflows and nothing is clipped; the text simply cannot be
|
|
* read. `wrap-anywhere` on the wrong element does this, and so does a
|
|
* table cell at phone width. chatkit's `findBrokenWords` measures each
|
|
* word's line boxes (a word beside - / . @ : and anything over 24
|
|
* characters is exempt, since a link has to break somewhere).
|
|
*
|
|
* AND IT OPENS THINGS, because measuring a page at rest missed a real one. The
|
|
* account dropdown hangs `absolute right-0` off its button; the day the avatar
|
|
* stopped being the last control in the bar, the panel's left third went off
|
|
* the screen with its labels cut in half. Every check here passed, because
|
|
* every dropdown on the page was shut. So the header's disclosures are opened
|
|
* one at a time and measured open — on a couple of representative pages rather
|
|
* than all of them, since the header is the same header everywhere.
|
|
*
|
|
* It seeds real browser state first: a dozen kept words, in several scripts,
|
|
* with the contexts they were kept from — one of them a link, because a
|
|
* learner keeping a word from a pasted URL is the exact case that broke
|
|
* `/portal`, and an empty localStorage would have shown a clean page.
|
|
*
|
|
* pnpm run dev # in another terminal
|
|
* pnpm run audit:responsive
|
|
* LOCALES=de,fr WIDTHS=320 pnpm run audit:responsive # narrow it down
|
|
*
|
|
* NOT part of `pnpm run verify`: it needs a running server and a browser
|
|
* binary, which `verify` deliberately does not. Run it when you touch layout.
|
|
*/
|
|
import { BROKEN_WORDS_SOURCE } from "@bitbaum/chatkit/audit";
|
|
import { chromium } from "playwright";
|
|
|
|
const BASE = process.env.BASE ?? "http://localhost:3000";
|
|
const LOCALES = (process.env.LOCALES ?? "de,fr,ru").split(",");
|
|
const WIDTHS = (process.env.WIDTHS ?? "320,360,390").split(",").map(Number);
|
|
const THEMES = (process.env.THEMES ?? "light,dark").split(",");
|
|
|
|
/**
|
|
* Where the header's dropdowns are opened and measured.
|
|
*
|
|
* Two pages rather than all of them: the header is the same header everywhere,
|
|
* and opening three disclosures on five hundred renders would turn a two
|
|
* minute check into a twenty minute one nobody runs.
|
|
*/
|
|
const PROBE = ["", "/portal"];
|
|
|
|
/** Every page below a locale. A route missing here is a route nobody measures. */
|
|
const PATHS = [
|
|
"", "/chat", "/portal", "/about", "/contribute", "/dialect", "/dialect/zueriduetsch",
|
|
// Basel is the one area on the far side of the first isogloss, and the one
|
|
// whose branch panel shows two identical forms; Bündnerdütsch is the one
|
|
// that belongs to no branch. Both render a path the taught area does not.
|
|
"/dialect/baseldytsch", "/dialect/buendnerdueuetsch",
|
|
"/essays", "/essays/warum-die-schweiz-ihre-mundarten-behalten-hat",
|
|
"/grammar", "/impressum", "/investors", "/listen", "/method", "/organisations",
|
|
"/practice", "/privacy", "/settings", "/speaking", "/technology", "/vocabulary",
|
|
// The situations index, plus the two scenes most likely to break a phone:
|
|
// `handover` holds the longest line in the pack («S Zimmer, wo mir gschtern
|
|
// gruumt händ, isch parat.») beside a German gloss that is longer still, and
|
|
// `evening-unrest` is the scene whose rows carry a grammar link under both
|
|
// halves — the three-deep stack that has nothing to shrink if the grid track
|
|
// is left at `auto`.
|
|
"/situations", "/situations/handover", "/situations/evening-unrest",
|
|
// A grammar topic page, and the two worst cases among them: `no-preterite`
|
|
// has the longest example pair in the pack and now also lists the scene
|
|
// lines that use it, and `unified-plural` renders «Mir händ, ihr händ, si
|
|
// händ.» beside a German gloss half again as long.
|
|
"/grammar/no-preterite", "/grammar/unified-plural",
|
|
// The practice page in a SCOPED state, which is a different layout: it adds
|
|
// the scope banner above the session, and its pill wraps in three languages.
|
|
"/practice?topic=no-preterite",
|
|
// The session screens: no header and no footer, a body exactly the screen
|
|
// high, and the answer bar pinned under a scrolling question. The test
|
|
// carries its clock in the top bar, the one place a long label can collide.
|
|
"/practice/session", "/practice/session?flow=test", "/warmup", "/warmup/session",
|
|
];
|
|
|
|
/**
|
|
* A browser that has been used.
|
|
*
|
|
* The long link and the 49-letter compound are not decoration: they are the
|
|
* two shapes with no break opportunity in them, and they are what a learner
|
|
* pastes. The Cyrillic and French contexts are here because a kept word
|
|
* carries the sentence it came from, in whatever language that was.
|
|
*/
|
|
const LINK =
|
|
"https://www.zuerich.ch/de/portal/verwaltung/mitteilungen/2026/wohnungsvergabe-mitteilung-an-alle-mieterinnen.html";
|
|
const SAVED = {
|
|
version: 1,
|
|
words: [
|
|
{ target: "chrank", bridge: "krank", context: "Je suis malade", savedAt: "2026-09-19T08:00:00.000Z" },
|
|
{ target: "hesch", bridge: "hast", context: "Hesch mir mal de Schlüssel, bitte?", savedAt: "2026-09-17T08:00:00.000Z" },
|
|
{ target: "Morn", bridge: "morgen", context: "tomorrow you have your MRI Mr meijer", savedAt: "2026-09-17T08:00:00.000Z" },
|
|
{ target: "wotsch", bridge: "willst", context: "Wanna go to this party", savedAt: "2026-09-17T08:00:00.000Z" },
|
|
{ target: "ha", bridge: "habe", context: "Sagen Sie das bestimmter — ich habe schon zweimal gefragt.", savedAt: "2026-09-16T08:00:00.000Z" },
|
|
{ target: "wett", bridge: "möchte", context: "я хочу пойти на концерт в пятницу вечером", savedAt: "2026-09-16T08:00:00.000Z" },
|
|
{ target: "Donaudampfschifffahrtsgesellschaftskapitaenswitwe", bridge: "Donaudampfschifffahrtsgesellschaftskapitänswitwe", context: LINK, savedAt: "2026-09-15T08:00:00.000Z" },
|
|
{ target: "znacht", bridge: "Abendessen", context: "Mir gaht's guet, danke. Und dir?", savedAt: "2026-09-15T08:00:00.000Z" },
|
|
{ target: "öppis", bridge: "etwas", context: "Wotsch öppis z trinke?", savedAt: "2026-09-13T08:00:00.000Z" },
|
|
],
|
|
};
|
|
|
|
/** An answer carrying every field that has ever run off the edge. */
|
|
const ANSWER = {
|
|
mode: "produce",
|
|
text: `Sie antworten, dass es Ihnen gut geht. Nachschlagen: ${LINK}`,
|
|
dialect: "Mir gaht's guet, danke. Und dir?",
|
|
dialectClean: false,
|
|
dialectFlags: ["nicht-zuerichdeutsche-form-xyz", "unbekannte-schreibung-abcdefgh"],
|
|
tone: "warm",
|
|
toneNote: "Warm und freundlich, passt für Kolleginnen und Kollegen in einem informellen Gespräch.",
|
|
glosses: [
|
|
{ form: "gaht's", standard: "geht es", english: "geht es", rule: "nd → nn" },
|
|
{ form: "Donaudampfschifffahrtsgesellschaftskapitaenswitwe", standard: "Donaudampfschifffahrtsgesellschaftskapitänswitwe", english: "Witwe eines Donaudampfschiffskapitäns", rule: "nd → nn" },
|
|
],
|
|
suggestions: [
|
|
{ label: "WÄRMER UND VIEL LÄNGER ALS ÜBLICH", text: LINK, english: "Ein sehr langer Link", variety: "bridge", clean: false, flags: ["flag-eins-sehr-lang", "flag-zwei"] },
|
|
{ label: "KÜRZER", text: "Guet, danke!", english: "Gut, danke!", clean: true, flags: [] },
|
|
],
|
|
next: [{ id: "reply" }, { id: "rephrase", axis: "warmer" }, { id: "grammar", topic: "no-preterite" }],
|
|
// The ONE row under the latest answer (`answerRow`): replies first, then
|
|
// the moves and learn chips, capped — so a full row, with the longest reply
|
|
// chatkit keeps (48 characters) and the grammar link that must survive it.
|
|
replies: ["Ja, gern", "Wie säg ich das förmlicher für d Verwaltig?", "Wie antworte ich darauf?", "Nein danke"],
|
|
model: "openai/gpt-oss-120b-instruct-turbo-preview-2026",
|
|
};
|
|
|
|
const DRAFT = {
|
|
version: 1,
|
|
locale: "de",
|
|
messages: [
|
|
{ id: "m1", authorId: "me", body: `Wie antworte ich darauf? ${LINK}`, createdAt: "2026-09-19T08:00:00.000Z" },
|
|
{ id: "m2", authorId: "heidi", body: ANSWER.text, createdAt: "2026-09-19T08:00:05.000Z", answer: ANSWER },
|
|
],
|
|
};
|
|
|
|
/** Runs in the page: every element whose box or whose content is too wide. */
|
|
function findOverflow(viewport) {
|
|
const over = [];
|
|
const clipped = [];
|
|
for (const el of document.querySelectorAll("body *")) {
|
|
const box = el.getBoundingClientRect();
|
|
const visible = box.width > 0 || box.height > 0;
|
|
|
|
if (visible && (box.right > viewport + 1 || box.left < -1) && !insideScroller(el)) {
|
|
// Only the outermost offender: a child sticking out of a parent that is
|
|
// itself sticking out is one defect reported twice.
|
|
const parent = el.parentElement?.getBoundingClientRect();
|
|
if (!parent || (parent.right <= viewport + 1 && parent.left >= -1)) {
|
|
over.push(describe(el, box));
|
|
}
|
|
}
|
|
|
|
if (el.scrollWidth > el.clientWidth + 1) {
|
|
const overflowX = getComputedStyle(el).overflowX;
|
|
// A real scroller is a deliberate choice; `visible` and `clip` are not.
|
|
if (overflowX === "visible" || overflowX === "clip") clipped.push(describe(el, box));
|
|
}
|
|
}
|
|
return { over, clipped, doc: document.documentElement.scrollWidth };
|
|
|
|
/**
|
|
* Is this element simply further along inside something that scrolls?
|
|
*
|
|
* THE SAME EXEMPTION THE `clipped` CHECK ALREADY MAKES, which this one was
|
|
* missing. Two lines below, content wider than its box is reported only
|
|
* when `overflow-x` is `visible` or `clip`, because "a real scroller is a
|
|
* deliberate choice" — but the horizontal check above had no such rule, so
|
|
* the third item of any sideways-scrolling row was reported as overflow for
|
|
* being where a scrolled item is supposed to be.
|
|
*
|
|
* It matters because the two checks disagreeing is worse than either being
|
|
* wrong: the on-this-page rail became a one-row scroller on phones, the
|
|
* document did NOT overflow (375px in a 375px viewport, measured), and the
|
|
* audit still printed four findings. A check that cries wolf on a correct
|
|
* page is a check people start passing `|| true` to.
|
|
*
|
|
* The scrolling ancestor must itself be inside the viewport. If the
|
|
* scroller is the thing hanging off the screen, that is a real defect and
|
|
* it is still reported — on the scroller, where it belongs.
|
|
*/
|
|
function insideScroller(el) {
|
|
for (let p = el.parentElement; p && p !== document.body; p = p.parentElement) {
|
|
const ox = getComputedStyle(p).overflowX;
|
|
if (ox === "auto" || ox === "scroll") {
|
|
const r = p.getBoundingClientRect();
|
|
if (r.right <= viewport + 1 && r.left >= -1) return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function describe(el, box) {
|
|
return {
|
|
tag: el.tagName.toLowerCase(),
|
|
cls: (el.getAttribute("class") ?? "").slice(0, 110),
|
|
left: Math.round(box.left),
|
|
right: Math.round(box.right),
|
|
sw: el.scrollWidth,
|
|
cw: el.clientWidth,
|
|
text: (el.textContent ?? "").replace(/\s+/g, " ").trim().slice(0, 44),
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Does the header's CONTENT still fit the height the token promises?
|
|
*
|
|
* `--header-height` (globals.css) is what the on-this-page rail pins below
|
|
* and what every anchored heading scrolls clear of. The header is now given
|
|
* that height outright, so asking "is the header the token height" answers
|
|
* itself — it is, by construction, even when the token is wrong. A check
|
|
* that cannot fail is worse than no check, because a clean run then means
|
|
* nothing.
|
|
*
|
|
* The falsifiable question is the other one: does what the header CONTAINS
|
|
* still fit inside it? Add a taller control — a second line of nav, a bigger
|
|
* avatar — and the content outgrows the fixed box and is quietly clipped,
|
|
* while every consumer of the token keeps clearing the old height. That is
|
|
* the failure this catches, and nothing in the type checker or the unit
|
|
* tests can see it: it is real glyphs in a real font at a real width.
|
|
*/
|
|
function measureHeader() {
|
|
const header = document.querySelector("header");
|
|
if (!header) return null;
|
|
const box = header.getBoundingClientRect().height;
|
|
// The tallest thing actually laid out inside the bar.
|
|
let content = 0;
|
|
for (const el of header.querySelectorAll("*")) {
|
|
const cs = getComputedStyle(el);
|
|
if (cs.position === "absolute" || cs.position === "fixed" || cs.display === "none") continue;
|
|
const r = el.getBoundingClientRect();
|
|
if (r.height > 0) content = Math.max(content, r.bottom - header.getBoundingClientRect().top);
|
|
}
|
|
return { box, content, declared: getComputedStyle(document.documentElement).getPropertyValue("--header-height").trim() };
|
|
}
|
|
|
|
/**
|
|
* `pnpm exec playwright install chromium` provides one; an environment that
|
|
* already ships a browser (a CI image, a sandbox) points at it instead rather
|
|
* than downloading a second copy.
|
|
*/
|
|
const browser = await chromium.launch(
|
|
process.env.CHROMIUM ? { executablePath: process.env.CHROMIUM } : {},
|
|
);
|
|
let renders = 0;
|
|
let headerDrift = 0;
|
|
/**
|
|
* Counted apart, because conflating them misled me once already.
|
|
*
|
|
* A long run against a dev server can hit a page that will not compile for
|
|
* unrelated reasons, and the summary said "40 with overflow" for forty HTTP
|
|
* 500s. A check that reports the wrong KIND of failure sends you looking in
|
|
* the wrong place, which is most of the cost of a failing check.
|
|
*/
|
|
let overflowing = 0;
|
|
let unreachable = 0;
|
|
let brokenWords = 0;
|
|
|
|
for (const theme of THEMES) {
|
|
for (const width of WIDTHS) {
|
|
const context = await browser.newContext({
|
|
viewport: { width, height: 780 },
|
|
isMobile: true,
|
|
hasTouch: true,
|
|
colorScheme: theme,
|
|
});
|
|
// Before the first paint, so the page renders WITH the data rather than
|
|
// filling in afterwards and being measured empty.
|
|
await context.addInitScript(
|
|
([saved, draft]) => {
|
|
try {
|
|
localStorage.setItem("heidi.saved.v1", JSON.stringify(saved));
|
|
localStorage.setItem("heidi.chat.draft.v1", JSON.stringify({ ...draft, updatedAt: new Date().toISOString() }));
|
|
} catch {
|
|
// A browser with storage denied still has to render; so does this.
|
|
}
|
|
},
|
|
[SAVED, DRAFT],
|
|
);
|
|
|
|
const page = await context.newPage();
|
|
// No model is called: the answer above is the fixture, so the audit is
|
|
// deterministic and costs nobody a token.
|
|
await page.route("**/api/chat", (route) =>
|
|
route.fulfill({
|
|
status: 200,
|
|
headers: { "content-type": "text/event-stream" },
|
|
body: `event: message\ndata: ${JSON.stringify({ type: "answer", answer: ANSWER })}\n\n`,
|
|
}),
|
|
);
|
|
|
|
for (const locale of LOCALES) {
|
|
for (const path of PATHS) {
|
|
const url = `${BASE}/${locale}${path}`;
|
|
let response;
|
|
try {
|
|
response = await page.goto(url, { waitUntil: "domcontentloaded", timeout: 30_000 });
|
|
} catch (error) {
|
|
console.log(`ERR ${locale}${path} @${width} ${theme}: ${String(error).slice(0, 90)}`);
|
|
unreachable += 1;
|
|
continue;
|
|
}
|
|
if (!response || response.status() >= 400) {
|
|
console.log(`HTTP ${response?.status()} ${locale}${path} @${width} ${theme}`);
|
|
unreachable += 1;
|
|
continue;
|
|
}
|
|
await page.waitForTimeout(350);
|
|
renders += 1;
|
|
|
|
// Every word on one line, as well. chatkit's function is handed over
|
|
// as source text: it runs inside the page, where the glyphs are.
|
|
const measure = async () => ({
|
|
found: await page.evaluate(findOverflow, width),
|
|
broken: await page.evaluate(`(${BROKEN_WORDS_SOURCE})(document.body)`),
|
|
});
|
|
const states = [{ name: "", ...(await measure()) }];
|
|
|
|
const head = await page.evaluate(measureHeader);
|
|
if (head && head.content > head.box + 1) {
|
|
headerDrift += 1;
|
|
console.log(
|
|
`\nHEAD ${locale}${path} @${width} ${theme}: the header contains ${Math.round(head.content)}px ` +
|
|
`of content in a ${Math.round(head.box)}px bar (--header-height: ${head.declared}).\n` +
|
|
` It is being clipped, and the rail and every anchored heading still clear the old height.`,
|
|
);
|
|
}
|
|
|
|
// Then again with each header disclosure open, one at a time.
|
|
if (PROBE.includes(path)) {
|
|
const toggles = page.locator("header button[aria-expanded]:visible");
|
|
for (let i = 0; i < (await toggles.count()); i += 1) {
|
|
const toggle = toggles.nth(i);
|
|
const name = (await toggle.getAttribute("aria-label")) ?? (await toggle.innerText()).trim().slice(0, 16);
|
|
await toggle.click({ timeout: 5_000 }).catch(() => {});
|
|
await page.waitForTimeout(150);
|
|
states.push({ name: ` [open: ${name}]`, ...(await measure()) });
|
|
await toggle.click({ timeout: 5_000 }).catch(() => {});
|
|
await page.waitForTimeout(100);
|
|
}
|
|
}
|
|
|
|
for (const { name, broken } of states) {
|
|
if (broken.length === 0) continue;
|
|
brokenWords += 1;
|
|
console.log(
|
|
`\nWORD ${locale}${path} @${width} ${theme}${name}: cut across two lines: ${[...new Set(broken)].join(", ")}`,
|
|
);
|
|
}
|
|
|
|
for (const { name, found } of states) {
|
|
if (found.over.length === 0 && found.clipped.length === 0) continue;
|
|
|
|
overflowing += 1;
|
|
console.log(`\n### ${locale}${path} @${width} ${theme}${name} (document ${found.doc}px)`);
|
|
for (const o of found.over.slice(0, 6)) {
|
|
console.log(` OVER <${o.tag}> L${o.left} R${o.right} "${o.text}"\n ${o.cls}`);
|
|
}
|
|
for (const o of found.clipped.slice(0, 6)) {
|
|
console.log(` CLIP <${o.tag}> content ${o.sw}px in ${o.cw}px "${o.text}"\n ${o.cls}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
await context.close();
|
|
}
|
|
}
|
|
|
|
/*
|
|
* THE NAVIGATION CONTRACT, AT THE WIDTHS THIS FILE NEVER RENDERED.
|
|
*
|
|
* `fleet/SHARED.md` holds eight rules for nav chrome, and names where they
|
|
* break: "one width was never a sample of the layout, only of one branch of
|
|
* it." This audit sweeps phone widths only. Measured on 2026-09-25, Heidi's
|
|
* desktop nav — Start, Chat, Lernen, Üben, Über Heidi — was 16 to 20px tall
|
|
* at 1440px, against the contract's 44px, and had been since it shipped.
|
|
* Every phone-width run was clean.
|
|
*
|
|
* So the header alone gets checked at a tablet and a desktop width, per
|
|
* locale: every control at least 44x44 (rule 3) and none crossing the
|
|
* viewport edge (rule 7). One page each, because the header is the same on
|
|
* every page — six renders rather than doubling the whole sweep.
|
|
*/
|
|
let navBreaches = 0;
|
|
for (const width of [834, 1440]) {
|
|
const context = await browser.newContext({ viewport: { width, height: 900 } });
|
|
const page = await context.newPage();
|
|
for (const locale of LOCALES) {
|
|
try {
|
|
await page.goto(`${BASE}/${locale}`, { waitUntil: "domcontentloaded", timeout: 30_000 });
|
|
} catch {
|
|
continue;
|
|
}
|
|
await page.waitForTimeout(350);
|
|
const found = await page.evaluate((w) => {
|
|
const out = [];
|
|
for (const el of document.querySelectorAll("header a, header button")) {
|
|
const r = el.getBoundingClientRect();
|
|
if (r.width === 0 || r.height === 0 || getComputedStyle(el).visibility === "hidden") continue;
|
|
const name = (el.innerText || el.getAttribute("aria-label") || el.tagName).trim().slice(0, 24);
|
|
if (r.width < 43.5 || r.height < 43.5) out.push(`SMALL ${name} ${Math.round(r.width)}x${Math.round(r.height)}`);
|
|
if (r.right > w + 0.5 || r.left < -0.5) out.push(`EDGE ${name} L${Math.round(r.left)} R${Math.round(r.right)}`);
|
|
}
|
|
return out;
|
|
}, width);
|
|
for (const line of found) {
|
|
navBreaches += 1;
|
|
console.log(`NAV ${locale} @${width}: ${line}`);
|
|
}
|
|
}
|
|
await context.close();
|
|
}
|
|
|
|
await browser.close();
|
|
console.log(
|
|
`\n${renders} page renders measured — ${overflowing} with overflow` +
|
|
(brokenWords > 0 ? `, ${brokenWords} with a word cut across two lines` : "") +
|
|
(headerDrift > 0 ? `, ${headerDrift} where the header is not its token height` : "") +
|
|
(navBreaches > 0 ? `, ${navBreaches} navigation-contract breaches at 834/1440` : "") +
|
|
(unreachable > 0 ? `, and ${unreachable} that did not load at all` : ""),
|
|
);
|
|
if (unreachable > 0) {
|
|
console.log("A page that does not load is not a layout finding. Check the server before reading the rest.");
|
|
}
|
|
process.exit(
|
|
overflowing === 0 && unreachable === 0 && headerDrift === 0 && navBreaches === 0 && brokenWords === 0 ? 0 : 1,
|
|
);
|