Files
siftlode/frontend/src/lib/inputPrimitive.contract.test.ts
T
peter ff80cc96fd fix(design): rating and live colour tokens, the player's menus over its notices, the info overlay on a light theme (E28)
- F16: --rating (theme-scoped gold, 4.5:1 on the page and its chip), --rating-media, --live/--live-fg,
  --media-chrome replace 14 palette literals; a lint rule refuses palette classes; the theme contract
  measures them.
- The Plex player's notices drew over its open settings/tracks popovers: notices z-base, popovers z-menu.
- The player's info overlay rendered theme tokens on its always-dark panel: on a light theme the score
  (2.6:1), collection years (3.2:1) and cast initials (1.05:1) were unreadable; onDark variants now.
- The lint-rule contract tests share one ESLint with a one-off warm-up (a cold first lint took 8 s,
  past vitest's 5 s).
2026-09-25 13:55:26 +02:00

41 lines
1.9 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { eslint } from "./lintProbe.testkit";
// `local/input-primitive` (eslint.config.js): every text field is ui/Input, Textarea or InnerInput and
// every checkbox / slider / colour well a NativeControls primitive (docs/DESIGN.md A4, A6; E28 S3c).
// ~100 hand-styled boxes were swept; this pins that the rule keeping a new one out fires, and where it
// stands down.
const RULE = "local/input-primitive";
async function hits(source: string, filePath = "src/components/__probe.tsx"): Promise<number> {
const [result] = await eslint.lintText(source, { filePath });
return (result?.messages ?? []).filter((m) => m.ruleId === RULE).length;
}
describe("a hand-rolled field", () => {
it("is refused anywhere outside the field primitives, text box or native control", async () => {
const text = 'export const A = () => <input className="border px-2" />;\n';
expect(await hits(text)).toBe(1);
expect(await hits(text, "src/design-lab/__probe.tsx")).toBe(1);
// …and in a ui/ composite: the pager's page box is an Input too.
expect(await hits(text, "src/components/ui/Pager.tsx")).toBe(1);
expect(await hits("export const B = () => <textarea />;\n")).toBe(1);
expect(await hits('export const C = () => <input type="checkbox" />;\n')).toBe(1);
expect(await hits('export const D = () => <input type="range" />;\n')).toBe(1);
});
it("passes in a field primitive, for a file picker, and for the primitives themselves", async () => {
for (const file of ["Input.tsx", "NativeControls.tsx"])
expect(await hits("export const E = () => <input />;\n", `src/components/ui/${file}`)).toBe(
0,
);
expect(await hits('export const F = () => <input type="file" hidden />;\n')).toBe(0);
expect(
await hits(
'import { Input } from "./ui/Input";\nexport const G = () => <Input className="w-full" />;\n',
),
).toBe(0);
});
});