chore: initialize POM 2 repo (docs guards green; release gates recorded NOT RUN pending install)
This commit is contained in:
30
tests/state.test.ts
Normal file
30
tests/state.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { bumpPatchVersion, createState, gotoStage, passStage, recordEvidence, startStage } from "../src/state";
|
||||
import { stage } from "../src/domain";
|
||||
|
||||
test("state machine rejects skipped prerequisites and evidence-free completion", async () => {
|
||||
assert.equal(bumpPatchVersion("1.2.9"), "1.2.10");
|
||||
assert.throws(() => bumpPatchVersion("latest"), /Invalid semantic version/);
|
||||
const root = await mkdtemp(join(tmpdir(), "pom-state-"));
|
||||
try {
|
||||
let state = createState("State Test", root);
|
||||
assert.throws(() => gotoStage(state, 1), /incomplete prerequisites/);
|
||||
state = startStage(state, 0);
|
||||
assert.equal(state.stageRuns["0"].status, "active");
|
||||
assert.throws(() => passStage(state, "report.json"), /lacks evidence/);
|
||||
|
||||
for (const criterion of stage(0).acceptance) {
|
||||
state = recordEvidence(state, criterion.id, `Verified ${criterion.label}`, ["01_planning/00_project_brief.md"], "Test");
|
||||
}
|
||||
state = passStage(state, "00_admin/validation/stage-0.json");
|
||||
assert.equal(state.stageRuns["0"].status, "complete");
|
||||
assert.equal(state.currentStage, 1);
|
||||
assert.deepEqual(state.completedStages, [0]);
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user