Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,79 @@
|
||||
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/portals-sites-decision-report.md");
|
||||
const manifestPath = path.join(root, "docs/feature-manifests/plugin-candidates.json");
|
||||
const verifierPath = path.join(root, "scripts/verify-portals-sites-decision-report.mjs");
|
||||
let originalReport;
|
||||
let originalManifest;
|
||||
|
||||
function runVerifier() {
|
||||
return execFileSync(process.execPath, [verifierPath], {
|
||||
cwd: root,
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
}
|
||||
|
||||
describe("verify-portals-sites-decision-report", () => {
|
||||
const runId = `${process.pid}-${Date.now()}`;
|
||||
const tempRoot = path.join(root, "node_modules", ".tmp", `portals-sites-verifier-${runId}`);
|
||||
const tempManifestPath = path.join(tempRoot, "docs/feature-manifests/plugin-candidates.json");
|
||||
const tempReportPath = path.join(tempRoot, "docs/feature-decisions/portals-sites-decision-report.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(() => {
|
||||
if (originalReport !== undefined) {
|
||||
fs.writeFileSync(reportPath, originalReport);
|
||||
originalReport = undefined;
|
||||
}
|
||||
|
||||
if (originalManifest !== undefined) {
|
||||
fs.writeFileSync(manifestPath, originalManifest);
|
||||
originalManifest = undefined;
|
||||
}
|
||||
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("passes for the committed Portals/Sites decision report, inventory, and manifest", () => {
|
||||
expect(runVerifier()).toContain("PASS portals/sites decision report verification");
|
||||
});
|
||||
|
||||
it("fails when the report contains an unresolved TODO placeholder", () => {
|
||||
copyFixtureTree();
|
||||
const originalTempReport = fs.readFileSync(tempReportPath, "utf8");
|
||||
fs.writeFileSync(tempReportPath, `${originalTempReport}\nTODO: fixture placeholder\n`);
|
||||
|
||||
expect(() => runVerifierForTempRoot()).toThrow(/report contains unresolved placeholder line: TODO: fixture placeholder/);
|
||||
});
|
||||
|
||||
it("fails when the portals-sites manifest component is removed", () => {
|
||||
copyFixtureTree();
|
||||
const manifest = JSON.parse(fs.readFileSync(tempManifestPath, "utf8"));
|
||||
manifest.components = manifest.components.filter((component) => component.id !== "portals-sites");
|
||||
manifest.codeAreas = manifest.codeAreas.filter((codeArea) => codeArea !== "apps/web/app/modules/portals" && codeArea !== "apps/web/app/modules/sites");
|
||||
fs.writeFileSync(tempManifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||
|
||||
expect(() => runVerifierForTempRoot()).toThrow(/manifest must contain component id "portals-sites"/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user