Skip to content

test(e2e): run the UI Playwright suite against the shared e2e gateway - #34212

Open
ryan-crabbe-berri wants to merge 3 commits into
mainfrom
litellm_ui_e2e_shared_gateway
Open

ryan-crabbe-berri wants to merge 3 commits into
mainfrom
litellm_ui_e2e_shared_gateway

Conversation

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Stacked on #34196. Verified against a live gateway provisioned the harness way (worktree proxy on port 4123, throwaway postgres, master key only, store_model_in_db: true), at 871629e:

$ export LITELLM_PROXY_URL=http://localhost:4123 LITELLM_MASTER_KEY=sk-1234 PROXY_LOGOUT_URL=https://www.example.com
$ cd tests/e2e/ui && npx playwright test --config playwright.config.ts   # run A
  1 failed
  3 skipped
  82 passed (3.3m)
$ npx playwright test --config playwright.config.ts                      # run B, same gateway, no reset
  1 failed
  3 skipped
  82 passed (3.1m)

Two identical back-to-back runs against the same persistent gateway prove the API seeding is idempotent. The 3 skips are env-gated specs (SERVER_ROOT_PATH redirect and friends). The 1 failure is the real-completion assertion in keys.spec.ts; this machine has no OPENAI_API_KEY, so the provider call 500s. The path itself works end to end; with the seeded deployment temporarily pointed at a provider this machine does have a key for:

$ KEY=$(curl -s -X POST http://localhost:4123/key/generate -H "Authorization: Bearer sk-1234" \
    -d '{"models":["e2e-ui-openai"],"key_alias":"e2e-proof-1"}' | jq -r .key)
$ curl -s http://localhost:4123/chat/completions -H "Authorization: Bearer $KEY" \
    -d '{"model":"e2e-ui-openai","messages":[{"role":"user","content":"Reply with the single word: pong"}]}'
status ok, content: pong | model: e2e-ui-openai

In CI the deployments resolve os.environ/OPENAI_API_KEY / os.environ/ANTHROPIC_API_KEY from the project env, so that spec runs against real OpenAI there

Type

✅ Test
🚄 Infrastructure

Changes

