From 02e4f34a1b571b4b2015190480ca7875739d0d7f Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Thu, 4 Jun 2026 09:29:51 +0200 Subject: [PATCH] fix(web): vocab form-level error states, newVocabulary heading, id guard, EN-required test --- web/src/vocab/vocabularies.test.tsx | 15 +++++++++++++++ web/src/vocab/vocabulary-list.tsx | 6 ++++++ web/src/vocab/vocabulary-terms.tsx | 9 ++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/web/src/vocab/vocabularies.test.tsx b/web/src/vocab/vocabularies.test.tsx index 15eb2d6..9e7b30a 100644 --- a/web/src/vocab/vocabularies.test.tsx +++ b/web/src/vocab/vocabularies.test.tsx @@ -51,3 +51,18 @@ test("selecting a vocabulary shows its terms and adds one", async () => { expect((termBody as { labels: { label: string }[] })?.labels[0].label).toBe("Stone"), ); }); + +test("add term without EN label shows required alert and does not POST", async () => { + let posted = false; + server.use( + http.post("/api/admin/vocabularies/:id/terms", () => { + posted = true; + return HttpResponse.json({ id: "t-x" }, { status: 201 }); + }), + ); + renderApp(tree(), { route: "/vocabularies/v-material" }); + expect(await screen.findByText("Bronze")).toBeInTheDocument(); + await userEvent.click(screen.getByRole("button", { name: /add term/i })); + expect(screen.getByRole("alert")).toBeInTheDocument(); + expect(posted).toBe(false); +}); diff --git a/web/src/vocab/vocabulary-list.tsx b/web/src/vocab/vocabulary-list.tsx index 5d63f90..41e07d5 100644 --- a/web/src/vocab/vocabulary-list.tsx +++ b/web/src/vocab/vocabulary-list.tsx @@ -27,6 +27,7 @@ export function VocabularyList() { return (
+
{t("vocab.newVocabulary")}
+ {create.isError && ( +

+ {t("form.rejected")} +

+ )}