import { spawnSync } from "node:child_process"; import { describe, expect, it } from "vitest"; import { childProcessTimeout } from "../helpers/child-process-timeout.ts"; /** * 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 the folder * markers. The manual a11y reviews, which people write and the a11y gates * read, moved to docs/accessibility/route-reviews/ on 2026-11-08, so the * folder is output only (docs/manual/03-outside-feature-folder.md, R3). A * file `git add -f` puts outside that list fails here. */ const ALLOWED = [ /^artifacts\/runbooks\/\.gitkeep$/u, /^artifacts\/tests\/\.gitkeep$/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", { timeout: childProcessTimeout(20) }, () => { it("are only the folder markers", () => { expect( trackedArtifacts().filter((file) => !ALLOWED.some((pattern) => pattern.test(file))), ).toEqual([]); }); });