From 384179228a1edf55fbe9609824c0f98a490dff66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 17 May 2026 12:47:33 +0200 Subject: [PATCH] test(analytics): seed rollup-count probe in slim-slice route test v1.4.36's perf wave added a `SELECT COUNT(*) FROM measurement_rollups` probe at the head of `computeSummariesSlice`. The slim-slice route test mocks `$queryRaw` with two `mockResolvedValueOnce` calls (aggregate + latest); the new probe consumed the first slot, leaving the aggregate read pointing at undefined and the route returning 500. Seed `n: BigInt(0)` as the first mock value so the route deterministically takes the legacy heavy-aggregate fallback path the rest of the test expects. --- src/app/api/analytics/__tests__/route.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/api/analytics/__tests__/route.test.ts b/src/app/api/analytics/__tests__/route.test.ts index 3ed5b35ee..a3d3d2ba5 100644 --- a/src/app/api/analytics/__tests__/route.test.ts +++ b/src/app/api/analytics/__tests__/route.test.ts @@ -266,8 +266,12 @@ describe("GET /api/analytics", () => { // contract the dashboard tile strip reads. it("returns the slim summaries slice when ?slice=summaries is set", async () => { const fiveDaysAgo = new Date(Date.now() - 5 * 24 * 60 * 60 * 1000); - // Aggregate pass + latest pass. The mock returns one row per pass. + // v1.4.36 — slim slice now opens with a cheap `SELECT COUNT(*) FROM + // measurement_rollups` probe. Force `n: 0` so the route takes the + // legacy heavy-aggregate fallback path that this test's fixtures + // expect (aggregate + latest, two `$queryRaw` passes). vi.mocked(prisma.$queryRaw) + .mockResolvedValueOnce([{ n: BigInt(0) }] as never) .mockResolvedValueOnce([ { type: "WEIGHT",