The UI Playwright suite now targets LITELLM_PROXY_URL (default http://localhost:4000), the same live gateway the python e2e suites use, instead of provisioning a private stack. globalSetup seeds everything through the management API with the master key: the org, the nine e2e-* users (created via /user/new, passwords set via /user/update), the four teams with members_with_roles, the five aliased keys, and two model deployments (e2e-ui-openai, e2e-ui-anthropic) registered via /model/new against real providers (gpt-5.5, claude-haiku-4-5; override with E2E_CHEAP_OPENAI_MODEL / E2E_CHEAP_ANTHROPIC_MODEL). seed.sql and the mock LLM server are deleted, which also lets tests/e2e/ui come off the basedpyright exclude list. The only gateway requirements are a master key and a database with store_model_in_db: true

Seeding is idempotent against a persistent gateway, which live-testing surfaced in three places: teardown deletes per entity because the batch delete endpoints are all-or-nothing (one missing id used to strand every other row and the next /team/new failed on "already exists"); the modelHub spec resets the public model groups list in beforeEach since make_public replaces the whole list and a prior run leaves nothing to select; and the MCP spec purges its own leftover e2e_mcp_* servers, whose dead-URL health checks otherwise keep the page's network busy until the networkidle navigation wait times out

Both configs pin workers: 1 (previously only CI did) because several specs mutate global gateway state (router_settings via /config/update, the public model groups list, enable_projects_ui); parallel workers race each other on a single gateway, which is exactly the flake pattern local runs showed at the default worker count. For the same reason tests/e2e/CLAUDE.md documents that the suite needs the gateway to itself while it runs, so python suites should not be pointed at the same gateway concurrently

The key creation spec now asserts a real completion (200 plus non-empty content) instead of the mock server's canned body, per the harness's no-mocks rule. run_e2e.sh skips provisioning entirely when LITELLM_PROXY_URL is set and otherwise keeps a provisioning mode (postgres, dashboard build, proxy on 4000) minus the seed and mock steps; the CircleCI jobs drop those steps too

Note for reviewers: the CircleCI e2e jobs now need OPENAI_API_KEY and ANTHROPIC_API_KEY in the project env (the proxy resolves them at call time for the seeded deployments). If they are not already set there, the single real-completion assertion will fail and they need to be added

QA runbook

  • tests/e2e/ui globalSetup (API seeding) - any live gateway can now host the suite with no DB access
    • Bring up a gateway per tests/e2e/CONTRIBUTING.md (or none at all; ./tests/e2e/ui/run_e2e.sh provisions one), with OPENAI_API_KEY/ANTHROPIC_API_KEY exported
    • Run LITELLM_PROXY_URL=<gateway> LITELLM_MASTER_KEY=<key> npx playwright test --config playwright.config.ts from tests/e2e/ui
    • Expect globalSetup to create the e2e-* users/teams/keys and the e2e-ui-openai / e2e-ui-anthropic deployments via the management API, then all specs to pass
    • Run the exact same command a second time without resetting anything and expect the same green result (idempotent reseed)
    • Sanity check: this test makes sense to add and is not hand-wavey (e.g., assert actual expected spend instead of just spend > 0) or potentially flaky

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Relocates ui/litellm-dashboard/e2e_tests to tests/e2e/ui so all end to end
suites live under tests/e2e. The suite stays in TypeScript and becomes a
self-contained npm package with its own package.json, lockfile and tsconfig
instead of leaning on the dashboard's toolchain; the dashboard drops its
@playwright/test dependency, e2e scripts and knip/vitest/tsconfig carve-outs.

CI paths follow the move: both CircleCI jobs (main e2e and the
SERVER_ROOT_PATH migration smoke) and the test_server_root_path workflow now
install and run Playwright from tests/e2e/ui, with the node cache keyed on
both lockfiles. classify_changes.sh treats tests/e2e/ui as client so spec
edits keep skipping backend jobs. The suite's mock LLM fixture is excluded
from the e2e basedpyright zero-error gate in pyrightconfig.json since it
belongs to the TS suite, not the typed Python harness.
…n UI

The key info header moved Delete Key into the More key actions menu
(#34116) and the credentials table moved row actions into a dropdown with
data-testids (shared DataTable migration), so both specs timed out
looking for buttons that no longer exist. Reproduced against a proxy
serving a fresh dashboard build; both pass after pointing them at the
menus.
The suite now targets LITELLM_PROXY_URL (default http://localhost:4000),
the same live gateway the python e2e suites use, instead of provisioning
its own postgres, mock LLM server and SQL-seeded proxy. globalSetup seeds
every e2e-* user, team, org, key and model deployment through the
management API with the master key, so any gateway with a master key and
store_model_in_db works; seed.sql and the mock LLM server are gone. The
two deployments (e2e-ui-openai, e2e-ui-anthropic) route to real providers
per the harness's no-mocks rule, and the key creation spec now asserts a
real completion instead of the mock's canned body.

Seeding is idempotent against a persistent gateway: teardown deletes
per-entity (batch deletes are all-or-nothing and one missing id used to
strand every other row), the modelHub spec resets the public model groups
list it fills, and the MCP spec purges its dead-URL servers whose failing
health checks kept networkidle navigation from settling on reruns. Both
Playwright configs pin workers: 1 since several specs mutate global
gateway state; the suite documents that it needs the gateway to itself
while it runs.

Two specs are also caught up with UI refactors that had moved their
buttons into dropdown menus (key deletion under "More key actions",
credential editing under the row's actions menu).

run_e2e.sh keeps a provisioning mode for CI and machines with no gateway,
and skips provisioning entirely when LITELLM_PROXY_URL is set. The
CircleCI jobs drop their seed and mock-server steps; the mock server's
removal also lets tests/e2e/ui leave the basedpyright exclude list.
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves the UI Playwright suite onto the shared e2e gateway. The main changes are:

  • Management-API seeding for users, teams, keys, organizations, and models
  • Real provider completions instead of the private mock server
  • Configurable gateway URLs and single-worker execution
  • Persistent-state cleanup for model hub and MCP tests
  • Simplified local and CircleCI gateway provisioning

Confidence Score: 4/5

Path-prefixed shared gateways and UI jobs without preconfigured provider secrets can fail before completing the suite.

  • Gateway prefixes can be duplicated during setup or discarded by root-relative requests.
  • The real-provider test path depends on credentials that the changed workflow does not explicitly attach.
  • Root-mounted gateways with project-wide provider secrets should continue through the intended flow.

tests/e2e/ui/globalSetup.ts, tests/e2e/ui/playwright.config.ts, tests/e2e/ui/fixtures/apiSeed.ts, and .circleci/config.yml

Important Files Changed

Filename Overview
tests/e2e/ui/fixtures/apiSeed.ts Adds management-API fixture seeding and real-provider deployments, with provider credentials required from the proxy environment.
tests/e2e/ui/globalSetup.ts Seeds the gateway and logs in test roles, but can duplicate a configured root-path prefix.
tests/e2e/ui/playwright.config.ts Adds configurable gateway targeting and serial execution, but path-prefixed base URLs conflict with root-relative requests.
tests/e2e/ui/run_e2e.sh Separates shared-gateway execution from disposable local provisioning and removes mock-server setup.
.circleci/config.yml Removes SQL and mock-provider setup, leaving the UI jobs dependent on externally configured provider credentials.
tests/e2e/ui/tests/proxy-admin/keys.spec.ts Changes key verification from a canned mock response to a successful real-provider completion.
tests/e2e/ui/tests/mcp/mcpServers.spec.ts Adds cleanup for stale e2e MCP servers before and after each test.
tests/e2e/ui/tests/modelHub/modelHub.spec.ts Resets public model groups before each test for repeatable runs against persistent gateways.

Reviews (1): Last reviewed commit: "test(e2e): run the UI Playwright suite a..." | Re-trigger Greptile

const rootPath = process.env.SERVER_ROOT_PATH ?? "";
const masterKey = process.env.LITELLM_MASTER_KEY || "sk-1234";

await seedGateway(`${PROXY_BASE_URL}${rootPath}`, masterKey);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Gateway Prefix Is Duplicated

When LITELLM_PROXY_URL already contains the mounted path and SERVER_ROOT_PATH is also set, this concatenation repeats the prefix. For example, http://localhost:4000/litellm plus /litellm sends seeding to /litellm/litellm, so global setup fails before the tests run.

Rule Used: What: avoid backwards-incompatible changes without... (source)

use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://localhost:4000",
baseURL: process.env.LITELLM_PROXY_URL ?? "http://localhost:4000",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Absolute Requests Drop Gateway Prefix

When LITELLM_PROXY_URL contains a path such as http://host/litellm, root-relative calls like page.goto('/ui?...') and request.post('/chat/completions') resolve against the origin and discard /litellm. Those tests hit unmounted endpoints while direct PROXY_BASE_URL calls retain the prefix, causing the same run to use two different gateway paths.

Rule Used: What: avoid backwards-incompatible changes without... (source)

Comment on lines +12 to +17
litellm_params: { model: OPENAI_UPSTREAM, api_key: "os.environ/OPENAI_API_KEY" },
model_info: { id: E2E_UI_OPENAI_MODEL },
},
{
model_name: E2E_UI_ANTHROPIC_MODEL,
litellm_params: { model: ANTHROPIC_UPSTREAM, api_key: "os.environ/ANTHROPIC_API_KEY" },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 CI Credentials Are Not Provisioned

The seeded deployments now require OPENAI_API_KEY and ANTHROPIC_API_KEY, but the changed CircleCI jobs do not declare or attach either credential. Unless they are already configured as project-wide environment variables, model creation or the real completion request fails and the UI job cannot pass; the workflow should explicitly provide the required secret context.

Rule Used: What: Ensure that any PR claiming to fix an issue ... (source)

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ryan-crabbe-berri
ryan-crabbe-berri force-pushed the litellm_move_ui_e2e_to_tests_e2e branch from f1b567f to 1a901d7 Compare July 22, 2026 18:24
Base automatically changed from litellm_move_ui_e2e_to_tests_e2e to litellm_internal_staging July 22, 2026 19:43
@ryan-crabbe-berri
ryan-crabbe-berri requested a review from a team July 22, 2026 19:43
@yuneng-berri
yuneng-berri deleted the branch main September 13, 2026 04:33
@yuneng-berri yuneng-berri reopened this Sep 13, 2026
@yuneng-berri
yuneng-berri self-requested a review as a code owner September 13, 2026 06:32
@devin-ai-integration
devin-ai-integration Bot changed the base branch from litellm_internal_staging to main September 23, 2026 15:35

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants