fix: T6 browser-check findings (compliance, treatments, labels)
- api-client accepts 2xx answers without body (revoke showed an error) - authority notices: sentOn in the future is rejected (Berlin day) on create, mark-sent and PATCH; dialog defaults to the Berlin day - service worker never caches /api/v1/site-settings - treatments/new no longer overflows at 390 px (min-w-0 on form wrappers); dose with more than 3 decimals is an error, never rounded - medicines: expired lots flagged, disposal over the rest warns - label designer: side panel at lg, sample values instead of placeholders, compliance panel reopens on lg, labelled zoom buttons - skip link to #main-content, headings on no-access pages Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
6c390efe7b
commit
e712c5d4d1
64 files changed
+1497
-323
No files matched your search
@@ -44,6 +44,33 @@ describe("api-client", () => {
|
||||
expect((apiError.body as { invalidColonyIds: string[] }).invalidColonyIds).toEqual(["c1"]);
|
||||
});
|
||||
|
||||
describe("empty success bodies", () => {
|
||||
it.each([200, 201, 202])("resolves undefined for a %i with an empty body", async (status) => {
|
||||
vi.stubGlobal("fetch", vi.fn().mockResolvedValue(new Response("", { status })));
|
||||
await expect(apiFetch("/x", { method: "POST" })).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("resolves undefined for a 204", async () => {
|
||||
vi.stubGlobal("fetch", vi.fn().mockResolvedValue(new Response(null, { status: 204 })));
|
||||
await expect(apiFetch("/x", { method: "POST" })).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("resolves undefined when Content-Length is 0", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn().mockResolvedValue(new Response("", { status: 201, headers: { "Content-Length": "0" } })),
|
||||
);
|
||||
await expect(apiFetch("/x", { method: "POST" })).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("still parses a JSON body and still rejects invalid JSON", async () => {
|
||||
vi.stubGlobal("fetch", vi.fn().mockResolvedValue(jsonResponse(201, { id: "a" })));
|
||||
await expect(apiFetch("/x", { method: "POST" })).resolves.toEqual({ id: "a" });
|
||||
vi.stubGlobal("fetch", vi.fn().mockResolvedValue(new Response("<html>", { status: 200 })));
|
||||
await expect(apiFetch("/x")).rejects.toBeInstanceOf(SyntaxError);
|
||||
});
|
||||
});
|
||||
|
||||
it("reports network-error on a failed fetch and reached-server on any HTTP answer", async () => {
|
||||
vi.stubGlobal("fetch", vi.fn().mockRejectedValue(new TypeError("Failed to fetch")));
|
||||
await expect(apiFetch("/x")).rejects.toBeInstanceOf(TypeError);
|
||||
|
||||
Reference in new issue
Block a user