The interface is now fully English regardless of the chat language (session titles stay in whatever language the user typed). Changed the right-rail subtitle to 'Datamart Builder with Human In The Loop'. Translated all chrome: new-question/settings dialogs, workflow phase strip (F1-F8), session rail, steer input, widgets (select/multiselect/freetext/fallback/reserved controls) and viewers (SQL, results, schema linking). Test matchers updated in lockstep. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { ArtifactGateWidget } from "./ArtifactGateWidget";
|
|
|
|
test("reject opens a freetext and combines the reason", async () => {
|
|
const onRespond = vi.fn();
|
|
render(
|
|
<ArtifactGateWidget
|
|
descriptor={{
|
|
id: "u1",
|
|
widget: "artifact-gate",
|
|
artifact: { kind: "cte", content: "SELECT 1" },
|
|
options: [
|
|
{ id: "approve", label: "Approva" },
|
|
{
|
|
id: "reject",
|
|
label: "Rifiuta",
|
|
opens: { id: "u1c", widget: "freetext", title: "Motivazione" },
|
|
},
|
|
],
|
|
}}
|
|
onRespond={onRespond}
|
|
/>
|
|
);
|
|
await userEvent.click(screen.getByRole("button", { name: /Rifiuta/ }));
|
|
await userEvent.type(screen.getByRole("textbox"), "join sbagliata");
|
|
await userEvent.click(screen.getByRole("button", { name: /send/i }));
|
|
expect(onRespond).toHaveBeenCalledWith({
|
|
id: "u1",
|
|
kind: "artifact-gate",
|
|
choices: ["reject"],
|
|
text: "join sbagliata",
|
|
});
|
|
});
|
|
|
|
test("approve (no opens) responds immediately without child widget", async () => {
|
|
const onRespond = vi.fn();
|
|
render(
|
|
<ArtifactGateWidget
|
|
descriptor={{
|
|
id: "u1",
|
|
widget: "artifact-gate",
|
|
artifact: { kind: "cte", content: "SELECT 1" },
|
|
options: [
|
|
{ id: "approve", label: "Approva" },
|
|
{
|
|
id: "reject",
|
|
label: "Rifiuta",
|
|
opens: { id: "u1c", widget: "freetext", title: "Motivazione" },
|
|
},
|
|
],
|
|
}}
|
|
onRespond={onRespond}
|
|
/>
|
|
);
|
|
await userEvent.click(screen.getByRole("button", { name: /Approva/ }));
|
|
expect(onRespond).toHaveBeenCalledWith({ id: "u1", kind: "artifact-gate", choices: ["approve"] });
|
|
// No textbox should appear
|
|
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
|
|
});
|