fix(fixture): design-system·diagnostics 음성 fixture를 파일마다 거절한다 #83

Merged
donghyeon.kang merged 2 commits from donghyeon.kang/fix/fixture-per-file-rejection AGit into main 2026-11-21 00:49:15 +00:00
13 changed files with 237 additions and 24 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ paths:
## 함정
1. `check:design-system`이 통과했으니 토큰만 썼다고 본다. TS·TSX에서는 `#hex`·`oklch(`·`rgb(`와 `style={{ … }}`의 손 색·간격만 찾는다. 문자열로 조립한 class, Tailwind 임의 값(`text-[…]`), `hsl()`·색 이름을 담은 다른 문자열은 안 본다. CSS는 `src` 아래 전부를 보고 UI-06이 간격·글자·반경·층·그림자의 날 값을 거절하지만, 너비·높이·위치·opacity는 보지 않는다. 리뷰가 잡는다. — `scripts/check-design-system.ts`, `docs/design/2026-07-26-design-system-platform-design.md` 4.1절 「토큰 CSS 검사 규칙」
2. tooltip에만 필요한 정보를 둔다. 검사기의 tooltip 규칙은 음성 fixture에서만 돌고 실제 소스는 보지 않는다. — `scripts/check-design-system.ts`, `docs/design/2026-07-26-design-system-platform-design.md` 6.1절 10번
2. tooltip에만 필요한 정보를 둔다. 이 꼴을 거절하는 검사기 규칙은 없으니 리뷰에서 본다(음성 fixture의 표식만 보던 규칙은 REV-FE-0002에서 지웠다). — `docs/design/2026-07-26-design-system-platform-design.md` 6.1절 10번
3. 포커스 대비 토큰을 `color-mix()`·알파·키워드로 만든다. 3:1 계산은 불투명한 `oklch()`로 끝나는 토큰만 하고 나머지는 실패한다. `color-mix()`는 색상각 공간(oklch·lch·hsl·hwb)에서 섞지 않는다. 기본은 `in oklab`이고, 반투명 색을 브라우저가 겹쳐 그린 결과를 재현할 때만 `in srgb`를 쓴다(`component.css`의 가림막). — `docs/styling/design-tokens.md` UI-01·UI-02
4. 다크 테마 재정의를 빠뜨리거나 light 전용 패널·글자색을 박는다. 핵심 역할 토큰은 `:root[data-theme="dark"]`에 모두 있어야 하고, `component.css`에 forced-colors 대체가 있어야 한다. — `docs/styling/design-tokens.md`, `scripts/check-design-system.ts`
5. 디자인 시스템 하위 파일, `lucide-react`, headless 라이브러리를 직접 import한다. `src/presentation/design-system/index.ts`와 vendor facade로만 들어간다. — `docs/architecture/layers.md` 규칙 `design-system-is-reached-through-its-index`·`icon-vendor-is-facade-only`, `docs/design/2026-07-26-design-system-platform-design.md` 6.1절
+2
View File
@@ -27,6 +27,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지
- FE-GATE-009의 `test:a11y`가 `playwright test --config playwright.a11y.config.ts --grep @a11y`로 돌고 결과를 `artifacts/tests/a11y/`에 쓴다. 자기 `test:a11y`를 고쳐 썼으면 `--config playwright.a11y.config.ts`를 넣는다. 빠지면 008과 009가 같은 결과 경로에 써서 `tests/unit/playwright-result-paths.test.ts`(FE-GATE-005)가 실패한다(`scripts/verify.sh gate FE-GATE-005`).
- FE-GATE-029가 `playwright test`의 `--grep-invert P` 실행마다 같은 testDir을 `--grep P`로 도는 게이트 실행을 요구한다. 자기 `test:e2e`·`test:a11y`의 패턴을 바꿨으면 두 글자를 같게 둔다. 게이트 명령에 파일 필터나 `grep`이 든 설정으로만 도는 testDir이 있으면 필터 없는 실행을 더한다. 짝이 없으면 main push의 FE-GATE-029가 그 testDir과 빠진 짝을 대며 실패한다(`scripts/verify.sh gate FE-GATE-029`).
- `check:test-evidence`(FE-GATE-008, fixture는 029)가 skip·fixme를 구문 트리로 찾는다. `testInfo.skip()`·`test.info().skip()`·import 별칭(`strictTest.skip()`)과 `.mts`·`.cts`·`.js`·`.mjs`·`.cjs`·`.jsx` 시험 파일도 본다. 이런 호출이 quarantine 주석 없이 있으면 실패한다. 옮긴 뒤 확인: `scripts/verify.sh script check:test-evidence:source`.
- `check:design-system:fixture`·`check:diagnostics:fixture`(FE-GATE-029)가 fixture 파일마다 거절을 요구한다. `tests/fixtures/design-system/forbidden/`·`tests/fixtures/diagnostics/forbidden/`에 어느 규칙에도 걸리지 않는 파일이 있으면 그 파일을 찍고 exit 2로 끝나 029가 실패한다. 표식 문자열(`TOOLTIP_ONLY_REQUIRED_INFORMATION`, `UNKNOWN_DIAGNOSTIC_EVENT`)만 보던 규칙이 없어지니, 자기 fixture가 그 표식에만 기대면 진짜 규칙 하나에 걸리게 고치거나 지운다. `check:i18n:fixture`의 파일 이름 판정도 끝 일치에서 경로 경계 일치로 바뀐다. 자기 규칙의 failure 문구는 경로 앞에 공백을, 뒤에 공백·`:`·끝을 두어야 그 파일을 거절한 것으로 센다(`"${file}"`·`(${file})` 꼴은 안 센다). 그 폴더에 자기 fixture를 더했으면 `tests/unit/design-system-rules.test.ts`·`tests/unit/fixture-rejection.test.ts`가 단언하는 failure 목록에도 더한다(FE-GATE-005). 옮긴 뒤 확인: `scripts/verify.sh gate FE-GATE-029 FE-GATE-005`.
- 수동 접근성 기록(`docs/accessibility/route-reviews/`)에 WCAG 2.2 칸 둘이 생기고, `Release ID`를 릴리스 태그와 대조한다.
- 옮기기 전: 자기 기록에 `M8`·`M9` 줄이 없으면 FE-GATE-009 형식 검사가 그 필드 이름을 대며 실패한다. release 단계를 태그 없이(브랜치에서 수동으로) 돌리면 FE-GATE-028이 `missing required environment: RELEASE_TAG`로 멈춘다.
- 옮기는 법: 기록마다 `M8 Focus not obscured: pending`, `M9 Target size: pending` 두 줄을 더한다. 서명하는 기록의 `Release ID`는 다음 release부터 그 릴리스 태그(예 `v1.4.0`)로 적는다. release 단계는 태그 run에서 돈다.
@@ -111,6 +112,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지
| [계약] | PR run은 바뀐 경로로 merge 게이트를 고른다. 경로표 `config/ci/pr-gate-selection.json`의 줄을 위에서부터 보고 처음 맞는 줄의 게이트를 늘 도는 001·002·003·010에 더한다. global 파일(`config/`, `scripts/`, `.gitea/`, 도구 설정, lockfile 등)이 하나라도 바뀌면 전부 돈다. 안 도는 게이트는 `건너뜀: <ID> — <이유>`를 찍고 성공으로 끝난다. main run과 수동 실행은 늘 전부 돈다. diff는 origin에서 인증 없이 base를 받아 잰다. 비공개 repo라 받지 못하면 이유를 찍고 전부 돈다. 경로표가 추적 파일을 모두 덮는지 시험이 본다(위 "먼저 할 일"). 시험 fixture는 PR job의 `CI_PR_BASE_REF`를 물려받지 않는다(소유자 결정 2026-11-13) | `config/ci/pr-gate-selection.json`, `scripts/lib/pr-gate-selection.ts`, `scripts/run-ci-gate.ts`, `scripts/contracts/ci-gates.ts`, `config/ci/gates.json`, `.gitea/workflows/quality-gates.yml`, `scripts/lib/fixture-node-modules.ts`, `tests/unit/pr-gate-selection.test.ts` | `9f8b2c1c`, `f0a8582c` |
| [계약] | `check:ci:gating`(FE-GATE-029)이 경로마다 그 경로를 돌리는 runner를 본다. Vitest 경로 아래의 `*.spec.*` 파일은 어느 게이트도 돌리지 않으므로 게이트 밖으로 세어 실패한다. 자기 Vitest 시험 파일이 `.spec`이면 `.test`로 바꾼다 (0929/12-06) | `scripts/check-ci-gating.ts`, `scripts/lib/ungated-tests.ts` | `d838be54` |
| [계약] | `check:test-evidence`의 skip·fixme 검사가 정규식에서 Babel 구문 트리로 바뀐다. 정규식은 `test.skip(` 꼴만 봐서 `testInfo.skip()`·`test.info().skip()`·import 별칭의 skip이 quarantine 없이 Playwright 시험을 뺐다. 파일은 Playwright `testMatch` 기본값의 확장자로 넓히고, 파싱이 안 되는 파일은 실패로 적는다. `test.fail()`은 그대로 허용한다 | `scripts/check-test-evidence.ts`, `tests/fixtures/test-evidence/forbidden/`, `tests/unit/test-evidence-source-rules.test.ts` | `6830ec5a` |
| [계약] | design-system·diagnostics 음성 fixture 판정이 「실패가 하나라도 있으면 통과」에서 「fixture 파일마다 자기 실패가 있어야 통과」로 바뀐다. 전에는 fixture 폴더에서만 도는 표식 규칙이 자기 파일을 늘 거절해, 검사기의 진짜 규칙(TSX의 raw palette·hue mix·inline style, direct console·민감 context)을 지워도 FE-GATE-029가 초록이었다. 세 검사기(`check-i18n.ts` 포함)가 같은 판정(`scripts/lib/fixture-rejection.ts`)을 쓰고, 거절되지 않은 파일이 있거나 fixture가 없으면 exit 2로 끝난다 | `scripts/check-design-system.ts`, `scripts/check-diagnostics.ts`, `scripts/check-i18n.ts`, `scripts/lib/fixture-rejection.ts`, `tests/fixtures/design-system/forbidden/`, `tests/fixtures/diagnostics/forbidden/` | `52e7d2c7` |
| [계약] | `verify:documentation`(FE-GATE-017)이 `scripts/verify.sh`와 `python3` 명령 안의 경로·script 이름도 대조한다. 자기 문서의 `scripts/verify.sh script <이름>`·`python3 <경로>`가 낡았으면 실패하니 고친다 (1112/08-06) | `scripts/verify-documentation-readiness.ts` | `aebb7c8c` |
| [계약] | release의 provider job 둘(vulnerability·provenance)에 FE-GATE-013과 같은 runner 요구(`hostRequirements`)를 적고, 계약이 둘이 같은지 본다. provider 감독 스크립트가 provider를 띄우기 전에 비특권 user namespace를 점검하고, 막혔으면 `test:system` 사전 점검과 같은 문구로 멈춘다 (1101/13-03) | `config/ci/gates.json`, `scripts/contracts/ci-gates.ts`, `scripts/generate-ci-workflow.ts`, `.gitea/workflows/quality-gates.yml`, `scripts/check-system-test-prerequisites.ts`, `scripts/run-and-validate-provider.ts` | `9ebd0856` |
| [계약] | 브라우저 job 컨테이너가 `--shm-size=2g`로 뜨고, Firefox 시험 프로필을 RAM 파일시스템(`/dev/shm`)에 둔다. Firefox가 시험 context의 저장소를 디스크 프로필에 두어, 디스크가 붐비면 첫 화면 5초 대기를 넘겼다. 자리가 모자라면 디스크 프로필로 돌고 이유를 한 줄 찍는다 | `scripts/generate-ci-workflow.ts`, `.gitea/workflows/quality-gates.yml`, `tests/support/browser/browser-test.ts`, `docs/operations/ci-quality-gates.md` | `f81dda49`, `c239bdf4` |
+10 -6
View File
@@ -1,6 +1,7 @@
import { mkdir, readFile, readdir } from "node:fs/promises";
import { designSystemReportArtifactSchema } from "./contracts/release-artifacts.ts";
import { fixtureRejectionFailure } from "./lib/fixture-rejection.ts";
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
import path from "node:path";
@@ -187,12 +188,6 @@ for (const file of sources) {
failures.push(`raw palette value in ${file}`);
}
failures.push(...hueMixFailures({ file, source }), ...inlineStyleFailures({ file, source }));
if (
file.includes("tests/fixtures/design-system/forbidden") &&
source.includes("TOOLTIP_ONLY_REQUIRED_INFORMATION")
) {
failures.push(`tooltip-only required information in ${file}`);
}
}
const report = designSystemReportArtifactSchema.parse({
@@ -214,6 +209,15 @@ await writeValidatedJsonArtifact({
value: report,
});
// Every fixture file must be rejected by a rule of its own (REV-FE-0002).
const unrejectedFixtures = fixtureMode
? fixtureRejectionFailure("Design system", sources, failures)
: undefined;
if (unrejectedFixtures) {
process.stderr.write(unrejectedFixtures);
process.exit(2);
}
if (failures.length > 0) {
process.stderr.write(`Design system contract failed:\n${failures.join("\n")}\n`);
process.exit(1);
+9 -6
View File
@@ -1,6 +1,7 @@
import { mkdir, readFile, readdir } from "node:fs/promises";
import { diagnosticsReportArtifactSchema } from "./contracts/release-artifacts.ts";
import { fixtureRejectionFailure } from "./lib/fixture-rejection.ts";
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
import path from "node:path";
@@ -106,12 +107,6 @@ for (const file of sources) {
if (calls.some((call) => sensitiveContext.test(call))) {
failures.push(`sensitive diagnostic or telemetry context in ${file}`);
}
if (
file.includes("tests/fixtures/diagnostics/forbidden") &&
source.includes("UNKNOWN_DIAGNOSTIC_EVENT")
) {
failures.push(`unknown diagnostic event in ${file}`);
}
}
const report = diagnosticsReportArtifactSchema.parse({
@@ -131,6 +126,14 @@ await writeValidatedJsonArtifact({
schema: diagnosticsReportArtifactSchema,
value: report,
});
// Every fixture file must be rejected by a rule of its own (REV-FE-0002).
const unrejectedFixtures = fixtureMode
? fixtureRejectionFailure("Diagnostics", sources, failures)
: undefined;
if (unrejectedFixtures) {
process.stderr.write(unrejectedFixtures);
process.exit(2);
}
if (failures.length > 0) {
process.stderr.write(
`Diagnostics contract failed:\n${failures.join("\n")}\n`,
+6 -8
View File
@@ -1,6 +1,7 @@
import { mkdir, readFile, readdir } from "node:fs/promises";
import { i18nReportArtifactSchema } from "./contracts/release-artifacts.ts";
import { fixtureRejectionFailure } from "./lib/fixture-rejection.ts";
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
import path from "node:path";
@@ -153,14 +154,11 @@ await writeValidatedJsonArtifact({
// Every fixture file must be rejected on its own; one rejected file must not
// hide a directory the discovery above stopped reaching.
const fixtureFiles = fixtureMode ? await listSourceFiles(sourceRoot) : [];
const unrejectedFixtures = fixtureFiles.filter(
(file) => !failures.some((failure) => failure.endsWith(file)),
);
if (fixtureMode && (fixtureFiles.length === 0 || unrejectedFixtures.length > 0)) {
process.stderr.write(
`I18n fixture was not rejected:\n${unrejectedFixtures.join("\n") || "(no fixture files found)"}\n`,
);
const unrejectedFixtures = fixtureMode
? fixtureRejectionFailure("I18n", await listSourceFiles(sourceRoot), failures)
: undefined;
if (unrejectedFixtures) {
process.stderr.write(unrejectedFixtures);
process.exit(2);
}
// A comment, punctuation or catalog words must not be rejected (0929/08-02).
+43
View File
@@ -0,0 +1,43 @@
// A `*:fixture` command passes when its checker exits 1 and prints its header
// (scripts/lib/ci-step-result.ts). One rejected file is enough for that, so a
// rule deleted from the checker hides behind the files that other rules still
// reject. A checker in fixture mode therefore asks that every fixture file is
// named by a failure of its own, and exits 2 when one is not: exit 2 is not
// the exit 1 the gate expects, so FE-GATE-029 fails (REV-FE-0002).
/**
* Whether `failure` names `file` as a whole path: at the start or after
* white space, and followed by the end, white space or `:` (a line number).
* `a.ts` is not named by a failure about `a.tsx` or `b/a.ts`.
*/
export function failureNamesFile(failure: string, file: string): boolean {
for (let at = failure.indexOf(file); at !== -1; at = failure.indexOf(file, at + 1)) {
const before = at === 0 ? "" : failure[at - 1];
const after = failure[at + file.length] ?? "";
if ((before === "" || /\s/.test(before)) && (after === "" || /[\s:]/.test(after))) return true;
}
return false;
}
/** The fixture files that no failure names. */
export function unrejectedFixtureFiles(
fixtureFiles: readonly string[],
failures: readonly string[],
): string[] {
return fixtureFiles.filter((file) => !failures.some((failure) => failureNamesFile(failure, file)));
}
/**
* The text a checker prints before it exits 2, or `undefined` when every
* fixture file is rejected. No fixture file at all is refused too: an empty or
* moved fixture folder must not pass as "every file rejected".
*/
export function fixtureRejectionFailure(
checker: string,
fixtureFiles: readonly string[],
failures: readonly string[],
): string | undefined {
const unrejected = unrejectedFixtureFiles(fixtureFiles, failures);
if (fixtureFiles.length > 0 && unrejected.length === 0) return undefined;
return `${checker} fixture was not rejected:\n${unrejected.join("\n") || "(no fixture files found)"}\n`;
}
@@ -0,0 +1,3 @@
// VD-05. A screen reaches the headless vendor instead of the design-system
// primitive that wraps it.
export { Button } from "react-aria-components";
+2
View File
@@ -0,0 +1,2 @@
// UI-02. A chart setting mixes colours in a hue space.
export const CHART_FILL = "color-mix(in hsl, var(--color-action), var(--color-surface))";
+7 -1
View File
@@ -1,3 +1,9 @@
// A raw colour outside a style attribute: only the raw palette rule sees it,
// so each fixture here is rejected by one rule (REV-FE-0002).
export function RawPalette() {
return <div style={{ color: "#ff0000" }}>raw palette</div>;
return (
<svg aria-hidden="true">
<path fill="#ff0000" d="M0 0h1v1H0z" />
</svg>
);
}
@@ -1 +0,0 @@
export const TOOLTIP_ONLY_REQUIRED_INFORMATION = "Required approval details";
+1 -1
View File
@@ -1,3 +1,3 @@
export function leakToConsole(token: string) {
console.error("UNKNOWN_DIAGNOSTIC_EVENT", token);
console.error("request failed", token);
}
+51
View File
@@ -425,4 +425,55 @@ describe("design system rules", { timeout: childProcessTimeout(3_540) }, () => {
await rm(root, { recursive: true, force: true });
}
});
// REV-FE-0002. check:design-system:fixture passes on exit 1 and the header,
// which one rejected file gives. Each forbidden fixture is rejected by the
// one rule it is for, and a file no rule rejects makes the script exit 2,
// so a rule dropped from the TSX loop fails here and in FE-GATE-029.
describe("check-design-system.ts --fixture", () => {
const fixtures = "tests/fixtures/design-system/forbidden";
const runFixtureMode = async (extra?: { file: string; source: string }) => {
const root = await mkdtemp(path.join(tmpdir(), "design-system-fixture-"));
try {
for (const folder of ["src/presentation/design-system/tokens", "src/presentation/styles", fixtures]) {
await cp(folder, path.join(root, folder), { recursive: true });
}
if (extra) await writeFile(path.join(root, fixtures, extra.file), extra.source);
const result = spawnSync(process.execPath, [path.resolve("scripts/check-design-system.ts"), "--fixture"], {
cwd: root,
encoding: "utf8",
});
const { failures } = JSON.parse(
await readFile(path.join(root, "artifacts/quality/design-system-fixture.json"), "utf8"),
) as { failures: string[] };
return { status: result.status, stderr: result.stderr, failures };
} finally {
await rm(root, { recursive: true, force: true });
}
};
it("rejects every forbidden fixture by its own rule", async () => {
const { status, stderr, failures } = await runFixtureMode();
expect(status, stderr).toBe(1);
expect(stderr).toContain("Design system contract failed:");
expect([...failures].sort()).toEqual(
[
`${fixtures}/hue-mix.tsx mixes colours in hsl; use oklab`,
`${fixtures}/raw-inline-style.tsx style color: "red" is written by hand; read a token or use a primitive variant`,
`${fixtures}/raw-inline-style.tsx style padding: 13 is written by hand; read a token or use a primitive variant`,
`direct headless vendor import in ${fixtures}/headless-vendor-import.tsx`,
`raw palette value in ${fixtures}/raw-palette.tsx`,
].sort(),
);
});
it("exits 2 when a fixture file is not rejected", async () => {
const { status, stderr } = await runFixtureMode({
file: "probe.tsx",
source: 'export function Probe() {\n return <p className="probe">reads tokens</p>;\n}\n',
});
expect(status, stderr).toBe(2);
expect(stderr).toBe(`Design system fixture was not rejected:\n${fixtures}/probe.tsx\n`);
});
});
});
+102
View File
@@ -0,0 +1,102 @@
import { spawnSync } from "node:child_process";
import { cp, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
failureNamesFile,
fixtureRejectionFailure,
unrejectedFixtureFiles,
} from "../../scripts/lib/fixture-rejection.ts";
import { childProcessTimeout } from "../helpers/child-process-timeout.ts";
// REV-FE-0002. A `*:fixture` command passes on exit 1 and the header, which
// one rejected file gives; check-i18n, check-design-system and
// check-diagnostics ask that every fixture file is rejected on its own.
describe("negative fixture rejection", { timeout: childProcessTimeout(1_038) }, () => {
describe("failureNamesFile", () => {
it.each([
["raw palette value in tests/a.tsx", true],
["tests/a.tsx mixes colours in hsl; use oklab", true],
["tests/a.tsx:2 z-index: 50 writes 50 by hand", true],
["eslint 1:1 message in tests/a.tsx", true],
["raw palette value in tests/a.tsx.bak", false],
["raw palette value in other/tests/a.tsx", false],
["raw palette value in tests/a.tsxx", false],
["direct console diagnostics bypass", false],
])("%s names tests/a.tsx: %s", (failure, named) => {
expect(failureNamesFile(failure, "tests/a.tsx")).toBe(named);
});
it("does not take a file for the longer path it starts", () => {
expect(failureNamesFile("raw palette value in tests/a.tsx", "tests/a.ts")).toBe(false);
});
it("finds the file after an earlier partial match", () => {
expect(failureNamesFile("tests/a.tsx.bak and tests/a.tsx", "tests/a.tsx")).toBe(true);
});
});
it("lists the fixture files no failure names", () => {
expect(
unrejectedFixtureFiles(["tests/a.ts", "tests/b.ts", "tests/c.ts"], ["rule one in tests/a.ts", "tests/c.ts:1 rule two"]),
).toEqual(["tests/b.ts"]);
});
it("passes only when every fixture file is rejected", () => {
expect(fixtureRejectionFailure("Probe", ["tests/a.ts"], ["rule in tests/a.ts"])).toBeUndefined();
expect(fixtureRejectionFailure("Probe", ["tests/a.ts", "tests/b.ts"], ["rule in tests/a.ts"])).toBe(
"Probe fixture was not rejected:\ntests/b.ts\n",
);
});
it("refuses a fixture folder with no files", () => {
expect(fixtureRejectionFailure("Probe", [], ["rule in tests/a.ts"])).toBe(
"Probe fixture was not rejected:\n(no fixture files found)\n",
);
});
// A rule dropped from check-diagnostics.ts leaves its fixture unrejected:
// the script exits 2 and FE-GATE-029, which expects exit 1, fails.
describe("check-diagnostics.ts --fixture", () => {
const fixtures = "tests/fixtures/diagnostics/forbidden";
const runFixtureMode = async (extra?: { file: string; source: string }) => {
const root = await mkdtemp(path.join(tmpdir(), "diagnostics-fixture-"));
try {
await cp(fixtures, path.join(root, fixtures), { recursive: true });
if (extra) await writeFile(path.join(root, fixtures, extra.file), extra.source);
const result = spawnSync(process.execPath, [path.resolve("scripts/check-diagnostics.ts"), "--fixture"], {
cwd: root,
encoding: "utf8",
});
const { failures } = JSON.parse(
await readFile(path.join(root, "artifacts/quality/diagnostics-fixture.json"), "utf8"),
) as { failures: string[] };
return { status: result.status, stderr: result.stderr, failures };
} finally {
await rm(root, { recursive: true, force: true });
}
};
it("rejects every forbidden fixture by its own rule", async () => {
const { status, stderr, failures } = await runFixtureMode();
expect(status, stderr).toBe(1);
expect(stderr).toContain("Diagnostics contract failed:");
expect([...failures].sort()).toEqual([
`direct console diagnostics bypass in ${fixtures}/direct-console.ts`,
`sensitive diagnostic or telemetry context in ${fixtures}/raw-context.ts`,
]);
});
it("exits 2 when a fixture file is not rejected", async () => {
const { status, stderr } = await runFixtureMode({
file: "probe.ts",
source: "export function probe(): number {\n return 1;\n}\n",
});
expect(status, stderr).toBe(2);
expect(stderr).toBe(`Diagnostics fixture was not rejected:\n${fixtures}/probe.ts\n`);
});
});
});