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<Response>>` 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) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-11 00:28:24 +02:00
1 parent 2ce1a85622
commit 49c1a41c08
1 file changed
+12 -6
@@ -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<Response>)(
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<Response>)(
new Request("http://localhost/api/analytics"),
);
expect(response.status).toBe(200);
const envelope = (await response.json()) as AnalyticsEnvelope;