From 5d48c472b193384bff68bd1e1ae7b708cc6125bb Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Tue, 8 Sep 2026 16:03:34 -0700 Subject: [PATCH] fix(ui): align SDK mocks and remaining dependency patches (cherry picked from commit bc8305810ff9bd465f464a7efd0abbaae46e3250) --- .../llm_calls/anthropic_messages.test.tsx | 4 +++- .../playground/llm_calls/audio_speech.test.tsx | 14 ++++++++------ .../llm_calls/audio_transcriptions.test.tsx | 14 ++++++++------ .../components/llm_calls/chat_completion.test.tsx | 4 +++- .../components/llm_calls/responses_api.test.tsx | 4 +++- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/anthropic_messages.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/anthropic_messages.test.tsx index 995104d4b7f..96ace129f87 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/anthropic_messages.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/anthropic_messages.test.tsx @@ -9,7 +9,9 @@ vi.mock("@/components/networking", () => ({ const mockMessagesStream = vi.fn(); vi.mock("@anthropic-ai/sdk", () => ({ - default: vi.fn(() => ({ messages: { stream: mockMessagesStream } })), + default: vi.fn(function () { + return { messages: { stream: mockMessagesStream } }; + }), })); describe("anthropic_messages prompt cache usage", () => { diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_speech.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_speech.test.tsx index dbfe8a39959..17f5d0f28a4 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_speech.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_speech.test.tsx @@ -20,13 +20,15 @@ describe("audio_speech", () => { }); // Mock the OpenAI constructor and its methods - (OpenAI as any).mockImplementation(() => ({ - audio: { - speech: { - create: mockCreate, + (OpenAI as any).mockImplementation(function () { + return { + audio: { + speech: { + create: mockCreate, + }, }, - }, - })); + }; + }); }); afterEach(() => { diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_transcriptions.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_transcriptions.test.tsx index 65b11e7f7d8..52561e5d42e 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_transcriptions.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/llm_calls/audio_transcriptions.test.tsx @@ -16,13 +16,15 @@ describe("audio_transcription", () => { }); // Mock the OpenAI constructor and its methods - (OpenAI as any).mockImplementation(() => ({ - audio: { - transcriptions: { - create: mockCreate, + (OpenAI as any).mockImplementation(function () { + return { + audio: { + transcriptions: { + create: mockCreate, + }, }, - }, - })); + }; + }); }); afterEach(() => { diff --git a/ui/litellm-dashboard/src/components/llm_calls/chat_completion.test.tsx b/ui/litellm-dashboard/src/components/llm_calls/chat_completion.test.tsx index bc4b4e3a351..08b02cacb21 100644 --- a/ui/litellm-dashboard/src/components/llm_calls/chat_completion.test.tsx +++ b/ui/litellm-dashboard/src/components/llm_calls/chat_completion.test.tsx @@ -20,7 +20,9 @@ const mockClient = { vi.mock("openai", () => ({ default: { - OpenAI: vi.fn(() => mockClient), + OpenAI: vi.fn(function () { + return mockClient; + }), }, })); diff --git a/ui/litellm-dashboard/src/components/llm_calls/responses_api.test.tsx b/ui/litellm-dashboard/src/components/llm_calls/responses_api.test.tsx index 0b94c093acd..ae5e224cfbf 100644 --- a/ui/litellm-dashboard/src/components/llm_calls/responses_api.test.tsx +++ b/ui/litellm-dashboard/src/components/llm_calls/responses_api.test.tsx @@ -16,7 +16,9 @@ const mockClient = { vi.mock("openai", () => ({ default: { - OpenAI: vi.fn(() => mockClient), + OpenAI: vi.fn(function () { + return mockClient; + }), }, }));