57 lines
1.9 KiB
JavaScript
57 lines
1.9 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "vitest";
|
|
|
|
import { failureCount, gates, renderReport } from "./verify-api-auth-surface-baseline.mjs";
|
|
|
|
describe("verify-api-auth-surface-baseline", () => {
|
|
it("defines the expected non-E2E gate commands", () => {
|
|
assert.deepEqual(
|
|
gates.map((gate) => [gate.id, gate.command, gate.args]),
|
|
[
|
|
["typecheck", "pnpm", ["run", "typecheck"]],
|
|
["lint", "pnpm", ["run", "lint"]],
|
|
["vitest-app", "pnpm", ["exec", "vitest", "run", "apps/web/app/"]],
|
|
["api-auth-surface", "node", ["scripts/verify-api-auth-surface.mjs", "--json"]],
|
|
],
|
|
);
|
|
});
|
|
|
|
it("derives failure counts from gate output", () => {
|
|
assert.equal(failureCount("typecheck", "src/a.ts(1,1): error TS2322: wrong\nerror TS7006", ""), 2);
|
|
assert.equal(failureCount("lint", "✖ 3 problems (2 errors, 1 warning)", ""), 2);
|
|
assert.equal(failureCount("vitest-app", "Tests 4 failed | 10 passed", ""), 4);
|
|
assert.equal(
|
|
failureCount(
|
|
"api-auth-surface",
|
|
JSON.stringify({
|
|
directValidateApiKeyCallsites: [
|
|
{ file: "apps/api/src/app.ts" },
|
|
{ file: "apps/web/app/utils/services/apiService.ts" },
|
|
],
|
|
}),
|
|
"",
|
|
),
|
|
1,
|
|
);
|
|
});
|
|
|
|
it("renders report sections with exitcodes, failure counts and fingerprints", () => {
|
|
const report = renderReport([
|
|
{
|
|
id: "typecheck",
|
|
command: "pnpm run typecheck",
|
|
exitCode: 2,
|
|
durationMs: 123,
|
|
failureCount: 5,
|
|
fingerprint: { hash: "abc123", excerpt: "error TS2322" },
|
|
},
|
|
]);
|
|
|
|
assert.match(report, /# API Auth Surface Baseline Health/);
|
|
assert.match(report, /## typecheck/);
|
|
assert.match(report, /Exitcode: 2/);
|
|
assert.match(report, /Failure Count: 5/);
|
|
assert.match(report, /Output Fingerprint: abc123/);
|
|
});
|
|
});
|