fix: return 400 on invalid tag/album payload
This commit is contained in:
@@ -100,6 +100,14 @@ test("albums POST inserts and writes audit log", async () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("albums POST rejects invalid body", async () => {
|
||||
const { handleCreateAlbum } = await import("../../app/api/albums/handlers");
|
||||
const res = await handleCreateAlbum({ adminOk: true, body: { name: "" } });
|
||||
expect(res.status).toBe(400);
|
||||
expect(res.body).toMatchObject({ error: "invalid_body" });
|
||||
expect(Array.isArray((res.body as { issues?: unknown }).issues)).toBe(true);
|
||||
});
|
||||
|
||||
test("album add asset inserts and writes audit log", async () => {
|
||||
const { handleAddAlbumAsset } = await import(
|
||||
"../../app/api/albums/handlers"
|
||||
|
||||
@@ -73,3 +73,11 @@ test("tags POST inserts and writes audit log", async () => {
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("tags POST rejects invalid body", async () => {
|
||||
const { handleCreateTag } = await import("../../app/api/tags/handlers");
|
||||
const res = await handleCreateTag({ adminOk: true, body: { name: "" } });
|
||||
expect(res.status).toBe(400);
|
||||
expect(res.body).toMatchObject({ error: "invalid_body" });
|
||||
expect(Array.isArray((res.body as { issues?: unknown }).issues)).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user