fix: return 400 on invalid tag/album payload

This commit is contained in:
William Valentin
2026-02-01 18:01:25 -08:00
parent 51aba941d6
commit e455425d2e
4 changed files with 34 additions and 2 deletions

View File

@@ -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"

View File

@@ -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);
});