import assert from "node:assert/strict"; import { describe, it } from "node:test"; import { buildCommandActionView } from "./commandActionView.ts"; describe("buildCommandActionView", () => { it("labels allowed command actions as policy-gated execution", () => { const view = buildCommandActionView({ intent: "container.restart", policy: "allowed", risk: "medium" }); assert.equal(view.tone, "execute"); assert.equal(view.buttonLabel, "Uitvoeren: container.restart"); assert.match(view.copy, /unsupported\/failed/i); }); it("keeps approval-required command actions explicit and non-executing", () => { const view = buildCommandActionView({ intent: "stack.redeploy", policy: "approval_required", risk: "high" }); assert.equal(view.tone, "approval"); assert.equal(view.buttonLabel, "stack.redeploy"); assert.match(view.copy, /niet uitgevoerd/i); }); it("marks blocked command actions as unavailable for approval or execution", () => { const view = buildCommandActionView({ intent: "volume.delete", policy: "blocked", risk: "high" }); assert.equal(view.tone, "blocked"); assert.equal(view.buttonLabel, "Geblokkeerd: volume.delete"); assert.match(view.copy, /voert deze actie niet uit/i); }); it("routes critical command actions through override guidance first", () => { const view = buildCommandActionView({ intent: "container.restart", policy: "allowed", risk: "critical" }); assert.equal(view.tone, "critical"); assert.equal(view.buttonLabel, "container.restart"); assert.match(view.copy, /Directe uitvoering is geblokkeerd/i); }); });