import assert from "node:assert/strict"; import { describe, it } from "vitest"; import { failureCount, gates, renderReport, reportPath } from "./verify-transactional-mail-provider-baseline.mjs"; describe("verify-transactional-mail-provider-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-mail-runtime", "pnpm", ["exec", "vitest", "run", "packages/mail/src/mailjet.test.ts", "packages/mail/src/queue.test.ts"]], ["removed-provider-scan", "pnpm", ["run", "verify:removed-modules"]], ], ); const commandText = gates.map((gate) => [gate.command, ...gate.args].join(" ")).join("\n"); assert.doesNotMatch(commandText, /playwright|cypress|browser|test:e2e|e2e/i); }); it("derives failure counts from non-zero 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("lint", "2 errors and 0 warnings potentially fixable", ""), 2); assert.equal(failureCount("vitest-mail-runtime", "Tests 4 failed | 10 passed", ""), 4); assert.equal(failureCount("vitest-mail-runtime", "Test Files 3 failed | 20 passed", ""), 3); assert.equal(failureCount("removed-provider-scan", "matches found: 7", ""), 7); assert.equal(failureCount("removed-provider-scan", "matches found: 0", ""), 0); assert.equal(failureCount("removed-provider-scan", "scanner crashed", ""), 0); }); it("renders Transactional Mail Provider report sections with exitcodes, failure counts, fingerprints, and report path text", () => { const report = renderReport([ { id: "typecheck", command: "pnpm run typecheck", exitCode: 2, durationMs: 123, failureCount: 5, fingerprint: { hash: "abc123", excerpt: "error TS2322" }, }, ]); assert.match(report, /# Transactional Mail Provider Baseline Health/); assert.match(report, /Transactional Mail Provider\ baseline/); assert.doesNotMatch(report, /API Auth Hardening Baseline Health/); assert.match(report, /## typecheck/); assert.match(report, /Exitcode: 2/); assert.match(report, /Failure Count: 5/); assert.match(report, /Output Fingerprint: abc123/); assert.match(reportPath.replaceAll("\\", "/"), /\.tc\/baselines\/transactional-mail-provider\/baseline-health\.md$/); }); });