Only the capabilities config set forbidOnly, so a committed test.only ran one e2e, visual or storybook test and passed. The skip check accepted any quarantine marker without comparing its expiry date to today. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { afterAll, describe, expect, it } from "vitest";
|
|
|
|
const FORBIDDEN = "tests/fixtures/test-evidence/forbidden";
|
|
const roots: string[] = [];
|
|
|
|
afterAll(async () => {
|
|
await Promise.all(roots.map((root) => rm(root, { recursive: true, force: true })));
|
|
});
|
|
|
|
function checkSource(sourceRoot: string) {
|
|
const result = spawnSync(
|
|
process.execPath,
|
|
[
|
|
"scripts/check-test-evidence.ts",
|
|
"--source-only",
|
|
"--source-root",
|
|
sourceRoot,
|
|
"--artifact",
|
|
"artifacts/quality/test-evidence-source-rules.json",
|
|
],
|
|
{ encoding: "utf8" },
|
|
);
|
|
return { status: result.status, stderr: result.stderr };
|
|
}
|
|
|
|
// 11-08. Each forbidden fixture is checked alone, so a rule that stops firing
|
|
// is not hidden by another fixture in the same directory still failing.
|
|
describe("test evidence source rules", () => {
|
|
it("rejects a focused test", () => {
|
|
const result = checkSource(`${FORBIDDEN}/focused-test.fixture`);
|
|
expect(result.status).toBe(1);
|
|
expect(result.stderr).toContain("focused test");
|
|
}, 30_000);
|
|
|
|
it("rejects a quarantine whose expiry date has passed", () => {
|
|
const result = checkSource(`${FORBIDDEN}/expired-quarantine.fixture`);
|
|
expect(result.status).toBe(1);
|
|
expect(result.stderr).toContain("quarantine expired on 2020-01-01");
|
|
}, 30_000);
|
|
|
|
it("rejects a skip without a quarantine", () => {
|
|
const result = checkSource(`${FORBIDDEN}/unowned-skip.fixture`);
|
|
expect(result.status).toBe(1);
|
|
expect(result.stderr).toContain("lacks owned expiring quarantine");
|
|
}, 30_000);
|
|
|
|
it("accepts a skip under an unexpired quarantine", async () => {
|
|
const root = await mkdtemp(path.join(tmpdir(), "test-evidence-quarantine-"));
|
|
roots.push(root);
|
|
const file = path.join(root, "quarantined.fixture");
|
|
// Built from parts so this file is not itself a skip the checker scans.
|
|
const skip = ["test", "skip"].join(".");
|
|
await writeFile(
|
|
file,
|
|
[
|
|
`// ${"quarantine"}(owner=frontend-platform, defect=open-fixture, expires=2999-12-31)`,
|
|
`${skip}("quarantined", async () => {});`,
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
const result = checkSource(file);
|
|
expect(result.stderr).toBe("");
|
|
expect(result.status).toBe(0);
|
|
}, 30_000);
|
|
});
|