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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user