Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/litellm-dashboard/e2e_tests/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const ADMIN_STORAGE_PATH = "admin.storageState.json";
export const INTERNAL_USER_VIEWER_STORAGE_PATH = "internalViewer.storageState.json";
4 changes: 4 additions & 0 deletions ui/litellm-dashboard/e2e_tests/fixtures/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ export const users = {
email: "admin",
password: isCI ? "gm" : "sk-1234",
},
[Role.InternalUserViewer]: {
email: "internalViewer@test.com",
password: "test",
},
};
29 changes: 21 additions & 8 deletions ui/litellm-dashboard/e2e_tests/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import { chromium } from "@playwright/test";
import { users } from "./fixtures/users";
import { Role } from "./fixtures/roles";
import { ADMIN_STORAGE_PATH, INTERNAL_USER_VIEWER_STORAGE_PATH } from "./constants";

async function loginAndSaveState(
browser,
user,
storagePath: string
) {
const context = await browser.newContext();
const page = await context.newPage();

await page.goto("http://localhost:4000/ui/login");
await page.getByPlaceholder("Enter your username").fill(user.email);
await page.getByPlaceholder("Enter your password").fill(user.password);
await page.getByRole("button", { name: "Login" }).click();
await page.getByText('AI GATEWAY').waitFor();

await context.storageState({ path: storagePath });
await context.close();
}

async function globalSetup() {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto("http://localhost:4000/ui/login");
await page.getByPlaceholder("Enter your username").fill(users[Role.ProxyAdmin].email);
await page.getByPlaceholder("Enter your password").fill(users[Role.ProxyAdmin].password);
const loginButton = page.getByRole("button", { name: "Login" });
await loginButton.click();
await page.waitForSelector("text=AI Gateway");
await page.context().storageState({ path: "admin.storageState.json" });
await loginAndSaveState(browser, users[Role.ProxyAdmin], ADMIN_STORAGE_PATH);
await loginAndSaveState(browser, users[Role.InternalUserViewer], INTERNAL_USER_VIEWER_STORAGE_PATH);
await browser.close();
}

Expand Down
2 changes: 1 addition & 1 deletion ui/litellm-dashboard/e2e_tests/tests/login/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { users } from "../../fixtures/users";
import { Role } from "../../fixtures/roles";

test("user can log in", async ({ page }) => {
await page.goto("http://localhost:4000/ui/login");
await page.goto("/ui/login");
await page.getByPlaceholder("Enter your username").fill(users[Role.ProxyAdmin].email);
await page.getByPlaceholder("Enter your password").fill(users[Role.ProxyAdmin].password);
const loginButton = page.getByRole("button", { name: "Login" });
Expand Down
15 changes: 13 additions & 2 deletions ui/litellm-dashboard/e2e_tests/tests/navigation/sidebar.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import test, { expect } from "@playwright/test";
import { Role } from "../../fixtures/roles";
import { ADMIN_STORAGE_PATH } from "../../constants";
import { ADMIN_STORAGE_PATH, INTERNAL_USER_VIEWER_STORAGE_PATH } from "../../constants";
import { Page } from "../../fixtures/pages";
import { menuLabelToPage } from "../../fixtures/menuMappings";
import { navigateToPage } from "../../helpers/navigation";

const sidebarButtons = {
[Role.ProxyAdmin]: [
"Virtual Keys",
"MCP Servers",
"Playground",
"Models",
"Usage",
"Logs",
"Teams",
"Internal Users",
"API Reference",
"AI Hub",
],
[Role.InternalUserViewer]: [
"Virtual Keys",
"MCP Servers",
"Usage",
"Teams",
"Logs",
"API Reference",
"AI Hub",
],
};

const roles = [{ role: Role.ProxyAdmin, storage: ADMIN_STORAGE_PATH }];
const roles = [{ role: Role.ProxyAdmin, storage: ADMIN_STORAGE_PATH }, { role: Role.InternalUserViewer, storage: INTERNAL_USER_VIEWER_STORAGE_PATH }];

for (const { role, storage } of roles) {
test.describe(`${role} sidebar`, () => {
Expand Down
1 change: 1 addition & 0 deletions ui/litellm-dashboard/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default defineConfig({
setupFiles: ["tests/setupTests.ts"],
globals: true,
css: true, // lets you import CSS/modules without extra mocks
testTimeout: 10000,
coverage: {
provider: "v8",
reporter: ["text", "lcov"],
Expand Down
Loading