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): drop test commentary and assert the normalized org-admin denial

Yuneng Jiangd554450f6292
diff --git a/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx b/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx
index d1eb7e7f4b1..5071fe6ff95 100644
--- a/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx
+++ b/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx
@@ -812,11 +812,7 @@ describe("CreateKey", () => {
openModal();
- // The modal still renders the rest of the advanced settings, so a missing
- // selector is a real omission rather than an un-rendered tree.
- await waitFor(() => {
- expect(screen.getByTestId("org-dropdown")).toBeInTheDocument();
- });
+ expect(await screen.findByTestId("org-dropdown")).toBeInTheDocument();
expect(getPoliciesList).not.toHaveBeenCalled();
expect(getPromptsList).not.toHaveBeenCalled();
diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
index be17c5de903..10f98ba4bfb 100644
--- a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
@@ -637,6 +637,8 @@ describe("TeamInfoView", () => {
});
describe("settings and editing", () => {
+ const policiesFormFieldLabel = () => screen.queryByText("Policies", { selector: "span" });
+
it("should offer the policies field and load it for a caller with the viewPolicies capability", async () => {
const user = userEvent.setup({ delay: null });
vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData());
@@ -651,10 +653,8 @@ describe("TeamInfoView", () => {
await user.click(screen.getByRole("tab", { name: "Settings" }));
await user.click(await screen.findByRole("button", { name: /edit settings/i }));
- // `selector` skips the read-only Policies card, which renders the team's own
- // policy names from team info and needs no admin list.
await waitFor(() => {
- expect(screen.getByText("Policies", { selector: "span" })).toBeInTheDocument();
+ expect(policiesFormFieldLabel()).toBeInTheDocument();
});
});
@@ -668,13 +668,10 @@ describe("TeamInfoView", () => {
await user.click(await screen.findByRole("tab", { name: "Settings" }));
await user.click(await screen.findByRole("button", { name: /edit settings/i }));
- // Team Name proves the edit form rendered, so a missing Policies field is a real omission.
- await waitFor(() => {
- expect(screen.getByLabelText("Team Name")).toBeInTheDocument();
- });
+ expect(await screen.findByLabelText("Team Name")).toBeInTheDocument();
expect(networking.getPoliciesList).not.toHaveBeenCalled();
- expect(screen.queryByText("Policies", { selector: "span" })).not.toBeInTheDocument();
+ expect(policiesFormFieldLabel()).not.toBeInTheDocument();
});
it("should open edit mode when edit button is clicked", async () => {
diff --git a/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx b/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx
index 4cf62b36f1f..ad845cd6d10 100644
--- a/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx
@@ -6,9 +6,6 @@ import { KeyResponse } from "../key_team_helpers/key_list";
import { getPoliciesList, getPromptsList, modelAvailableCall } from "../networking";
import { KeyEditView } from "./key_edit_view";
-// PolicySelector gates itself on the session capability; in this bare template
-// render there is no session, so stub the hook to an admin to keep the selector
-// mounted and prove the gate under test is KeyEditView's own.
const can = vi.fn();
vi.mock("@/app/(dashboard)/hooks/useCan", () => ({
default: (...args: unknown[]) => can(...args),
@@ -250,7 +247,6 @@ describe("KeyEditView", () => {
it("should omit both fields and fire neither admin-only request for an internal user", async () => {
renderAs("Internal User");
- // Models still loads, so the form really rendered and the fields are absent by gate.
await waitFor(() => {
expect(modelAvailableCall).toHaveBeenCalled();
});
diff --git a/ui/litellm-dashboard/src/utils/capabilities.test.ts b/ui/litellm-dashboard/src/utils/capabilities.test.ts
index a19e851f873..1da47e29bdc 100644
--- a/ui/litellm-dashboard/src/utils/capabilities.test.ts
+++ b/ui/litellm-dashboard/src/utils/capabilities.test.ts
@@ -17,33 +17,41 @@ describe("hasCapability", () => {
},
);
- it.each(["Admin", "Admin Viewer", "proxy_admin", "proxy_admin_viewer", "org_admin"])(
- "should grant viewPolicies to %s",
- (role) => {
- expect(hasCapability(role, "viewPolicies")).toBe(true);
- },
- );
+ it.each(["Admin", "Admin Viewer", "proxy_admin", "proxy_admin_viewer"])("should grant viewPolicies to %s", (role) => {
+ expect(hasCapability(role, "viewPolicies")).toBe(true);
+ });
- it.each(["Internal User", "Internal Viewer", "internal_user", "App User", "Unknown Role", "", null, undefined])(
- "should deny viewPolicies to %s",
- (role) => {
- expect(hasCapability(role, "viewPolicies")).toBe(false);
- },
- );
+ it.each([
+ "Internal User",
+ "Internal Viewer",
+ "internal_user",
+ "App User",
+ "Org Admin",
+ "Unknown Role",
+ "",
+ null,
+ undefined,
+ ])("should deny viewPolicies to %s", (role) => {
+ expect(hasCapability(role, "viewPolicies")).toBe(false);
+ });
- it.each(["Admin", "Admin Viewer", "proxy_admin", "proxy_admin_viewer", "org_admin"])(
- "should grant viewPrompts to %s",
- (role) => {
- expect(hasCapability(role, "viewPrompts")).toBe(true);
- },
- );
+ it.each(["Admin", "Admin Viewer", "proxy_admin", "proxy_admin_viewer"])("should grant viewPrompts to %s", (role) => {
+ expect(hasCapability(role, "viewPrompts")).toBe(true);
+ });
- it.each(["Internal User", "Internal Viewer", "internal_user", "App User", "Unknown Role", "", null, undefined])(
- "should deny viewPrompts to %s",
- (role) => {
- expect(hasCapability(role, "viewPrompts")).toBe(false);
- },
- );
+ it.each([
+ "Internal User",
+ "Internal Viewer",
+ "internal_user",
+ "App User",
+ "Org Admin",
+ "Unknown Role",
+ "",
+ null,
+ undefined,
+ ])("should deny viewPrompts to %s", (role) => {
+ expect(hasCapability(role, "viewPrompts")).toBe(false);
+ });
});
describe("rolesWithCapability", () => {