import { readdirSync, readFileSync, statSync } from "node:fs"; import { join } from "node:path"; import { describe, expect, it } from "vitest"; const SHELL_ROOT = join(import.meta.dirname, "../../../apps/web/src/pages"); /** Primary shell surfaces must not use sub-label pixel typography. */ const FORBIDDEN_PRIMARY = [/text-\[(9|10|11)px\]/, /\bsize=\{(9|10|11|12|13)\}/]; function walk(dir: string, out: string[] = []): string[] { for (const entry of readdirSync(dir)) { const path = join(dir, entry); if (statSync(path).isDirectory()) { walk(path, out); } else if (/\.tsx$/.test(entry) && !/\.test\.tsx$/.test(entry)) { out.push(path); } } return out; } describe("ui scale guard — primary shell surfaces", () => { const shellFiles = walk(SHELL_ROOT); it("has shell files to scan", () => { expect(shellFiles.length).toBeGreaterThan(5); }); for (const file of shellFiles) { const rel = file.replace(`${SHELL_ROOT}/`, ""); it(`${rel} avoids ultra-small primary UI classes`, () => { const content = readFileSync(file, "utf8"); for (const pattern of FORBIDDEN_PRIMARY) { expect(content, pattern.toString()).not.toMatch(pattern); } }); } });