82 lines
3.4 KiB
JavaScript
82 lines
3.4 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 verifierPath = path.join(root, "scripts/verify-email-marketing-decision-report.mjs");
|
|
|
|
function runVerifier() {
|
|
return execFileSync(process.execPath, [verifierPath], {
|
|
cwd: root,
|
|
encoding: "utf8",
|
|
stdio: ["ignore", "pipe", "pipe"],
|
|
});
|
|
}
|
|
|
|
describe("verify-email-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", `email-marketing-verifier-${runId}`);
|
|
const tempReportPath = path.join(tempRoot, "docs/feature-decisions/email-marketing-decision-report.md");
|
|
const tempManifestPath = path.join(tempRoot, "docs/feature-manifests/plugin-candidates.json");
|
|
const tempEmailSequencesDocPath = path.join(tempRoot, "docs/features/email-sequences.md");
|
|
|
|
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", ".env.fly.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 Email Marketing decision report and manifests", () => {
|
|
expect(runVerifier()).toContain("PASS email marketing decision report verification");
|
|
});
|
|
|
|
it("fails when a required report heading is missing", () => {
|
|
copyFixtureTree();
|
|
const source = fs.readFileSync(tempReportPath, "utf8");
|
|
fs.writeFileSync(tempReportPath, source.replace("## CRM Audience Decision", "## Audience Decision"));
|
|
|
|
expect(() => runVerifierForTempRoot()).toThrow(/missing required heading: ## CRM Audience Decision/);
|
|
});
|
|
|
|
it("fails when Email Sequences drift back into plugin-candidates", () => {
|
|
copyFixtureTree();
|
|
const manifest = JSON.parse(fs.readFileSync(tempManifestPath, "utf8"));
|
|
manifest.components.splice(2, 0, {
|
|
id: "email-sequences",
|
|
title: "Email Sequences",
|
|
rationale: "Incorrectly promoted to plugin candidate.",
|
|
codeAreas: ["apps/web/app/routes/admin/email-sequences*"],
|
|
});
|
|
fs.writeFileSync(tempManifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
|
|
expect(() => runVerifierForTempRoot()).toThrow(/must not contain component id "email-sequences"/);
|
|
});
|
|
|
|
it("fails when Email Sequences stop declaring admin-preview status", () => {
|
|
copyFixtureTree();
|
|
const source = fs.readFileSync(tempEmailSequencesDocPath, "utf8");
|
|
fs.writeFileSync(tempEmailSequencesDocPath, source.replaceAll("foundation/admin-preview", "foundation"));
|
|
|
|
expect(() => runVerifierForTempRoot()).toThrow(/Email Sequences doc must reference boundary text: foundation\/admin-preview/);
|
|
});
|
|
});
|