test(collection-map): cover assigned_at clear on unassign

This commit is contained in:
SJCoetz 2026-07-10 00:49:36 +02:00
parent 5ce3ef1000
commit 1846e86b9e

View file

@ -96,4 +96,23 @@ describe("PATCH /api/v1/collection-map/items/[id]/assign", () => {
// The unmark path must not silently overwrite the existing note.
expect(payload.notes).toBeUndefined();
});
it("clears assigned_at when returning an item to the pool (no driverId)", async () => {
getOneMock.mockResolvedValueOnce({
id: "item-1",
assigned_at: "2026-07-09T00:00:00.000Z",
});
updateMock.mockResolvedValueOnce({ id: "item-1" });
const res = await PATCH(
makeReq({ date: "" }),
{ params: Promise.resolve({ id: "item-1" }) },
);
expect(res.status).toBe(200);
const payload = updateMock.mock.calls[0][1] as Record<string, unknown>;
expect(payload.assigned_at).toBe("");
expect(payload.item_status).toBe("collection_pool");
expect(payload.drv_status).toBe("unassigned");
});
});