mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-17 04:34:25 +00:00
test(ui): wait for the logout navigation before checking the session is gone (#47008)
This commit is contained in:
parent
e9a8581a02
commit
53ef63145b
1 changed files with 19 additions and 1 deletions
|
|
@ -2,6 +2,8 @@ import { test, expect } from "@playwright/test";
|
|||
import { Role, users } from "../../fixtures/users";
|
||||
import { logInThroughLoginPage } from "../../helpers/userOnboarding";
|
||||
|
||||
const LOGOUT_URL = process.env.PROXY_LOGOUT_URL ?? "";
|
||||
|
||||
test.describe("Logout", () => {
|
||||
test.use({ storageState: { cookies: [], origins: [] } });
|
||||
|
||||
|
|
@ -9,9 +11,21 @@ test.describe("Logout", () => {
|
|||
const admin = users[Role.ProxyAdmin];
|
||||
await logInThroughLoginPage(page, admin.email, admin.password);
|
||||
|
||||
if (LOGOUT_URL) {
|
||||
const target = new URL(LOGOUT_URL);
|
||||
await page.route(
|
||||
(url) => url.origin === target.origin,
|
||||
(route) =>
|
||||
route.fulfill({ status: 200, contentType: "text/html", body: "<html><body>logged out</body></html>" }),
|
||||
);
|
||||
}
|
||||
const settingsLoaded = page.waitForResponse((r) => r.url().includes("/sso/get/ui_settings") && r.ok(), {
|
||||
timeout: 30_000,
|
||||
});
|
||||
await page.goto("/ui");
|
||||
// Scope to the sidebar; the top-bar breadcrumb also shows "Virtual Keys".
|
||||
await expect(page.getByRole("complementary").getByText("Virtual Keys")).toBeVisible({ timeout: 10_000 });
|
||||
await settingsLoaded;
|
||||
|
||||
// Open the sidebar account menu. The trigger button exposes an aria-label
|
||||
// of "Account menu — <role> — signed in as <email>"; clicking it opens the
|
||||
|
|
@ -22,8 +36,12 @@ test.describe("Logout", () => {
|
|||
await expect(popup).toBeVisible({ timeout: 5_000 });
|
||||
|
||||
// Click Logout — the handler clears the auth cookie and navigates via
|
||||
// window.location.href = PROXY_LOGOUT_URL (empty string in the e2e env).
|
||||
// window.location.href = PROXY_LOGOUT_URL.
|
||||
const loggedOut = LOGOUT_URL
|
||||
? page.waitForURL((url) => url.origin === new URL(LOGOUT_URL).origin, { timeout: 15_000 })
|
||||
: page.waitForEvent("load", { timeout: 15_000 });
|
||||
await popup.getByRole("button", { name: "Logout" }).click();
|
||||
await loggedOut;
|
||||
await expect
|
||||
.poll(async () => (await page.context().cookies()).filter((c) => c.name === "token").length, {
|
||||
timeout: 15_000,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue