litellm/tests/e2e/ui/tests/internal-user/internalUserNoTeam.spec.ts
mateo-berri e641864e6f test(e2e/ui): give the seeded users passwords that pass the default password policy
The default password policy from #39381 (12+ chars with upper, lower, number, and special) makes globalSetup's POST /user/update with password "test" fail with a 400, so every role login in the UI e2e suite has been failing since that merge. Seed the roles, the noteam@test.local login, and the second-admin spec with policy-compliant passwords and update the scrypt hash in seed.sql to match.
2026-09-02 16:58:53 -07:00

43 lines
2.3 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { navigateToPage } from "../../helpers/navigation";
import { Page } from "../../fixtures/pages";
import { E2E_SEEDED_USER_PASSWORD } from "../../constants";
/**
* 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("noteam@test.local");
await page.getByPlaceholder("Enter your password").fill(E2E_SEEDED_USER_PASSWORD);
await page.getByRole("button", { name: "Login", exact: true }).click();
await expect(page.getByRole("complementary").getByText("Virtual Keys")).toBeVisible({ timeout: 30_000 });
expect(new URL(page.url()).pathname).not.toMatch(/\/connect$/);
await navigateToPage(page, Page.ApiKeys);
// Scope to the sidebar; the top-bar breadcrumb also shows "Virtual Keys".
await expect(page.getByRole("complementary").getByText("Virtual Keys")).toBeVisible({ timeout: 15_000 });
// 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.getByTestId("team-dropdown").getByRole("combobox");
await teamSelect.click();
// Wait for the settled-empty state, not a transient one. The dropdown shows
// "Loading teams…" while teams load and only swaps in "No teams found" once
// the request resolves with nothing (team_dropdown.tsx passes both copies to
// PaginatedSearchSelect). 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(page.getByText("No teams found")).toBeVisible({ timeout: 10_000 });
await expect(page.getByRole("option")).toHaveCount(0);
});
});