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
adds vitests surrounding new components
Achintya Rajan679cf54c6e6e
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/teams/components/TeamsTable/YourRoleCell/TeamRoleBadge.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/teams/components/TeamsTable/YourRoleCell/TeamRoleBadge.test.tsxnew file mode 100644index 00000000000..b7e659403cb--- /dev/null+++ b/ui/litellm-dashboard/src/app/(dashboard)/teams/components/TeamsTable/YourRoleCell/TeamRoleBadge.test.tsx@@ -0,0 +1,38 @@+import React from "react";+import { describe, it, expect } from "vitest";+import { render, screen } from "@testing-library/react";+import "@testing-library/jest-dom";+import TeamRoleBadge from "./TeamRoleBadge";++const renderBadge = (role: string | null) => render(<div data-testid="wrap">{TeamRoleBadge(role)}</div>);++describe("TeamRoleBadge", () => {+ it("renders admin badge with correct label, base classes, styles, and an icon", () => {+ renderBadge("admin");+ const label = screen.getByText("Admin");+ const badge = label.closest("span")!;+ expect(badge).toHaveClass("inline-flex", "items-center", "border", "text-xs", "font-medium");+ expect(badge).toHaveStyle({+ backgroundColor: "#EEF2FF",+ color: "#3730A3",+ borderColor: "#C7D2FE",+ });+ expect(badge.querySelector("svg")).toBeInTheDocument(); // ShieldIcon renders as an SVG+ });++ it.each<[string | null]>([["user"], [null], ["viewer" as unknown as string]])(+ "renders member badge for non-admin role (%p) with correct styles",+ (role) => {+ renderBadge(role);+ const label = screen.getByText("Member");+ const badge = label.closest("span")!;+ expect(badge).toHaveClass("inline-flex", "items-center", "border", "text-xs", "font-medium");+ expect(badge).toHaveStyle({+ backgroundColor: "#F3F4F6",+ color: "#4B5563",+ borderColor: "#E5E7EB",+ });+ expect(badge.querySelector("svg")).toBeInTheDocument(); // UserIcon renders as an SVG+ },+ );+});diff --git a/ui/litellm-dashboard/src/app/(dashboard)/teams/components/TeamsTable/YourRoleCell/YourRoleCell.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/teams/components/TeamsTable/YourRoleCell/YourRoleCell.test.tsxnew file mode 100644index 00000000000..20a4497159d--- /dev/null+++ b/ui/litellm-dashboard/src/app/(dashboard)/teams/components/TeamsTable/YourRoleCell/YourRoleCell.test.tsx@@ -0,0 +1,43 @@+import React from "react";+import { describe, it, expect, vi } from "vitest";+import { render, screen } from "@testing-library/react";+import "@testing-library/jest-dom";+import type { Team } from "@/components/key_team_helpers/key_list";+import YourRoleCell from "./YourRoleCell";++// Lightweight mocks for stable, focused tests+vi.mock("@tremor/react", () => ({+ TableCell: ({ children }: { children: React.ReactNode }) => <div data-testid="cell">{children}</div>,+}));++// The component invokes TeamRoleBadge as a function, so mock it as such+vi.mock("@/app/(dashboard)/teams/components/TeamsTable/YourRoleCell/TeamRoleBadge", () => ({+ __esModule: true,+ default: (role: string | null) => <span data-testid="badge">{role === "admin" ? "Admin" : "Member"}</span>,+}));++const team = (members?: Array<{ user_id: string; role: "admin" | "user" }>): Team =>+ ({ members_with_roles: members }) as unknown as Team;++describe("YourRoleCell", () => {+ it("renders Admin when the user is an admin of the team", () => {+ render(<YourRoleCell team={team([{ user_id: "u1", role: "admin" }])} userId="u1" />);+ expect(screen.getByTestId("cell")).toBeInTheDocument();+ expect(screen.getByTestId("badge")).toHaveTextContent("Admin");+ });++ it("renders Member when the user is a regular member", () => {+ render(<YourRoleCell team={team([{ user_id: "u2", role: "user" }])} userId="u2" />);+ expect(screen.getByTestId("badge")).toHaveTextContent("Member");+ });++ it.each<[string, Team, string | null]>([+ ["userId is null", team([{ user_id: "u3", role: "admin" }]), null],+ ["user not in team", team([{ user_id: "x", role: "user" }]), "y"],+ ["team has no members", team([]), "u4"],+ ["members field undefined", team(undefined), "u5"],+ ])("falls back to Member when no role can be determined (%s)", (_label, t, uid) => {+ render(<YourRoleCell team={t} userId={uid} />);+ expect(screen.getByTestId("badge")).toHaveTextContent("Member");+ });+});