From db2c70a78d59844e1fcb5d13a4b717b12321d277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 21 May 2026 11:23:17 +0200 Subject: [PATCH] test(medications): pin skipDuplicates flag on intake-route backfill The W-SERVER-FIX-2 race-guard work added `skipDuplicates: true` to the intake route's projection-backfill createMany alongside the schema @@unique([userId, medicationId, scheduledFor, source]) constraint. The existing unit test asserted the row shape but not the flag, so a regression that drops `skipDuplicates: true` while keeping the unique constraint would surface as a 5xx in prod (constraint violation bubbles through) without breaking the suite. Adds the flag to the `toMatchObject` assertion so the defense-in-depth contract stays pinned next to the row shape it pairs with. Matches the equivalent assertion the dashboard summary test already carries. --- src/app/api/medications/intake/__tests__/route.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/api/medications/intake/__tests__/route.test.ts b/src/app/api/medications/intake/__tests__/route.test.ts index f1fc4fc75..9bf740a29 100644 --- a/src/app/api/medications/intake/__tests__/route.test.ts +++ b/src/app/api/medications/intake/__tests__/route.test.ts @@ -201,6 +201,15 @@ describe("GET /api/medications/intake", () => { source: "REMINDER", }, ], + // v1.4.39 W-SERVER-FIX-2 — the createMany must ship + // `skipDuplicates: true` so a concurrent dashboard-summary hit + // can't race a duplicate `(userId, medicationId, scheduledFor, + // REMINDER)` row in between this route's existence probe and + // insert. The schema-level @@unique([userId, medicationId, + // scheduledFor, source]) is the structural backstop; this flag + // is the defense-in-depth that keeps the route returning 2xx + // when the constraint rejects the second mint. + skipDuplicates: true, }); });