38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { execFileSync } from "node:child_process";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
const root = process.cwd();
|
|
const reportPath = path.join(root, "docs/feature-decisions/crm-decision-report.md");
|
|
const verifierPath = path.join(root, "scripts/verify-crm-decision-report.mjs");
|
|
let originalReport;
|
|
|
|
function runVerifier() {
|
|
return execFileSync(process.execPath, [verifierPath], {
|
|
cwd: root,
|
|
encoding: "utf8",
|
|
stdio: ["ignore", "pipe", "pipe"],
|
|
});
|
|
}
|
|
|
|
describe("verify-crm-decision-report", () => {
|
|
afterEach(() => {
|
|
if (originalReport !== undefined) {
|
|
fs.writeFileSync(reportPath, originalReport);
|
|
originalReport = undefined;
|
|
}
|
|
});
|
|
|
|
it("passes for the committed CRM decision report and manifest", () => {
|
|
expect(runVerifier()).toContain("PASS crm decision report verification");
|
|
});
|
|
|
|
it("fails when a required report heading is missing", () => {
|
|
originalReport = fs.readFileSync(reportPath, "utf8");
|
|
fs.writeFileSync(reportPath, originalReport.replace("## Risks", "## Risk Check"));
|
|
|
|
expect(() => runVerifier()).toThrow(/missing required heading: ## Risks/);
|
|
});
|
|
});
|