Files
govoplan-campaign/webui/tests/review-workflow-guidance.test.ts
zemion c51fc180fb
Module Package Release / publish-packages (push) Successful in 12s
Release govoplan-campaign v0.1.28: stabilize saving, review and delivery recovery
2026-09-08 01:32:26 +02:00

75 lines
2.9 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { attachmentDeliveryPreflight, calculateBuildReviewProgress } from "../src/features/campaigns/review/reviewProgress.ts";
test("separates blocking, individual, and group review work", () => {
assert.deepEqual(calculateBuildReviewProgress({
blocking: 2,
individualRequired: 3,
individualReviewed: 1,
groupRequired: 4,
reviewComplete: false
}), {
blocking: 2,
individualRequired: 3,
individualReviewed: 1,
individualRemaining: 2,
groupRequired: 4,
groupReviewed: 0,
groupRemaining: 4,
required: 7,
reviewed: 1,
remaining: 6
});
});
test("a recorded review completion acknowledges every review decision", () => {
const progress = calculateBuildReviewProgress({
blocking: 0,
individualRequired: 3,
individualReviewed: 3,
groupRequired: 4,
reviewComplete: true
});
assert.equal(progress.reviewed, 7);
assert.equal(progress.remaining, 0);
assert.equal(progress.individualRemaining, 0);
assert.equal(progress.groupRemaining, 0);
});
test("normalizes malformed counters without overstating progress", () => {
const progress = calculateBuildReviewProgress({
blocking: -2,
individualRequired: 2.9,
individualReviewed: 99,
groupRequired: Number.NaN,
reviewComplete: false
});
assert.equal(progress.blocking, 0);
assert.equal(progress.individualRequired, 2);
assert.equal(progress.individualReviewed, 2);
assert.equal(progress.required, 2);
assert.equal(progress.remaining, 0);
});
const acceptedAttachments = { migrationRequired: false, hasBuild: true, reviewLoaded: true,
blocking: 0, remaining: 0, inspectionComplete: true, missing: 14, ambiguous: 0 };
test("fourteen accepted missing matches do not ask again at final delivery preflight", () => {
assert.equal(attachmentDeliveryPreflight(acceptedAttachments).state, "ready");
assert.equal(attachmentDeliveryPreflight({ ...acceptedAttachments, inspectionComplete: false }).state, "ready");
});
test("expected policy omissions need no acceptance and pending review is not a hard attachment blocker", () => {
assert.equal(attachmentDeliveryPreflight({ ...acceptedAttachments, inspectionComplete: false, remaining: 0 }).state, "ready");
assert.equal(attachmentDeliveryPreflight({ ...acceptedAttachments, inspectionComplete: false, remaining: 14 }).state, "warning");
});
test("saved review cannot override real blockers, missing build evidence or legacy Mail migration", () => {
assert.equal(attachmentDeliveryPreflight({ ...acceptedAttachments, blocking: 1 }).state, "blocked");
assert.equal(attachmentDeliveryPreflight({ ...acceptedAttachments, migrationRequired: true }).state, "blocked");
assert.equal(attachmentDeliveryPreflight({ ...acceptedAttachments, reviewLoaded: false }).state, "info");
assert.equal(attachmentDeliveryPreflight({ ...acceptedAttachments, hasBuild: false }).state, "info");
});