test: give the report's pulse-window count a mock and a typed route call

This commit is contained in:
Marc-André Bombeck committed 2026-09-27 21:16:20 +02:00
1 parent 0e991c3640
commit 3458100ac4
2 files changed
+5 -2

No files matched your search

@@ -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() },
@@ -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<Response>;
const res = await callGet(
new NextRequest("http://localhost/api/insights/comprehensive"),
);
expect(res.status).toBe(200);