From 1f5f37444f063106692de38c4be05cc5d84e384f Mon Sep 17 00:00:00 2001 From: devarakondasrikanth Date: Tue, 31 Mar 2026 14:05:33 -0700 Subject: [PATCH] test(ui): add vllm reasoning object and timing coverage --- .../llm_calls/chat_completion.test.tsx | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/ui/litellm-dashboard/src/components/playground/llm_calls/chat_completion.test.tsx b/ui/litellm-dashboard/src/components/playground/llm_calls/chat_completion.test.tsx index a2b07ed99e1..daa7c2523f7 100644 --- a/ui/litellm-dashboard/src/components/playground/llm_calls/chat_completion.test.tsx +++ b/ui/litellm-dashboard/src/components/playground/llm_calls/chat_completion.test.tsx @@ -312,4 +312,62 @@ describe("chat_completion", () => { expect(onReasoningContent).toHaveBeenCalledWith("step 1 step 2"); }); + + it("should support object-typed `reasoning` delta", async () => { + const onReasoningContent = vi.fn(); + const mockChunks = [ + { + choices: [{ delta: { reasoning: { text: "inner thought" } }, index: 0 }], + model: "qwen3.5", + }, + ]; + async function* mockStream() { + for (const chunk of mockChunks) { + yield chunk; + } + } + mockCreate.mockResolvedValueOnce(mockStream()); + + await makeOpenAIChatCompletionRequest( + mockChatHistory, + mockUpdateUI, + "qwen3.5", + "test-token", + undefined, + undefined, + onReasoningContent, + ); + + expect(onReasoningContent).toHaveBeenCalledWith("inner thought"); + }); + + it("should trigger first-token timing when reasoning field arrives", async () => { + const onTimingData = vi.fn(); + const mockChunks = [ + { + choices: [{ delta: { reasoning: "thinking..." }, index: 0 }], + model: "qwen3.5", + }, + ]; + async function* mockStream() { + for (const chunk of mockChunks) { + yield chunk; + } + } + mockCreate.mockResolvedValueOnce(mockStream()); + + await makeOpenAIChatCompletionRequest( + mockChatHistory, + mockUpdateUI, + "qwen3.5", + "test-token", + undefined, + undefined, + undefined, + onTimingData, + ); + + expect(onTimingData).toHaveBeenCalledTimes(1); + expect(onTimingData).toHaveBeenCalledWith(expect.any(Number)); + }); });