Repository navigation
test(e2e): run the UI Playwright suite against the shared e2e gateway - #34212
ryan-crabbe-berri wants to merge 3 commits into
Conversation
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 SummaryThis PR moves the UI Playwright suite onto the shared e2e gateway. The main changes are:
Confidence Score: 4/5Path-prefixed shared gateways and UI jobs without preconfigured provider secrets can fail before completing the suite.
tests/e2e/ui/globalSetup.ts, tests/e2e/ui/playwright.config.ts, tests/e2e/ui/fixtures/apiSeed.ts, and .circleci/config.yml
|
| 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); |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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)
| 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" }, |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
f1b567f to
1a901d7
Compare
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito 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: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 noOPENAI_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:In CI the deployments resolve
os.environ/OPENAI_API_KEY/os.environ/ANTHROPIC_API_KEYfrom the project env, so that spec runs against real OpenAI thereType
✅ Test
🚄 Infrastructure
Changes
The UI Playwright suite now targets
LITELLM_PROXY_URL(defaulthttp://localhost:4000), the same live gateway the python e2e suites use, instead of provisioning a private stack.globalSetupseeds 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 withmembers_with_roles, the five aliased keys, and two model deployments (e2e-ui-openai,e2e-ui-anthropic) registered via/model/newagainst real providers (gpt-5.5,claude-haiku-4-5; override withE2E_CHEAP_OPENAI_MODEL/E2E_CHEAP_ANTHROPIC_MODEL).seed.sqland the mock LLM server are deleted, which also letstests/e2e/uicome off the basedpyright exclude list. The only gateway requirements are a master key and a database withstore_model_in_db: trueSeeding 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/newfailed on "already exists"); the modelHub spec resets the public model groups list inbeforeEachsincemake_publicreplaces the whole list and a prior run leaves nothing to select; and the MCP spec purges its own leftovere2e_mcp_*servers, whose dead-URL health checks otherwise keep the page's network busy until the networkidle navigation wait times outBoth configs pin
workers: 1(previously only CI did) because several specs mutate global gateway state (router_settingsvia/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 reasontests/e2e/CLAUDE.mddocuments that the suite needs the gateway to itself while it runs, so python suites should not be pointed at the same gateway concurrentlyThe 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.shskips provisioning entirely whenLITELLM_PROXY_URLis 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 tooNote for reviewers: the CircleCI e2e jobs now need
OPENAI_API_KEYandANTHROPIC_API_KEYin 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 addedQA runbook
globalSetup(API seeding) - any live gateway can now host the suite with no DB accesstests/e2e/CONTRIBUTING.md(or none at all;./tests/e2e/ui/run_e2e.shprovisions one), withOPENAI_API_KEY/ANTHROPIC_API_KEYexportedLITELLM_PROXY_URL=<gateway> LITELLM_MASTER_KEY=<key> npx playwright test --config playwright.config.tsfromtests/e2e/uiglobalSetupto create the e2e-* users/teams/keys and thee2e-ui-openai/e2e-ui-anthropicdeployments via the management API, then all specs to passFinal Attestation