fix(gate): buildArtifactGate emits approve/reject options so the gate renders a forward button
This commit is contained in:
@@ -159,3 +159,28 @@ test("artifact-gate with unknown action kind throws clearly", () => {
|
|||||||
/action/i,
|
/action/i,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("buildArtifactGate derives approve/reject options from action.kind", () => {
|
||||||
|
const w = buildArtifactGate({
|
||||||
|
id: "u1",
|
||||||
|
phase: "F1",
|
||||||
|
title: "Chiudi fase",
|
||||||
|
artifact: { kind: "phase", data: {} },
|
||||||
|
action: { kind: "approve_reject" },
|
||||||
|
});
|
||||||
|
assert.deepEqual(w.options, [
|
||||||
|
{ id: "approve", label: "Conferma e prosegui", recommended: true },
|
||||||
|
{ id: "reject", label: "Rifiuta" },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("buildArtifactGate: confirm -> single approve; view_only -> no options", () => {
|
||||||
|
const confirm = buildArtifactGate({
|
||||||
|
id: "u1", phase: "F1", title: "t", artifact: { kind: "phase", data: {} }, action: { kind: "confirm" },
|
||||||
|
});
|
||||||
|
assert.deepEqual(confirm.options, [{ id: "approve", label: "Conferma e prosegui", recommended: true }]);
|
||||||
|
const viewOnly = buildArtifactGate({
|
||||||
|
id: "u1", phase: "F1", title: "t", artifact: { kind: "phase", data: {} }, action: { kind: "view_only" },
|
||||||
|
});
|
||||||
|
assert.deepEqual(viewOnly.options, []);
|
||||||
|
});
|
||||||
|
|||||||
@@ -112,6 +112,14 @@ function buildArtifactGate({ id, phase, title, artifact, action }) {
|
|||||||
`builders: artifact-gate action.kind must be one of ${[...VALID_ACTION_KINDS].join(", ")}`,
|
`builders: artifact-gate action.kind must be one of ${[...VALID_ACTION_KINDS].join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const ACTION_OPTIONS = {
|
||||||
|
approve_reject: [
|
||||||
|
{ id: "approve", label: "Conferma e prosegui", recommended: true },
|
||||||
|
{ id: "reject", label: "Rifiuta" },
|
||||||
|
],
|
||||||
|
confirm: [{ id: "approve", label: "Conferma e prosegui", recommended: true }],
|
||||||
|
view_only: [],
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
type: "ui_request",
|
type: "ui_request",
|
||||||
id,
|
id,
|
||||||
@@ -121,6 +129,7 @@ function buildArtifactGate({ id, phase, title, artifact, action }) {
|
|||||||
title,
|
title,
|
||||||
artifact,
|
artifact,
|
||||||
action,
|
action,
|
||||||
|
options: ACTION_OPTIONS[action.kind],
|
||||||
reserved: RESERVED,
|
reserved: RESERVED,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user