test(medications): anchor inventory first-use date relative to now

The markAsFirstUseAt case hardcoded 2026-05-14, whose 30-day in-use window
lapses at noon UTC on 2026-06-13 — past that the expected state flips to
EXPIRED and the assertion fails. Anchor first-use to one day ago so the
window is always open relative to the run.
This commit is contained in:
Marc-André Bombeck committed 2026-06-13 16:08:53 +02:00
1 parent 9cf609bae2
commit 4c5dbf00ec
1 file changed
+5 -1
@@ -220,7 +220,11 @@ describe("PATCH /api/medications/[id]/inventory/[itemId]", () => {
state: "IN_USE",
} as never);
const intake = "2026-05-14T12:00:00Z";
// Anchor first-use to one day ago so the 30-day in-use window is
// always open relative to "now" — a previously hardcoded date
// (2026-05-14) silently aged past its window and flipped the expected
// state to EXPIRED once the wall clock crossed firstUseAt + 30 days.
const intake = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
const res = await PATCH(
jsonReq(
"http://localhost/api/medications/med-1/inventory/inv-1",