test(collection-map): cover assigned_at clear on unassign
This commit is contained in:
parent
5ce3ef1000
commit
1846e86b9e
1 changed files with 19 additions and 0 deletions
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue