test(chat): import the route statically so a loaded run cannot time out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DEls 2026-09-26 09:55:18 +02:00
parent 774eaca13f
commit 1dbe719e2c

View file

@ -1,6 +1,10 @@
import { describe, expect, it, vi } from "vitest";
import type { ChatProvider, RunTurnArgs } from "@/lib/chat";
import type { ChartSpec } from "@/lib/reports/chart-spec";
// Static import (vi.mock is hoisted above it): loading the route pulls in
// the provider SDKs, which is slow under a parallel run and must count
// as collection, not test time.
import { POST } from "./route";
const spec: ChartSpec = {
id: "site-weekly",
@ -44,7 +48,6 @@ vi.mock("@/lib/chat", async (importOriginal) => {
describe("POST /api/chat", () => {
it("streams chart specs to the browser and only ids/titles to the model", async () => {
const { POST } = await import("./route");
const res = await POST(
new Request("http://test/api/chat", {
method: "POST",