fix(ui): align SDK mocks and remaining dependency patches

(cherry picked from commit bc8305810f)
This commit is contained in:
Yuneng Jiang 2026-09-08 16:03:34 -07:00
parent 3f1c0bd573
commit 5d48c472b1
No known key found for this signature in database
5 changed files with 25 additions and 15 deletions

View file

@ -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", () => {

View file

@ -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(() => {

View file

@ -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(() => {

View file

@ -20,7 +20,9 @@ const mockClient = {
vi.mock("openai", () => ({
default: {
OpenAI: vi.fn(() => mockClient),
OpenAI: vi.fn(function () {
return mockClient;
}),
},
}));

View file

@ -16,7 +16,9 @@ const mockClient = {
vi.mock("openai", () => ({
default: {
OpenAI: vi.fn(() => mockClient),
OpenAI: vi.fn(function () {
return mockClient;
}),
},
}));