Skip to content

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]

test(ui): pin the placeholder branch alongside the label branch

Yuneng Jiang48986da99c1f
diff --git a/ui/litellm-dashboard/src/components/ui/select.test.tsx b/ui/litellm-dashboard/src/components/ui/select.test.tsx
index 2bba4281589..15dd266d38c 100644
--- a/ui/litellm-dashboard/src/components/ui/select.test.tsx
+++ b/ui/litellm-dashboard/src/components/ui/select.test.tsx
@@ -7,11 +7,15 @@ const ENVIRONMENTS = [
{ value: "staging", label: "Staging" },
] as const;
-function renderSelect(props: { value: string | null; items?: React.ComponentProps<typeof Select>["items"] }) {
+function renderSelect(props: {
+ value: string | null;
+ items?: React.ComponentProps<typeof Select>["items"];
+ placeholder?: string;
+}) {
return render(
<Select value={props.value} items={props.items}>
<SelectTrigger data-testid="trigger">
- <SelectValue />
+ <SelectValue placeholder={props.placeholder} />
</SelectTrigger>
<SelectContent>
{ENVIRONMENTS.map((environment) => (
@@ -42,4 +46,20 @@ describe("SelectValue label resolution", () => {
expect(screen.getByTestId("trigger")).toHaveTextContent("production");
});
+
+ it("still renders the placeholder when nothing is selected", () => {
+ renderSelect({ value: null, items: ENVIRONMENTS, placeholder: "Pick an environment" });
+
+ expect(screen.getByTestId("trigger")).toHaveTextContent("Pick an environment");
+ });
+
+ it("lets a null-valued item's label win over the placeholder", () => {
+ renderSelect({
+ value: null,
+ items: [{ value: null, label: "Any environment" }, ...ENVIRONMENTS],
+ placeholder: "Pick an environment",
+ });
+
+ expect(screen.getByTestId("trigger")).toHaveTextContent("Any environment");
+ });
});