Repository navigation
test(e2e): cover Internal Viewer nav, key, and team-info gating #29075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yuneng-berri
merged 2 commits into
litellm_internal_staging
from
litellm_e2e_internal_viewer_role
May 29, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
ui/litellm-dashboard/e2e_tests/tests/internal-viewer/internalViewer.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { test, expect } from "@playwright/test"; | ||
| import { | ||
| E2E_TEAM_CRUD_ID, | ||
| E2E_VIEWER_KEY_ALIAS, | ||
| INTERNAL_VIEWER_STORAGE_PATH, | ||
| } from "../../constants"; | ||
| import { Page } from "../../fixtures/pages"; | ||
| import { navigateToPage } from "../../helpers/navigation"; | ||
|
|
||
| async function clickTeamId(page: import("@playwright/test").Page, teamId: string) { | ||
| const cell = page.locator("td").filter({ hasText: teamId }).first(); | ||
| await expect(cell).toBeVisible({ timeout: 10_000 }); | ||
| await cell.click(); | ||
| await expect(page.getByText("Back to Teams")).toBeVisible({ timeout: 10_000 }); | ||
| } | ||
|
|
||
| test.describe("Internal Viewer", () => { | ||
| test.use({ storageState: INTERNAL_VIEWER_STORAGE_PATH }); | ||
|
|
||
| test("Nav shows only the allowed options for the Internal Viewer role", async ({ page }) => { | ||
| // Use navigateToPage so the networkidle wait lets the async role-gated nav | ||
| // settle before we assert — a bare page.goto races the permission fetch. | ||
| await navigateToPage(page, Page.ApiKeys); | ||
|
|
||
| // Scope to the sidebar and match items by their link role + accessible | ||
| // name. The sidebar is a `complementary` landmark (the `navigation` role | ||
| // is the top bar), and each item renders as a link inside it — far tighter | ||
| // than a CSS `nav, aside` selector or a getByText on stray text nodes. | ||
| const nav = page.getByRole("complementary"); | ||
|
|
||
| // Items that must be visible per the manual-QA checklist | ||
| const expectedVisible = [ | ||
| "Virtual Keys", | ||
| "MCP Servers", | ||
| "Guardrails", | ||
| "Usage", | ||
| "Logs", | ||
| "Teams", | ||
| "API Reference", | ||
| "AI Hub", | ||
| ]; | ||
| for (const label of expectedVisible) { | ||
| await expect( | ||
| nav.getByRole("link", { name: label, exact: true }).first(), | ||
| `expected nav item "${label}" to render for Internal Viewer`, | ||
| ).toBeVisible({ timeout: 5_000 }); | ||
| } | ||
|
|
||
| // Items that must NOT be visible (admin-only surface) | ||
| const expectedHidden = ["Internal Users", "Organizations", "Models + Endpoints"]; | ||
| for (const label of expectedHidden) { | ||
| await expect( | ||
| nav.getByRole("link", { name: label, exact: true }), | ||
| `nav item "${label}" must not render for Internal Viewer`, | ||
| ).toHaveCount(0); | ||
| } | ||
| }); | ||
|
|
||
| test("Virtual Keys page hides Create / Regenerate / Reset / Delete controls", async ({ page }) => { | ||
| await navigateToPage(page, Page.ApiKeys); | ||
|
|
||
| // Create button is gated on rolesWithWriteAccess (Internal Viewer is not in it) | ||
| await expect(page.getByRole("button", { name: /Create New Key/i })).toHaveCount(0); | ||
|
|
||
| // Open the viewer's own key info page | ||
| const keyRow = page.locator("tr", { hasText: E2E_VIEWER_KEY_ALIAS }); | ||
| await expect(keyRow).toBeVisible({ timeout: 10_000 }); | ||
| await keyRow.locator("button").first().click(); | ||
| await expect(page.getByText("Back to Keys")).toBeVisible({ timeout: 10_000 }); | ||
|
|
||
| // None of the destructive / mutating actions should render | ||
| await expect(page.getByRole("button", { name: "Regenerate Key" })).toHaveCount(0); | ||
| await expect(page.getByRole("button", { name: /Reset Spend/i })).toHaveCount(0); | ||
| await expect(page.getByRole("button", { name: "Delete Key" })).toHaveCount(0); | ||
| }); | ||
|
|
||
| test("Team info page omits Members and Settings tabs for an Internal Viewer", async ({ page }) => { | ||
| await navigateToPage(page, Page.Teams); | ||
|
|
||
| await clickTeamId(page, E2E_TEAM_CRUD_ID); | ||
|
|
||
| // Overview / Virtual Keys are always visible; Settings + Members are not. | ||
| // Tabs are conditionally rendered (getTeamInfoVisibleTabs filters the list), | ||
| // so assert absence from the DOM with toHaveCount(0) to match the nav block. | ||
| await expect(page.getByRole("tab", { name: "Overview" })).toBeVisible({ timeout: 5_000 }); | ||
| await expect(page.getByRole("tab", { name: "Virtual Keys" })).toBeVisible({ timeout: 5_000 }); | ||
| await expect(page.getByRole("tab", { name: "Settings" })).toHaveCount(0); | ||
| await expect(page.getByRole("tab", { name: "Members" })).toHaveCount(0); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.