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(e2e): cover Internal User create-key flow when in no teams (#29083)
ryan-crabbe-berri892838963ca5
diff --git a/ui/litellm-dashboard/e2e_tests/constants.ts b/ui/litellm-dashboard/e2e_tests/constants.tsindex dbc73432f65..8b1b4313869 100644--- a/ui/litellm-dashboard/e2e_tests/constants.ts+++ b/ui/litellm-dashboard/e2e_tests/constants.ts@@ -18,5 +18,6 @@ export const E2E_TEAM_CRUD_ALIAS = "E2E Team CRUD";export const E2E_TEAM_DELETE_ID = "e2e-team-delete";export const E2E_TEAM_DELETE_ALIAS = "E2E Team Delete";export const E2E_TEAM_ORG_ID = "e2e-team-org";+export const E2E_TEAM_ORG_ALIAS = "E2E Team In Org";export const E2E_TEAM_NO_ADMIN_ID = "e2e-team-no-admin";export const E2E_TEAM_NO_ADMIN_ALIAS = "E2E Team No Admin";diff --git a/ui/litellm-dashboard/e2e_tests/fixtures/seed.sql b/ui/litellm-dashboard/e2e_tests/fixtures/seed.sqlindex 5e5313240e6..a1218633cdb 100644--- a/ui/litellm-dashboard/e2e_tests/fixtures/seed.sql+++ b/ui/litellm-dashboard/e2e_tests/fixtures/seed.sql@@ -33,6 +33,7 @@ VALUES('e2e-internal-viewer', '[email protected]', 'internal_user_viewer', '{"e2e-team-crud"}', 'scrypt:MU5CcTAi6rVK1HfY1rVPEWq6r4sxg837eq9dG4n5Q6BhDJ44442+seC6LAhLEAYr'),('e2e-team-admin', '[email protected]', 'internal_user', '{"e2e-team-crud","e2e-team-delete"}', 'scrypt:MU5CcTAi6rVK1HfY1rVPEWq6r4sxg837eq9dG4n5Q6BhDJ44442+seC6LAhLEAYr'),('e2e-invitable-user', '[email protected]', 'internal_user', '{}', 'scrypt:MU5CcTAi6rVK1HfY1rVPEWq6r4sxg837eq9dG4n5Q6BhDJ44442+seC6LAhLEAYr'),+ ('e2e-internal-noteam', '[email protected]', 'internal_user', '{}', 'scrypt:MU5CcTAi6rVK1HfY1rVPEWq6r4sxg837eq9dG4n5Q6BhDJ44442+seC6LAhLEAYr'),('e2e-invitable-by-team-admin', '[email protected]', 'internal_user', '{}', 'scrypt:MU5CcTAi6rVK1HfY1rVPEWq6r4sxg837eq9dG4n5Q6BhDJ44442+seC6LAhLEAYr'),('e2e-removable-member', '[email protected]', 'internal_user', '{"e2e-team-crud"}', 'scrypt:MU5CcTAi6rVK1HfY1rVPEWq6r4sxg837eq9dG4n5Q6BhDJ44442+seC6LAhLEAYr');diff --git a/ui/litellm-dashboard/e2e_tests/tests/internal-user/internalUserNoTeam.spec.ts b/ui/litellm-dashboard/e2e_tests/tests/internal-user/internalUserNoTeam.spec.tsnew file mode 100644index 00000000000..548639d6877--- /dev/null+++ b/ui/litellm-dashboard/e2e_tests/tests/internal-user/internalUserNoTeam.spec.ts@@ -0,0 +1,41 @@+import { test, expect } from "@playwright/test";+import { dismissFeedbackPopup } from "../../helpers/navigation";++/**+ * Logs in fresh inside the test rather than reusing a stored session because+ * this user (seeded with no team memberships) only exists for this one spec —+ * extending globalSetup + the Role enum + the storage-path map for a single+ * assertion isn't worth the maintenance cost.+ */+test.describe("Internal User with no team memberships", () => {+ test.use({ storageState: { cookies: [], origins: [] } });++ test("Create Key team dropdown is empty when the user belongs to no teams", async ({ page }) => {+ // Log in via the form as the no-team seeded user.+ await page.goto("/ui/login");+ await page.getByPlaceholder("Enter your username").fill("[email protected]");+ await page.getByPlaceholder("Enter your password").fill("test");+ await page.getByRole("button", { name: "Login", exact: true }).click();+ await expect(page.getByText("Virtual Keys")).toBeVisible({ timeout: 15_000 });+ await dismissFeedbackPopup(page);++ // Open the Create Key modal.+ await page.getByRole("button", { name: /Create New Key/i }).click();+ await expect(page.getByText("Key Ownership")).toBeVisible({ timeout: 10_000 });++ const teamSelect = page.locator(".ant-select", { hasText: "Search or select a team" });+ await teamSelect.click();++ const dropdown = page.locator(".ant-select-dropdown:visible").first();+ await expect(dropdown).toBeVisible({ timeout: 5_000 });++ // Wait for the settled-empty state, not a transient one. The dropdown shows+ // a spinner while teams load and only swaps in "No teams found" once the+ // request resolves with nothing (team_dropdown.tsx renders the spinner when+ // isLoading and this copy otherwise). Asserting on it means a regression+ // where teams DO load for this user fails here instead of racing a one-shot+ // count() against an in-flight request.+ await expect(dropdown.getByText("No teams found")).toBeVisible({ timeout: 10_000 });+ await expect(dropdown.getByRole("option")).toHaveCount(0);+ });+});diff --git a/ui/litellm-dashboard/e2e_tests/tests/internal-user/internalUserWithTeams.spec.ts b/ui/litellm-dashboard/e2e_tests/tests/internal-user/internalUserWithTeams.spec.tsnew file mode 100644index 00000000000..f6b60f411b4--- /dev/null+++ b/ui/litellm-dashboard/e2e_tests/tests/internal-user/internalUserWithTeams.spec.ts@@ -0,0 +1,37 @@+import { test, expect } from "@playwright/test";+import {+ INTERNAL_USER_STORAGE_PATH,+ E2E_TEAM_CRUD_ALIAS,+ E2E_TEAM_ORG_ALIAS,+} from "../../constants";+import { Page } from "../../fixtures/pages";+import { navigateToPage } from "../../helpers/navigation";++/**+ * Differential partner to internalUserNoTeam.spec.ts: the seeded+ * e2e-internal-user belongs to exactly two teams, so the Create Key dropdown+ * must list both. Without this, the no-team spec's "zero options" assertion+ * would still pass against a bug that empties the dropdown for everyone.+ */+test.describe("Internal User with team memberships", () => {+ test.use({ storageState: INTERNAL_USER_STORAGE_PATH });++ test("Create Key team dropdown lists exactly the teams the user belongs to", async ({ page }) => {+ await navigateToPage(page, Page.ApiKeys);++ await page.getByRole("button", { name: /Create New Key/i }).click();+ await expect(page.getByText("Key Ownership")).toBeVisible({ timeout: 10_000 });++ const teamSelect = page.locator(".ant-select", { hasText: "Search or select a team" });+ await teamSelect.click();++ const dropdown = page.locator(".ant-select-dropdown:visible").first();+ await expect(dropdown).toBeVisible({ timeout: 5_000 });++ // Both seeded memberships render, and nothing else does — proving the+ // dropdown is scoped to the user's teams rather than empty or unfiltered.+ await expect(dropdown.getByText(E2E_TEAM_CRUD_ALIAS, { exact: true })).toBeVisible({ timeout: 10_000 });+ await expect(dropdown.getByText(E2E_TEAM_ORG_ALIAS, { exact: true })).toBeVisible();+ await expect(dropdown.getByRole("option")).toHaveCount(2);+ });+});