test(media): cover timeout request forwarding

This commit is contained in:
Ayaan Zaidi
2026-04-29 11:09:01 +05:30
parent 09a64bd77e
commit 47204a1db5
2 changed files with 13 additions and 1 deletions

View File

@@ -105,6 +105,7 @@ describe("createOllamaStreamFn thinking events", () => {
async function streamOllamaEvents(
chunks: Array<Record<string, unknown>>,
options: Parameters<ReturnType<typeof createOllamaStreamFn>>[2] = {},
): Promise<Array<{ type: string; [key: string]: unknown }>> {
const body = makeNdjsonBody(chunks);
fetchWithSsrFGuardMock.mockResolvedValue({
@@ -116,7 +117,7 @@ describe("createOllamaStreamFn thinking events", () => {
const stream = streamFn(
{ api: "ollama", provider: "ollama", id: "qwen3.5", contextWindow: 65536 } as never,
{ messages: [{ role: "user", content: "test" }] } as never,
{},
options,
);
const events: Array<{ type: string; [key: string]: unknown }> = [];
@@ -224,4 +225,14 @@ describe("createOllamaStreamFn thinking events", () => {
const textStart = events.find((e) => e.type === "text_start") as { contentIndex?: number };
expect(textStart?.contentIndex).toBe(0);
});
it("uses generic stream timeout for Ollama request timeout", async () => {
await streamOllamaEvents([makeOllamaResponse({ content: "ok" })], { timeoutMs: 2500 });
expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
expect.objectContaining({
timeoutMs: 2500,
}),
);
});
});

View File

@@ -551,6 +551,7 @@ describe("describeImageWithModel", () => {
await assertion;
const [, , options] = completeMock.mock.calls[0] ?? [];
expect(options?.signal?.aborted).toBe(true);
expect(options?.timeoutMs).toBe(25);
});
it("rejects when image runtime setup exceeds the request timeout", async () => {