feat(web): highlight the offending field on a set_fields 422 (#28)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 15:39:49 +02:00
parent d6dc1c9b57
commit 0c9db7bcdb
7 changed files with 73 additions and 12 deletions
+20
View File
@@ -17,6 +17,26 @@ function tree() {
);
}
test("edit: fields PUT 422 with field body -> field error message shown and field marked invalid", async () => {
server.use(
http.get("/api/admin/objects/:id", () =>
HttpResponse.json({ ...amphora, fields: { inscription: "old" } }),
),
http.put("/api/admin/objects/:id", () => new HttpResponse(null, { status: 204 })),
http.put("/api/admin/objects/:id/fields", () =>
HttpResponse.json({ field: "inscription", code: "type_mismatch" }, { status: 422 }),
),
);
renderApp(tree(), { route: `/objects/${amphora.id}/edit` });
await screen.findByDisplayValue("Amphora");
await userEvent.click(screen.getByRole("button", { name: /save/i }));
const alerts = await screen.findAllByText(/inscription.*rejected/i);
expect(alerts.length).toBeGreaterThanOrEqual(2);
});
test("edit: prefilled, save -> PUT core + PUT fields -> back to detail", async () => {
let putCore: unknown;
let putFields: unknown;