Skip to content

Commit c7734cb

Browse files
authored
Merge pull request BerriAI#18501 from BerriAI/litellm_ui_e2e_login_session
[Infra] UI - E2E Tests Setup
2 parents 52a1dbf + 46ce686 commit c7734cb

File tree

8 files changed

+159
-4
lines changed

8 files changed

+159
-4
lines changed

.circleci/config.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,6 @@ jobs:
34763476
name: Install Playwright Browsers
34773477
command: |
34783478
npx playwright install
3479-
34803479
- run:
34813480
name: Build Docker image
34823481
command: docker build -t my-app:latest -f ./docker/Dockerfile.database .
@@ -3515,7 +3514,10 @@ jobs:
35153514
- run:
35163515
name: Run Playwright Tests
35173516
command: |
3518-
npx playwright test e2e_ui_tests/ --reporter=html --output=test-results
3517+
npx playwright test \
3518+
--config ui/litellm-dashboard/e2e_tests/playwright.config.ts \
3519+
--reporter=html \
3520+
--output=test-results
35193521
no_output_timeout: 120m
35203522
- store_artifacts:
35213523
path: test-results
@@ -3973,4 +3975,4 @@ workflows:
39733975
- proxy_pass_through_endpoint_tests
39743976
- check_code_and_doc_quality
39753977
- publish_proxy_extras
3976-
- guardrails_testing
3978+
- guardrails_testing

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,5 @@ tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py
101101
litellm/proxy/_experimental/out/guardrails/index.html
102102
scripts/test_vertex_ai_search.py
103103
LAZY_LOADING_IMPROVEMENTS.md
104+
**/test-results
105+
**/playwright-report
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("login and save auth state", async ({ page }) => {
4+
await page.goto("http://localhost:4000/ui");
5+
6+
await page.getByPlaceholder("Enter your username").fill("admin");
7+
await page.getByPlaceholder("Enter your password").fill("gm");
8+
9+
const loginButton = page.getByRole("button", { name: "Login" });
10+
await expect(loginButton).toBeEnabled();
11+
await loginButton.click();
12+
13+
// Assert successful login (important)
14+
await expect(page.getByText("AI Gateway")).toBeVisible();
15+
16+
// 🔐 Save auth state
17+
await page.context().storageState({
18+
path: "storageState.json",
19+
});
20+
});
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
3+
/**
4+
* See https://playwright.dev/docs/test-configuration.
5+
*/
6+
export default defineConfig({
7+
testDir: ".",
8+
testMatch: ["**/*.spec.ts", "**/*.setup.ts"],
9+
testIgnore: ["**/*.test.*"],
10+
/* Run tests in files in parallel */
11+
fullyParallel: true,
12+
/* Fail the build on CI if you accidentally left test.only in the source code. */
13+
forbidOnly: !!process.env.CI,
14+
/* Retry on CI only */
15+
retries: process.env.CI ? 2 : 0,
16+
/* Opt out of parallel tests on CI. */
17+
workers: process.env.CI ? 1 : undefined,
18+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
19+
reporter: "html",
20+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
21+
use: {
22+
/* Base URL to use in actions like `await page.goto('/')`. */
23+
baseURL: "http://localhost:3000",
24+
25+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
26+
trace: "on-first-retry",
27+
},
28+
29+
/* Configure projects for major browsers */
30+
projects: [
31+
{
32+
name: "chromium",
33+
use: { ...devices["Desktop Chrome"] },
34+
},
35+
36+
{
37+
name: "firefox",
38+
use: { ...devices["Desktop Firefox"] },
39+
},
40+
],
41+
42+
/* Timeout settings */
43+
timeout: 4 * 60 * 1000,
44+
expect: {
45+
timeout: 10 * 1000,
46+
},
47+
});

ui/litellm-dashboard/package-lock.json

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/litellm-dashboard/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"test": "vitest",
1111
"test:watch": "vitest -w",
1212
"format": "prettier --write .",
13-
"format:check": "prettier --check ."
13+
"format:check": "prettier --check .",
14+
"e2e": "playwright test --config e2e_tests/playwright.config.ts",
15+
"e2e:ui": "playwright test --ui --config e2e_tests/playwright.config.ts"
1416
},
1517
"dependencies": {
1618
"@anthropic-ai/sdk": "^0.54.0",
@@ -44,6 +46,7 @@
4446
"uuid": "^11.1.0"
4547
},
4648
"devDependencies": {
49+
"@playwright/test": "^1.57.0",
4750
"@tailwindcss/forms": "^0.5.7",
4851
"@testing-library/dom": "^10.4.1",
4952
"@testing-library/jest-dom": "^6.8.0",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"cookies": [
3+
{
4+
"name": "token",
5+
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiZGVmYXVsdF91c2VyX2lkIiwia2V5Ijoic2stUkJVZGFncVZuY0VWMDNVdnNDZkstdyIsInVzZXJfZW1haWwiOm51bGwsInVzZXJfcm9sZSI6InByb3h5X2FkbWluIiwibG9naW5fbWV0aG9kIjoidXNlcm5hbWVfcGFzc3dvcmQiLCJwcmVtaXVtX3VzZXIiOnRydWUsImF1dGhfaGVhZGVyX25hbWUiOiJBdXRob3JpemF0aW9uIiwiZGlzYWJsZWRfbm9uX2FkbWluX3BlcnNvbmFsX2tleV9jcmVhdGlvbiI6ZmFsc2UsInNlcnZlcl9yb290X3BhdGgiOiIvIn0.aW_1-qDI9HuZvDq53ufTX_HrE6EJ7XSCPBb-N136KjQ",
6+
"domain": "localhost",
7+
"path": "/",
8+
"expires": -1,
9+
"httpOnly": false,
10+
"secure": false,
11+
"sameSite": "Lax"
12+
}
13+
],
14+
"origins": []
15+
}

ui/litellm-dashboard/vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export default defineConfig({
88
globals: true,
99
css: true, // lets you import CSS/modules without extra mocks
1010
coverage: { reporter: ["text", "lcov"] },
11+
exclude: ["e2e_tests/**,", "node_modules/**"],
12+
include: ["src/**/*.test.ts", "src/**/*.test.tsx", "tests/**/*.test.ts", "tests/**/*.test.tsx"],
1113
},
1214
resolve: {
1315
alias: {

0 commit comments

Comments
 (0)