The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(ui): characterize TokenFlow and JsonViewer
Yuneng Jiang89d503778026
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/JsonViewer.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/JsonViewer.test.tsxnew file mode 100644index 00000000000..055e400167b--- /dev/null+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/JsonViewer.test.tsx@@ -0,0 +1,28 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it } from "vitest";+import { JsonViewer } from "./JsonViewer";++describe("JsonViewer", () => {+ it("should render a placeholder and no tree when the log entry carries no payload", () => {+ render(<JsonViewer data={null} mode="formatted" />);++ expect(screen.getByText("No data")).toBeInTheDocument();+ expect(screen.queryByRole("tree")).not.toBeInTheDocument();+ });++ it("should render the payload as a tree exposing its keys", () => {+ render(<JsonViewer data={{ model: "claude-opus-4-5", stream: true }} mode="formatted" />);++ expect(screen.getByRole("tree")).toBeInTheDocument();+ expect(screen.getByText(/model/)).toBeInTheDocument();+ expect(screen.getByText(/stream/)).toBeInTheDocument();+ expect(screen.queryByText("No data")).not.toBeInTheDocument();+ });++ it("should treat an empty payload as data rather than showing the placeholder", () => {+ render(<JsonViewer data={{}} mode="formatted" />);++ expect(screen.getByRole("tree")).toBeInTheDocument();+ expect(screen.queryByText("No data")).not.toBeInTheDocument();+ });+});diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/TokenFlow.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/TokenFlow.test.tsxnew file mode 100644index 00000000000..f1784bb4009--- /dev/null+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/TokenFlow.test.tsx@@ -0,0 +1,23 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it } from "vitest";+import { TokenFlow } from "./TokenFlow";++describe("TokenFlow", () => {+ it("should render the total followed by its prompt and completion breakdown", () => {+ render(<TokenFlow prompt={9} completion={3} total={12} />);++ expect(screen.getByText("12 (9 prompt tokens + 3 completion tokens)")).toBeInTheDocument();+ });++ it("should group large counts with thousands separators", () => {+ render(<TokenFlow prompt={1234567} completion={89012} total={1323579} />);++ expect(screen.getByText("1,323,579 (1,234,567 prompt tokens + 89,012 completion tokens)")).toBeInTheDocument();+ });++ it("should fall back to zero for counts the log entry does not carry", () => {+ render(<TokenFlow total={12} />);++ expect(screen.getByText("12 (0 prompt tokens + 0 completion tokens)")).toBeInTheDocument();+ });+});