fix(gate): reviewer_confirm requires explicit approve; free-text is actionable, not accidental approve
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
const { resolveConfirmOutcome } = require("../../tht-gate.js");
|
||||
|
||||
test("explicit approve choice resolves to approve", () => {
|
||||
assert.deepEqual(resolveConfirmOutcome({ id: "u1", choices: ["approve"] }), { kind: "approve" });
|
||||
});
|
||||
|
||||
test("reject choice resolves to reject", () => {
|
||||
assert.deepEqual(resolveConfirmOutcome({ id: "u1", choices: ["reject"] }), { kind: "reject" });
|
||||
});
|
||||
|
||||
test("freetext control is actionable, carries text, and is NOT approve", () => {
|
||||
const out = resolveConfirmOutcome({ id: "u1", control: "freetext", text: "aggiungi la tabella X" });
|
||||
assert.equal(out.kind, "freetext");
|
||||
assert.equal(out.text, "aggiungi la tabella X");
|
||||
});
|
||||
|
||||
test("back/exit controls resolve to their kinds", () => {
|
||||
assert.equal(resolveConfirmOutcome({ control: "back" }).kind, "back");
|
||||
assert.equal(resolveConfirmOutcome({ control: "exit" }).kind, "exit");
|
||||
});
|
||||
|
||||
test("an unrecognized response never approves (kind: unknown)", () => {
|
||||
assert.equal(resolveConfirmOutcome({ id: "u1", control: "other" }).kind, "unknown");
|
||||
assert.equal(resolveConfirmOutcome({ id: "u1", choices: [] }).kind, "unknown");
|
||||
});
|
||||
Reference in New Issue
Block a user