test(frontend): cover ArtifactWidget view-only + multiselect allow_empty gate

This commit is contained in:
2026-06-28 12:40:09 +02:00
parent be9e761e0a
commit f933b544ff
2 changed files with 45 additions and 0 deletions
@@ -81,6 +81,30 @@ test("confirm is disabled when nothing checked and allow_empty is false", async
expect(onRespond).not.toHaveBeenCalled();
});
test("deselect-all with allow_empty false disables Conferma (empty confirm impossible)", async () => {
const onRespond = vi.fn();
render(
<MultiselectWidget
descriptor={{
id: "u1",
widget: "multiselect",
allow_empty: false,
options: [
{ id: "a", label: "Alpha", selected: true },
{ id: "b", label: "Beta", selected: true },
],
}}
onRespond={onRespond}
/>
);
const btn = screen.getByRole("button", { name: /conferma/i });
expect(btn).not.toBeDisabled();
await userEvent.click(screen.getByRole("button", { name: /deseleziona tutti/i }));
expect(btn).toBeDisabled();
await userEvent.click(btn);
expect(onRespond).not.toHaveBeenCalled();
});
test("confirm is enabled when allow_empty is false but something is checked", async () => {
const onRespond = vi.fn();
render(