mirror of
https://github.com/bitbaum/heidi.git
synced 2026-12-04 05:57:42 +01:00
* Practice: choose or type, one switch above every question A remembered habit (heidi.practice.habit.v2) decides, for each word that has both, whether its meaning is chosen or its sentence typed. A flip swaps the questions still ahead one for one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: a word typed right comes back later than one chosen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: one hardness number for every question Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Plans: your own AI key is offered, and the pass card says what a pass is Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Knowledge map: a deterministic layout, and every node's state from the ledger lib/visual/knowledge-map is the first knowledge-map layout in the fleet, written to be extracted: plain data in, coordinates out, no app imports. Clusters packed into columns, nodes in rows under each cluster's name, labels wrapped with the real font's widths; no two cells meet, so no two labels can, at 320px as at 1280px. Same input, same picture. lib/domain/progress reads where a learner stands on every situation, grammar topic and word group (not started / started / shaky / solid / mastered) from the learner model, the review memory and the situation readings the situation pages already use, and orders the few lines worth acting on: the learner's own situations first, then new ones in their areas, then what wobbles, then the words that keep slipping. Nothing is counted in advance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * «Was du kannst»: the map page, the weak-spots card, and the ways to it /[locale]/progress draws the whole course as a map coloured by the learner's own answers, with a legend and one motion (what is known fills in, off under reduced motion). Tapping a node opens a sheet with what it is, the numbers (asked, right, last seen, due) and «Üben», «Bis es sitzt» (goal=nail), and for a situation «Situation starten»; an area's name opens its situations and practises the whole area (module=…). Works signed out from this device and signed in with the synced views; with no data it is the course, not started, and where to begin. The card «Was sitzt, was fehlt» is on the personal page and above the map; /practice links to the map; the avatar menu lists it. Personal and noindex like settings, so not in the sitemap. Strings in all seven dictionaries; the responsive audit measures /progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: an area scope, «Nail it», hardest first, and nothing right today asked again - module=<area>: every scene of one situation area (care, hospitals, ...) and the words said in them; subjects=<list>: named words and lines, for the weak spots. - goal=nail (nail.ts): a drill over a scope until each question is right twice in a row, the second at least three questions later and in the typed form where a word has one; a miss comes back after two to four others; at most 30 subjects, hardest not-known first. - order=hard: hardest first by hardness(); «Harder» prefers the harder question inside its band. - A sitting's order is shuffled (order.ts), never the same subject back to back and the same kind only where unavoidable; cards keep their most-heard-first order. - Answered right today and not wrong today, on any screen (stats now date every wrong answer): not new again today in a sitting; read instead of asked in a situation run (withKnownRead), unless its review is due. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Play together: a challenge link and a live round A challenge is ten fixed questions behind a link (/play/c/<id>): the same questions in the same order with the same option order for everyone, a nickname and no account, marked on the server, and a board of names, right answers and times. It is kept 30 days, and expired ones are removed when somebody next touches the table. A live round is a host screen (/play/host) with a six-digit code and a QR code, players on their phones (/play?code=), 20 seconds a question, points for right plus speed, counts per option on the host's screen, a short board on the phones and a podium. Realtime is short polling against Postgres: one primary-key read with a version, 204 when nothing moved. At most 50 players per room; a room is gone two hours after its last move, checked on access. Host actions need the host secret kept on the host's device; creating rooms and joining are limited with limitkit; nicknames are cleaned, capped at 24 and only ever rendered as text. Five new tables (migration 0033), two privacy flows, the strings in all seven languages, one section on /practice and one button at the end of a sitting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: wrong answers a German reader cannot see through, and «Find the German word» A harness (scripts/audit/options.ts, not shipped) measures how often a reader who knows no Zurich German answers each chosen-answer question by looks alone: most like the prompt, least like it, odd shape, longest. options.test.ts holds the rates near chance. - «Say it in Zurich German» (run): the wrong lines are the right line with one word changed: a Standard German word from the pack's leaks or the course's own cognate pairs, a form the pack places elsewhere, or an article the noun never takes. By looks: 99% -> 32%. Other lines only where a line has fewer than two such changes. - Look-alikes skip Zurich words that stand for two standard words (bi: bin/bei, wänn: wann/wenn) and course pairs that are not cognates, so a planted word is certainly not Zurich German. - «Stimmt das?»: a false claim is a near miss of the line's meaning (near-miss.ts), never another line; no near miss, no false claim. By resemblance: 96% -> 64%. - «What is meant?»: more near-miss meanings (modals, Herr/Frau, times, places, colours...), the closest first. Lines with one: 21% -> 42%. - Cognates («gah», gehen) are asked from German with real course words as the other options; the rest by meaning, with distractors as alike as the answer (resembles: letters and consonant skeleton). - Options, banks and columns are laid out from a seed per sitting and the question id (present.ts), one helper for practice and the runs. - hardness.ts counts giveaways, confusable options and odds; a cognate asked from Zurich rates easier than the same word asked from German. - New kind «Find the German word» (spot): a course line with one word in Standard German, tap the word; the answer shows the Zurich word and the line. Strings in all seven languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Questions: «Tschüss» is never offered as the certainly-wrong German word Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Exercises: read before moving on, and tap the words instead of typing The moment after an answer (exercises/chrome.tsx, useMoveOn): - a right answer shows the whole line where the question showed part of it, its meaning and the reason, then moves on after a beat as long as that text: 1.3 s + 45 ms a character, at most 6 s (move-on.ts); - a touch, wheel or focus on the session screen, or «Anhalten» beside «Weiter», holds it: the bar fades and the control reads «Angehalten» in the same box, so nothing moves; Enter or Space continues; - a wrong answer or a skip never moves on; - «Von selbst weiter: An | Aus» in the sitting's sheet, remembered on the device (heidi.practice.move-on.v1, person-level, on the privacy page); - reduced motion: no draining bar, the seconds are counted on «Weiter». The situation run's follow steps use the same hook and controls, and the run now has the same sheet behind the sliders. Tap instead of type (tiles.ts, exercises/tiles.tsx, answer-how.tsx): - every translate question can be built from tiles: its own words plus two or three real course words from the same scene, topic or word group, look-alikes first; marked against the course line (case and punctuation ignored), typed answers stay self-marked; - the build kind's tile UI is now TileAnswer, shared by both; - the habit is «Wählen | Antippen | Tippen»; old stored values stay valid; on a typed question it is that question's switch, and «Wählen» is not offered where there is no meaning question; - the run's «Lieber schreiben» link is the same «Wörter antippen | Tippen» switch, above the question; - tiles are recorded as mode "tap": not typed, not scheduled as recalled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Heidi Plus: a subscription that renews, monthly or yearly, with an intro price The one-time pass becomes «Heidi Plus»: a monthly plan that renews until cancelled, a yearly one at a saving, and an optional lower price for the first months, through Stripe (paykit 0.6 `stripeBilling`). The pass stays, offered below as «Lieber einmal zahlen?». - /plans is paykit's PlanPicker: Free | Heidi Plus (recommended) | Eigener KI-Schlüssel | Organisationen. The own-key tier is CHF 0 to Heidi, names the providers from ai-kit's BYOK_VENDORS and leads to /settings#model; the old own-key section is gone. Without prices, Plus is «Bald verfügbar» with the notify form. - A review step before Stripe (paykit's PlanReview): summary, notes, the account, the renewal box that must be ticked (Heidi has no terms page, so no terms box), the practice reminders as an optional box, and an active pass or subscription shown with «Abo verwalten» instead of a second one. - Prices only from HEIDI_PLUS_MONTH_CHF, HEIDI_PLUS_YEAR_CHF, HEIDI_PLUS_INTRO_CHF, HEIDI_PLUS_INTRO_MONTHS; the proposal is on /owner/payments and in .env.example, marked as one. - Stripe webhook: subscription events verified, handled once by event id (pay_events), the record in pay_subscriptions (migration 0034). A paid period moves the same entitlements row a pass uses, never back. - Settings: «Abo verwalten» opens Stripe's portal, with the status line (renews / ends / payment failed / ended). - Deleting the account cancels the subscription at Stripe first. - Privacy: the passPayments flow names the subscription, its tables and the email Stripe receives; the flows have anchors. - Strings in all seven languages. package.json asks for @bitbaum/paykit ^0.6.0; the lockfile follows once it is published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Play together: «Find the German word» can be played; the said-too list lives in the packs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: «Was willst du üben?» on /practice and the personal page; «Bis es sitzt» drills - The builder: what (everything, words, forms and grammar, a situation, an area, my weak spots), which (a searchable list, each row with the learner's state: not started, in progress, strong), how (quick round, Nail it, test; hardest first). It opens a URL of the sitting contract. - A «Nail it» sitting shows «12 of 20 nailed», says when the drill took only the hardest 30, and ends with a short summary; it resumes where it was left. - A situation run shows a line answered right today as a line to read. - «Bis es sitzt üben» on every situation page and grammar topic page with questions. - Strings in all seven dictionaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * «Which one is Zurich German?»: a wrong article names its noun; a form Zurich speakers use is never planted as wrong (tested) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Session bar: progress keeps its room, repeats shorten below 380px; audit measures the new answer moment The top bar's progress bar keeps a minimum width, and the «+1 repeat» note collapses to «+1 ↻» on the narrowest phones so 2/8 never pushes it off. The responsive audit gains ONLY= to narrow to changed pages, measures a held run step, measures a typed question as tiles before switching to typing, and answers the meaning gate (after hydration) where a language shows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Situation run: the reason for each wrong line is shown once, with the article's noun Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Situation run: what a step asks is the sitting's own small line above the question (one shape with practice) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Changelog 2026-12-03: the exercise revamp Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Plan test: new questions per sitting checked over 40 learners, not one lucky seed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * /practice: one picker — the quick round's mix sits under «Was willst du üben?» without a second «what / test» row Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Changelog 2026-12-03: plans (Free, Heidi Plus, own AI key, Organisations) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Lockfile: @bitbaum/paykit 0.6.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Heidi: «Was du kannst» answers next step, standing per area, what to do inside The knowledge map (unlabelled dots in rows, lines that meant nothing) is replaced by a page that answers, in order: one next step with its reason and one black button; per area a segmented bar of lines that sit, wobble and were never asked, with untouched areas collapsed to one line; inside an area every situation, topic or word group with its bar, status word and the action that fits it, sorted by what to do next. The step comes from a pure planOf (lib/domain/progress/plan.ts) that the personal page's card uses too, so the two never disagree. The map layout module, its tests and the weak-spots card are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Questions: one standard for practice, runs and play Every question now passes the same five rules, written down in code in lib/domain/questions/standard.ts and checked by tests: 1. Ask only what a German reader doesn't get for free. A line that can be read straight off its German is read, not asked. «Chasch mer schnäll hälfe?» is now a line to read. 2. Wrong options are the same kind of thing as the answer. «mir» is offered with «wir», «uns» and «euch», never with «nirgends» or «übermorgen». The reading shelf no longer fills a short list with words of another kind. 3. A question must not be solvable without knowing Zurich German. Seven solvers that don't know the language (look-alike, longest, odd one out and others) may beat chance by at most 15 points per kind; balance() drops the questions that let them do better. 4. Feedback gives the rule, other lines with the same word, and a line where the word means something else. A later line of the run asks the word again (transfer). 5. Hardness is real: it is measured from the options. Homographs: a word whose meaning depends on the line is asked only when the line's German proves the taught meaning (provesMeaning). The «wo» cue ", wo" matched «Ah, wo denn?», where «wo» is the question word. That cue is gone, and comma cues now end at a word boundary. This removes 5 false proofs, including «wohin». The sourced Einsiedeln text now asks «cho». Close is not wrong: choosing a look-alike that differs only by a form said in another Swiss region («geit», Bern) gets «Fast», with where that form is said. It is scheduled as FSRS «hard», not as a lapse. One rule, lookalikeVerdict, decides this. A Standard German word stays wrong. Questions are now chosen from ASKED_ITEMS, the items that meet the standard. PACK_ITEMS still holds everything, so stored progress, glosses and reminders keep working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Questions: rules that are rules, fair German-first words, spot, transfer - A rule line appears only where there is a rule. The line «Merk es dir im Satz…» shown under every plain word is gone (ruleOf in questions/standard.ts). «mir» and «si» now carry how their line tells the two meanings apart (homograph-role, homograph-modal), with examples taken from course lines, in all seven languages. The pack names which rule applies to which homograph. - Asked from German: wrong options come from the word's own group, are never rude, and look as much like the German word as the answer does. If the answer is the only word that looks like the German one, the word is not asked. Balance no longer keeps a kind's last question when a solver wins it. - Spot never plants a mere spelling of the Zurich word («bestelle» for «bstelle», «gehört» for «ghört»). It never plants a lone word ending in «-en» either, since that can be found by its ending alone. The word is quoted without its punctuation. - Transfer: a run asks a word at most twice. A homograph's second question goes to a later line that uses the other meaning, when the part has one («bi mir» after «Mir händ…»). A contrast question is never the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r --------- Co-authored-by: Claude <noreply@anthropic.com>
619 lines
31 KiB
JavaScript
619 lines
31 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
|
|
* ONLY=/practice/session?scene=apero,/situations/handover/run pnpm run audit:responsive
|
|
*
|
|
* 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(",");
|
|
/** Some of `PATHS` only, exactly as written there: the pages a change touched. */
|
|
const ONLY = process.env.ONLY ? process.env.ONLY.split(",") : null;
|
|
|
|
/**
|
|
* 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",
|
|
// The pass page: one card per pass, a price and a button per way of paying
|
|
// (francs and Bitcoin both, where both are on), the code field below.
|
|
"/pass",
|
|
"/plans",
|
|
// Which models answer: a table of names and numbers, the widest thing on it a model id.
|
|
"/models",
|
|
"/practice", "/privacy", "/settings",
|
|
// «Was du kannst»: the knowledge map, an SVG laid out to the width it gets,
|
|
// with every label of the course under a node.
|
|
"/progress", "/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", "/languages",
|
|
// Two of the scenes added on 2026-11-26, one per domain: the longest
|
|
// German line of the new care scenes (`at-the-door`) and the longest
|
|
// everyday title in Russian (`asking-the-way`).
|
|
"/situations/at-the-door", "/situations/asking-the-way",
|
|
// The language pages the map opens: Romansh carries the idioms, French the
|
|
// longest region sentence, and all three the interest form beside the map.
|
|
"/languages/fr", "/languages/it", "/languages/rm", "/dialect/wallisertitsch",
|
|
// 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", "/profile",
|
|
// The same screen AFTER an answer the learner typed or revealed: `ANSWERED`
|
|
// below. Reported cut off on a phone on 2026-11-25, in a state no sweep had
|
|
// ever rendered — every page above is measured as it loads.
|
|
"/practice/session?scene=apero",
|
|
// A situation: its opener is `/situations/handover` above; this is the
|
|
// reference list behind it, and the guided run itself — measured at every
|
|
// kind of step and at its ending, not only as it loads (`RUN` below).
|
|
"/situations/handover/lines", "/situations/handover/run",
|
|
// Reading: the shelf, and two OPEN texts — the longest sourced passage
|
|
// (place names nobody here chose the length of, each word a button) and an
|
|
// exchange from a care scene, whose lines are the longest the course has.
|
|
"/reading", "/reading/pfaeffikersee", "/reading/handover",
|
|
];
|
|
|
|
/**
|
|
* The guided run that is walked: a care scene, whose lines are the longest.
|
|
* Each kind of step is measured the first time it comes up — a line to
|
|
* follow, the same line answered, a sentence to build and built, a line to
|
|
* say, the replay with every line shown — and then the ending. If the ending
|
|
* is not reached the run FAILS as unreachable.
|
|
*/
|
|
const RUN = { path: "/situations/handover/run", kinds: ["follow", "build", "speak", "replay"] };
|
|
|
|
/**
|
|
* A sitting left half way on `ANSWERED.path`, so the audit opens on a typed
|
|
* question and then a revealed one instead of on whatever the plan deals.
|
|
* The session screen resumes it (`resume.ts`). If these ids leave the packs
|
|
* the sitting is not resumed, no field appears, and the run FAILS as
|
|
* unreachable rather than quietly measuring something else.
|
|
*/
|
|
const ANSWERED = {
|
|
path: "/practice/session?scene=apero",
|
|
key: "mixed|scene:apero",
|
|
ids: ["translate:scene:apero:3", "cloze:apero:0:cho"],
|
|
// A word missing and a word respelled: every line of the comparison shows.
|
|
typed: "Für mich lieber öpis Alkohol, aber ohni Donaudampfschifffahrtsgesellschaftskapitän",
|
|
};
|
|
|
|
/**
|
|
* 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, answered]) => {
|
|
try {
|
|
localStorage.setItem("heidi.saved.v1", JSON.stringify(saved));
|
|
localStorage.setItem("heidi.chat.draft.v1", JSON.stringify({ ...draft, updatedAt: new Date().toISOString() }));
|
|
localStorage.setItem(
|
|
"heidi.practice.session.v2",
|
|
JSON.stringify({ v: 2, courses: { "gsw-zh": { key: answered.key, ids: answered.ids, at: 0, outcomes: [], savedAt: new Date().toISOString() } } }),
|
|
);
|
|
// A learner who said what interests them: `/listen` then opens with
|
|
// «Für dich» (a caption, a row and a note per suggestion, the widest
|
|
// thing on that page), and `/profile` resumes on the interests
|
|
// question, the one with nine tiles.
|
|
localStorage.setItem(
|
|
"heidi.profile.v2",
|
|
JSON.stringify({ v: 2, courses: { "gsw-zh": { interests: ["politics", "sport", "science"], step: "interests", at: new Date().toISOString() } } }),
|
|
);
|
|
} catch {
|
|
// A browser with storage denied still has to render; so does this.
|
|
}
|
|
},
|
|
[SAVED, DRAFT, ANSWERED],
|
|
);
|
|
|
|
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 ONLY ? PATHS.filter((p) => ONLY.includes(p)) : 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);
|
|
}
|
|
}
|
|
|
|
// And a guided run, step by step to its ending (`RUN`).
|
|
if (path === RUN.path) {
|
|
const bar = page.locator("[data-chrome=session] > div:last-child");
|
|
const seen = new Set();
|
|
let ended = false;
|
|
for (let i = 0; i < 60 && !ended; i++) {
|
|
await page.waitForTimeout(120);
|
|
if ((await page.locator("[data-ending]").count()) > 0) {
|
|
ended = true;
|
|
break;
|
|
}
|
|
const kind = await page.locator("[data-run-step]").first().getAttribute("data-run-step").catch(() => null);
|
|
const first = kind !== null && !seen.has(kind);
|
|
if (first) {
|
|
seen.add(kind);
|
|
states.push({ name: ` [run: ${kind}]`, ...(await measure()) });
|
|
}
|
|
if (kind === "follow") {
|
|
await page.locator("[data-run-step] button:not([disabled])").first().click({ timeout: 5_000 }).catch(() => {});
|
|
if (first) states.push({ name: " [run: follow, answered]", ...(await measure()) });
|
|
// A right answer carries «Anhalten» beside «Weiter» (`useMoveOn`):
|
|
// measured held once, the state a reader stops in.
|
|
const hold = bar.locator("button[aria-pressed][data-move-on]");
|
|
if (!seen.has("follow:held") && (await hold.count()) > 0) {
|
|
seen.add("follow:held");
|
|
await hold.click({ timeout: 5_000 }).catch(() => {});
|
|
await page.waitForTimeout(150);
|
|
states.push({ name: " [run: follow, held]", ...(await measure()) });
|
|
}
|
|
// «Weiter» is the bar's LAST button: the first may be «Anhalten».
|
|
await bar.locator("button").last().click({ timeout: 5_000 }).catch(() => {});
|
|
} else if (kind === "build") {
|
|
const tiles = page.locator("[data-run-step] ul button:not([disabled])");
|
|
const count = await tiles.count();
|
|
for (let k = 0; k < count - 1; k++) await tiles.first().click({ timeout: 5_000 }).catch(() => {});
|
|
await bar.locator("button").last().click({ timeout: 5_000 }).catch(() => {});
|
|
await page.waitForTimeout(250);
|
|
if (first) states.push({ name: " [run: build, checked]", ...(await measure()) });
|
|
await bar.locator("button").last().click({ timeout: 5_000 }).catch(() => {});
|
|
} else if (kind === "replay") {
|
|
await bar.locator("button").last().click({ timeout: 5_000 }).catch(() => {});
|
|
await page.waitForTimeout(250);
|
|
states.push({ name: " [run: replay, every line]", ...(await measure()) });
|
|
await bar.locator("button").first().click({ timeout: 5_000 }).catch(() => {});
|
|
} else {
|
|
// A line to say: not spoken here (`audit:speaking` has the microphone).
|
|
await bar.locator("button").first().click({ timeout: 5_000 }).catch(() => {});
|
|
}
|
|
}
|
|
if (!ended || RUN.kinds.some((kind) => !seen.has(kind))) {
|
|
console.log(`ERR ${locale}${path} @${width} ${theme}: the run did not reach its ending through every kind of step`);
|
|
unreachable += 1;
|
|
} else {
|
|
await page.waitForTimeout(300);
|
|
states.push({ name: " [run: ending]", ...(await measure()) });
|
|
}
|
|
}
|
|
|
|
// And the answered states of a sitting: a typed answer compared with
|
|
// the line it should be, then a gap revealed.
|
|
if (path === ANSWERED.path) {
|
|
// A typed question opens on its tiles (a learner is never made to
|
|
// type): measured with two placed, then switched to the field.
|
|
// In a language with glosses the exercise first asks how good the
|
|
// learner's German is (`MeaningGate`); that screen was measured
|
|
// above, so answer it and go on to the question behind it.
|
|
const gate = page.locator("[data-meaning-gate] button");
|
|
// A click before hydration lands on a button with no handler yet
|
|
// (a cold dev server compiles for a minute): wait, then try until
|
|
// the gate is gone.
|
|
await page.waitForLoadState("networkidle", { timeout: 90_000 }).catch(() => {});
|
|
for (let tries = 0; tries < 5 && (await gate.count()) > 0; tries++) {
|
|
await gate.first().click({ timeout: 5_000 }).catch(() => {});
|
|
await page.locator("[data-meaning-gate]").waitFor({ state: "detached", timeout: 2_000 }).catch(() => {});
|
|
}
|
|
const heap = page.locator("[data-tiles] ul button:not([disabled])");
|
|
if ((await heap.count()) > 0) {
|
|
await heap.first().click({ timeout: 5_000 }).catch(() => {});
|
|
await heap.first().click({ timeout: 5_000 }).catch(() => {});
|
|
await page.waitForTimeout(150);
|
|
states.push({ name: " [typed question, as tiles]", ...(await measure()) });
|
|
}
|
|
await page.locator("[data-habit-option=type]").click({ timeout: 5_000 }).catch(() => {});
|
|
await page.waitForTimeout(250);
|
|
const field = page.locator("textarea");
|
|
if ((await field.count()) === 0) {
|
|
console.log(`ERR ${locale}${path} @${width} ${theme}: the typed question did not open (see ANSWERED)`);
|
|
unreachable += 1;
|
|
} else {
|
|
await field.fill(ANSWERED.typed);
|
|
await field.press("Enter");
|
|
await page.waitForTimeout(250);
|
|
states.push({ name: " [typed answer compared]", ...(await measure()) });
|
|
await page.locator("details > summary").first().click({ timeout: 5_000 }).catch(() => {});
|
|
await page.waitForTimeout(150);
|
|
states.push({ name: " [typed answer, more open]", ...(await measure()) });
|
|
// «I had it», then the gap: reveal it.
|
|
await page.keyboard.press("1");
|
|
await page.waitForTimeout(250);
|
|
await page.keyboard.press("Enter");
|
|
await page.waitForTimeout(250);
|
|
states.push({ name: " [gap revealed]", ...(await measure()) });
|
|
}
|
|
}
|
|
|
|
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,
|
|
);
|