diff --git a/web/src/app/api/requests/route.test.ts b/web/src/app/api/requests/route.test.ts index fb74e88..753b76f 100644 --- a/web/src/app/api/requests/route.test.ts +++ b/web/src/app/api/requests/route.test.ts @@ -25,6 +25,26 @@ describe("requests API", () => { expect(res.status).toBe(400); }); + it("rejects a malformed JSON body", async () => { + const req = new Request("http://localhost/api/requests", { + method: "POST", + headers: { "content-type": "application/json" }, + body: "{not json", + }); + const res = await POST(req); + expect(res.status).toBe(400); + }); + + it("rejects an empty/whitespace-only artist", async () => { + const res = await POST(postReq({ artist: " ", album: "X" })); + expect(res.status).toBe(400); + }); + + it("rejects a non-string artist field", async () => { + const res = await POST(postReq({ artist: 123, album: "X" })); + expect(res.status).toBe(400); + }); + it("lists requests newest first with job state", async () => { await POST(postReq({ artist: "A", album: "1" })); await POST(postReq({ artist: "B", album: "2" }));