import { spawnSync } from "node:child_process"; import { describe, expect, it } from "vitest"; /** * 0929/14-01. `artifacts/` is run output, but screenshots and a coverage * report were committed there and stayed tracked with nothing reading them. * `.gitignore` ignores the folder as a whole and re-includes only what people * write or keep: the folder markers and the manual a11y reviews, which the * a11y gates read (`config/ci/gates.json`). A file `git add -f` puts outside * that list fails here. */ const ALLOWED = [ /^artifacts\/runbooks\/\.gitkeep$/u, /^artifacts\/tests\/\.gitkeep$/u, /^artifacts\/tests\/a11y-manual\/[^/]+\.md$/u, ]; function trackedArtifacts(): string[] { const listed = spawnSync("git", ["ls-files", "-z", "--", "artifacts"], { encoding: "utf8", }); if (listed.error || listed.status !== 0) { throw new Error(`git ls-files failed: ${listed.error?.message ?? listed.stderr}`); } return listed.stdout.split("\0").filter((file) => file !== ""); } describe("tracked artifacts", () => { it("are only the folder markers and the manual a11y reviews", () => { expect( trackedArtifacts().filter((file) => !ALLOWED.some((pattern) => pattern.test(file))), ).toEqual([]); }); });