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 verifierPath = path.join(root, "scripts/verify-kb-widgets-workflow-marketing-decision-report.mjs"); function runVerifier() { return execFileSync(process.execPath, [verifierPath], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], }); } describe("verify-kb-widgets-workflow-marketing-decision-report", () => { // Isolierte Fixture-Kopie statt In-place-Mutation realer Repo-Dateien (die geteilte // docs/feature-manifests/plugin-candidates.json wird auch von Geschwister-Verifiern gelesen -> // sonst Parallelitaets-Race). Muster wie verify-portals-sites-decision-report.test.mjs. const runId = `${process.pid}-${Date.now()}`; const tempRoot = path.join(root, "node_modules", ".tmp", `kb-widgets-verifier-${runId}`); const tempReportPath = path.join(tempRoot, "docs/feature-decisions/kb-widgets-workflow-marketing-decision-report.md"); const tempPluginManifestPath = path.join(tempRoot, "docs/feature-manifests/plugin-candidates.json"); function copyFixtureTree() { fs.rmSync(tempRoot, { recursive: true, force: true }); fs.mkdirSync(tempRoot, { recursive: true }); for (const entry of ["apps", "docs", "prisma", ".env.example", ".env.production.example"]) { fs.cpSync(path.join(root, entry), path.join(tempRoot, entry), { recursive: true }); } } function runVerifierForTempRoot() { return execFileSync(process.execPath, [verifierPath, tempRoot], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], }); } afterEach(() => { fs.rmSync(tempRoot, { recursive: true, force: true }); }); it("passes for the committed KB/widgets/workflow/marketing report, inventory, and manifests", () => { expect(runVerifier()).toContain("PASS kb/widgets/workflow/marketing decision report verification"); }); it("fails when the report contains an unresolved TODO placeholder", () => { copyFixtureTree(); const source = fs.readFileSync(tempReportPath, "utf8"); fs.writeFileSync(tempReportPath, `${source}\nTODO: fixture placeholder\n`); expect(() => runVerifierForTempRoot()).toThrow(/report contains unresolved placeholder line: TODO: fixture placeholder/); }); it("fails when the workflow-engine plugin manifest component is removed", () => { copyFixtureTree(); const manifest = JSON.parse(fs.readFileSync(tempPluginManifestPath, "utf8")); manifest.components = manifest.components.filter((component) => component.id !== "workflow-engine"); fs.writeFileSync(tempPluginManifestPath, `${JSON.stringify(manifest, null, 2)}\n`); expect(() => runVerifierForTempRoot()).toThrow(/plugin-candidates manifest must contain component id "workflow-engine"/); }); it("fails when docs reintroduce stale pruned marketing path tokens", () => { copyFixtureTree(); const source = fs.readFileSync(tempReportPath, "utf8"); const stalePath = ["apps/web/app/routes", "brand.tsx"].join("/"); fs.writeFileSync(tempReportPath, `${source}\nStale path: ${stalePath}\n`); expect(() => runVerifierForTempRoot()).toThrow(/must not reference stale pruned path token/); }); });