e2e tests

This commit is contained in:
yuneng-jiang 2025-12-03 20:34:41 -08:00
parent d215576477
commit 3de84b3f8b
6 changed files with 15 additions and 10 deletions

View File

@ -555,7 +555,7 @@ else:
global_max_parallel_request_retry_timeout_env
)
ui_link = f"{server_root_path}/ui/login"
ui_link = f"{server_root_path}/ui"
fallback_login_link = f"{server_root_path}/fallback/login"
model_hub_link = f"{server_root_path}/ui/model_hub_table"
ui_message = (

View File

@ -10,7 +10,9 @@ import { test, expect } from "@playwright/test";
test("admin login test", async ({ page }) => {
// Go to the specified URL
await page.goto("http://localhost:4000/ui/login");
await page.goto("http://localhost:4000/ui");
page.screenshot({ path: "login_before.png" });
// Enter "admin" in the username input field
await page.fill('input[name="username"]', "admin");
@ -18,8 +20,10 @@ test("admin login test", async ({ page }) => {
// Enter "gm" in the password input field
await page.fill('input[name="password"]', "gm");
page.screenshot({ path: "login_after_inputs.png" });
// Optionally, you can add an assertion to verify the login button is enabled
const loginButton = page.locator('button[type="submit"]');
const loginButton = page.getByRole("button", { name: "Login" });
await expect(loginButton).toBeEnabled();
// Optionally, you can click the login button to submit the form

View File

@ -31,7 +31,7 @@ test("user search test", async ({ page }) => {
await page.fill('input[name="password"]', "gm");
console.log("Filled login credentials");
const loginButton = page.locator('input[type="submit"]');
const loginButton = page.getByRole("button", { name: "Login" });
await expect(loginButton).toBeEnabled();
await loginButton.click();
console.log("Clicked login button");
@ -138,7 +138,7 @@ test("user filter test", async ({ page }) => {
await page.fill('input[name="password"]', "gm");
console.log("Filled login credentials");
const loginButton = page.locator('input[type="submit"]');
const loginButton = page.getByRole("button", { name: "Login" });
await expect(loginButton).toBeEnabled();
await loginButton.click();
console.log("Clicked login button");

View File

@ -15,7 +15,7 @@ test("view internal user page", async ({ page }) => {
await page.fill('input[name="password"]', "gm");
// Click the login button
const loginButton = page.locator('input[type="submit"]');
const loginButton = page.getByRole("button", { name: "Login" });
await expect(loginButton).toBeEnabled();
await loginButton.click();
@ -35,9 +35,9 @@ test("view internal user page", async ({ page }) => {
const rowCount = await page.locator("tbody tr").count();
expect(rowCount).toBeGreaterThan(0);
// Verify table headers are present (including Virtual Keys column)
const virtualKeysHeader = page.locator("th", { hasText: "Virtual Keys" });
await expect(virtualKeysHeader).toBeVisible();
const userIdHeader = page.locator("th", { hasText: "User ID" });
page.screenshot({ path: "user_id_header.png" });
await expect(userIdHeader).toBeVisible();
// test pagination
// Wait for pagination controls to be visible

View File

@ -14,6 +14,7 @@ test.describe("User Info View", () => {
// Wait for loading state to disappear
await page.waitForSelector('text="🚅 Loading users..."', {
state: "hidden",
timeout: 10000,
});
// Wait for users table to load
await page.waitForSelector("table");

View File

@ -186,7 +186,7 @@ export default function CreateKeyPage() {
useEffect(() => {
if (redirectToLogin) {
// Replace instead of assigning to avoid back-button loops
const dest = (proxyBaseUrl || "") + "/sso/key/generate";
const dest = (proxyBaseUrl || "") + "/ui/login";
window.location.replace(dest);
}
}, [redirectToLogin]);