Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

test(api): cover custom research timeout signal

Karan Lokchandani9e3cab40c1cb
diff --git a/apps/api/src/lib/research-upstream.test.ts b/apps/api/src/lib/research-upstream.test.ts
index 40b58b437..fc246be27 100644
--- a/apps/api/src/lib/research-upstream.test.ts
+++ b/apps/api/src/lib/research-upstream.test.ts
@@ -44,6 +44,25 @@ describe("fetchResearchUpstream", () => {
);
});
+ it("uses a supplied operation timeout", async () => {
+ const signal = new AbortController().signal;
+ const timeout = vi.spyOn(AbortSignal, "timeout").mockReturnValue(signal);
+
+ await fetchResearchUpstream({
+ path: "/v2/research/papers",
+ params: { query: "graph databases" },
+ queryKeys: ["query"],
+ headers: {},
+ timeoutMs: 30_000,
+ });
+
+ expect(timeout).toHaveBeenCalledWith(30_000);
+ expect(mocks.fetch).toHaveBeenCalledWith(
+ new URL("https://research.test/v2/research/papers?query=graph+databases"),
+ expect.objectContaining({ signal }),
+ );
+ });
+
it("limits connection setup without dispatcher headers or body timeouts", () => {
expect(mocks.agent).toHaveBeenCalledWith({ connectTimeout: 10_000 });
});