#!/usr/bin/env node
/**
* Self-test for ui-defect-audit.mjs.
* Run: node scripts/ci/test-ui-defect-audit.mjs
*
* A detector is only worth its output if BOTH sides are pinned. The first draft
* of this audit flagged 88 "defects" across 14 sites, and most of the alignment
* ones were a heading followed by consistently indented items — correct markup
* reported as broken. A rule that fires on everything is as useless as one that
* fires on nothing, and it is more expensive, because someone has to read it.
*
* So every fixture below asserts a VERDICT, not just a run:
* - the real loki bug is still caught (positive)
* - correct markup stays silent (negative)
*
* Fixtures are inline data: URLs — no network, no fleet, no auth.
*/
import { DISCLOSE, MEASURE, loadPlaywright, parseViewports } from "./ui-defect-audit.mjs";
const FIXTURES = {
// ── navigation fixtures ───────────────────────────────────────────────────
// The orangecat sidebar as it shipped: the section title is an
in a
//
, and the ONLY thing carrying the click is the chevron beside it.
// Visitors aimed at the word "Fund" and nothing happened.
navDeadLabel: `
`,
// The same row done correctly: the label lives INSIDE the control, so the
// whole row is the target. This must stay silent.
navLabelInsideControl: `
`,
// A nav containing a link to the page we are on, with nothing announcing it.
navUnmarkedCurrent: `
`,
// The same nav, announcing correctly.
navMarkedCurrent: `
`,
// A nav of outbound links only — it legitimately contains no link to the
// current page, so "no aria-current" is CORRECT here and must stay silent.
navNoSelfLink: `
`,
// Targets below the fleet's 44px floor.
navSmallTargets: `
`,
// The original loki fleet card: an icon INLINE at the head of two of
// the four rows, shoving only those lines sideways by its own width, and a
// wrapped hint whose second line falls back to the container edge.
raggedStack: `
Fleet autopilot
Idle — nothing queued
0 working21 idle
Autopilot on — agents work through each project's queue, then pick the next-best task automatically and keep going until the queue is empty.
`,
// The SAME visual family done correctly: icons hang in a fixed gutter, every
// row shares one text column, the wrapped line has a hanging indent.
fixedStack: `
Fleet autopilot
Idle — nothing queued
0 working21 idle
Autopilot on — agents work through each project's queue, then pick the next-best task automatically and keep going until the queue is empty.
`,
// Correct markup that the first draft wrongly flagged: a label, then items
// deliberately indented under it. The column goes out once and STAYS — no
// return to a previous edge, so it is structure, not raggedness.
intentionalIndent: `
GUT · BRAIN AXIS
Vollständige Mikrobiomanalyse
Darmpermeabilitätsmarker
Neurotransmitter-Vorläuferstatus
`,
// An action below the AA floor, and one comfortably above it.
contrast: `
`,
// Chips on a 4%-white overlay over near-black. A naive single canvas paint
// resolves that overlay to SOLID WHITE and reports these as failures.
translucentChips: `
`,
// A nested GROUP between peer lines. datacat renders exactly this: a card
// title, a description, an icon checklist, then a CTA back at the card edge.
// The checklist is indented because it is a group, not because anything is
// broken — and the CTA returning to the base indent is what made the first
// draft call it ragged.
nestedGroup: `
Formular-Erfassung
Erstellen Sie benutzerdefinierte Formulare für Umfragen.
`,
// Centered copy. Every line starts at a different x BY DESIGN.
centeredCopy: `
Every feature — health tracking, digital twin, vet network, marketplace, and adoption listings — is included free with no pet limits.
`,
// A bare wrapper anchor around a styled button. The anchor's own ink is
// never painted — the button paints the label — so measuring the anchor read
// 1:1 on surf-your-life's "Konto erstellen". The button itself passes.
wrapperAnchor: `
`,
// A disabled control is dim BECAUSE it is disabled — WCAG exempts it. Its
// enabled twin with the same colors is a real finding.
disabledControl: `
`,
// A row of padded buttons in a text column: the BUTTON BOX is flush with the
// column and only the labels sit padding deeper — aoz-wohnen's hero read as
// ragged for exactly this.
buttonRow: `
`,
// The same hero with the button row genuinely off the column: the BOX edge
// returns 16px out and back, and the box edge is what must be measured.
buttonRowRagged: `
`,
// substrata's mobile menu as it shipped. The sits in the middle of
// the header, so `right: 0` on an absolutely positioned panel measures from
// THERE — and a 320px panel lands mostly off the left of a 390px screen.
// Every existing rule passes on this markup; the links simply are not on it.
navPanelOffLeft: `
`,
// The same menu anchored to the header instead of to the button — the fix.
// It must stay silent, or the rule cannot tell a bug from its own remedy.
navPanelAnchored: `
`,
// A closed slide-in drawer, parked entirely off the left. This is CORRECT —
// it is how every drawer in this fleet waits — and reporting it would make
// the rule fire on reparaturbonus-zh and anything else with one.
navClosedDrawer: `