From 3458100ac4d3e6848391504c15461652ed2c9921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 27 Sep 2026 21:16:20 +0200 Subject: [PATCH] test: give the report's pulse-window count a mock and a typed route call --- src/app/api/export/health-record/__tests__/route.test.ts | 3 ++- tests/integration/dense-pulse-raw-window-reads.test.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/api/export/health-record/__tests__/route.test.ts b/src/app/api/export/health-record/__tests__/route.test.ts index 664e6fc4f..29d5fe949 100644 --- a/src/app/api/export/health-record/__tests__/route.test.ts +++ b/src/app/api/export/health-record/__tests__/route.test.ts @@ -19,7 +19,8 @@ import { unzipSync } from "fflate"; vi.mock("@/lib/db", () => ({ prisma: { - measurement: { findMany: vi.fn() }, + // `count` sizes the report's pulse window (#1023): a sparse account. + measurement: { findMany: vi.fn(), count: vi.fn(async () => 0) }, medication: { findMany: vi.fn() }, medicationIntakeEvent: { findMany: vi.fn() }, moodEntry: { findMany: vi.fn() }, diff --git a/tests/integration/dense-pulse-raw-window-reads.test.ts b/tests/integration/dense-pulse-raw-window-reads.test.ts index 1ff3d0398..b613840db 100644 --- a/tests/integration/dense-pulse-raw-window-reads.test.ts +++ b/tests/integration/dense-pulse-raw-window-reads.test.ts @@ -147,7 +147,9 @@ describe("resting-pulse proxy folded in Postgres", () => { const spy = vi.spyOn(prisma.measurement, "findMany"); try { const { GET } = await import("@/app/api/insights/comprehensive/route"); - const res = await GET( + // The route reads no request field, so its handler is typed without one. + const callGet = GET as unknown as (req: NextRequest) => Promise; + const res = await callGet( new NextRequest("http://localhost/api/insights/comprehensive"), ); expect(res.status).toBe(200);