import assert from "node:assert/strict"; import { describe, it } from "node:test"; import { getPolicyActionState, getPolicyActionButtonLabel } from "./policyActionState.ts"; describe("getPolicyActionState", () => { it("blocks critical actions unless an explicit override exists", () => { assert.deepEqual(getPolicyActionState("allowed", "critical", true, false), { kind: "critical_override_required", interactive: true, fallbackMessage: "Kritieke actie vereist handmatige override in Safety Center.", }); }); it("marks blocked policy decisions as non-interactive", () => { assert.deepEqual(getPolicyActionState("blocked", "high", true, true), { kind: "blocked", interactive: false, fallbackMessage: null, }); }); it("requires an approval handler for approval-required actions", () => { assert.deepEqual(getPolicyActionState("approval_required", "medium", false, false), { kind: "approval", interactive: false, fallbackMessage: "Goedkeuringsflow is voor deze actie nog niet aangesloten.", }); }); it("requires an execute handler for allowed actions", () => { assert.deepEqual(getPolicyActionState("allowed", "low", false, false), { kind: "execute", interactive: false, fallbackMessage: "Deze actie heeft nog geen veilige uitvoerflow in AppOps V1.", }); }); it("keeps approval-required action labels explicit", () => { assert.equal(getPolicyActionButtonLabel("approval_required", "Scan All"), "Vraag goedkeuring: Scan All"); assert.equal(getPolicyActionButtonLabel("approval_required", "Pause All"), "Vraag goedkeuring: Pause All"); }); it("does not alter allowed or blocked action labels", () => { assert.equal(getPolicyActionButtonLabel("allowed", "Scan"), "Scan"); assert.equal(getPolicyActionButtonLabel("blocked", "Delete Data Volume"), "Delete Data Volume"); }); });