From 49c1a41c084550810c61e3182adda437c15be1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 11 May 2026 00:28:24 +0200 Subject: [PATCH] test: cast analytics GET handler in sleep-stages integration test The W2 commit shipped with `as never` casts on the request + params arguments, which let the runtime test pass but failed strict tsc because `apiHandler<() => Promise>` narrows the wrapper's signature down to its inner handler's. Cast through `unknown` so the wrapper-side `request.url` read works and tsc is satisfied. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../integration/analytics-sleep-stages.test.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/integration/analytics-sleep-stages.test.ts b/tests/integration/analytics-sleep-stages.test.ts index d79a0979f..c50f25b7b 100644 --- a/tests/integration/analytics-sleep-stages.test.ts +++ b/tests/integration/analytics-sleep-stages.test.ts @@ -124,9 +124,12 @@ describe("GET /api/analytics — sleep-stage aggregation", () => { } const { GET } = await import("@/app/api/analytics/route"); - const response = await GET( - new Request("http://localhost/api/analytics") as never, - { params: Promise.resolve({}) } as never, + // The wrapped handler reads `request.url` for logging metadata; + // the inner handler ignores its arguments. Cast through `unknown` + // because `apiHandler`'s narrowed type signature is the inner + // handler's `()`, not the wrapper's `(NextRequest)`. + const response = await (GET as unknown as (req: Request) => Promise)( + new Request("http://localhost/api/analytics"), ); expect(response.status).toBe(200); const envelope = (await response.json()) as AnalyticsEnvelope; @@ -166,9 +169,12 @@ describe("GET /api/analytics — sleep-stage aggregation", () => { }); const { GET } = await import("@/app/api/analytics/route"); - const response = await GET( - new Request("http://localhost/api/analytics") as never, - { params: Promise.resolve({}) } as never, + // The wrapped handler reads `request.url` for logging metadata; + // the inner handler ignores its arguments. Cast through `unknown` + // because `apiHandler`'s narrowed type signature is the inner + // handler's `()`, not the wrapper's `(NextRequest)`. + const response = await (GET as unknown as (req: Request) => Promise)( + new Request("http://localhost/api/analytics"), ); expect(response.status).toBe(200); const envelope = (await response.json()) as AnalyticsEnvelope;