From 08e2ec3412a0a6a58acbe63b409cce786771dbdd Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Sat, 7 Mar 2026 16:43:33 -0800 Subject: [PATCH] Fix flaky e2e tests by using regex selectors The createKey test broke because the Models field changed from required to optional (PR #22826), removing the asterisk from the accessible name. The unauthenticated redirect test broke because the login URL now includes a redirect_to query param. Both selectors now use regex to be resilient to these kinds of changes. Co-Authored-By: Claude Opus 4.6 --- .../e2e_tests/tests/auth/unauthenticatedRedirect.spec.ts | 3 +-- ui/litellm-dashboard/e2e_tests/tests/keys/createKey.spec.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/litellm-dashboard/e2e_tests/tests/auth/unauthenticatedRedirect.spec.ts b/ui/litellm-dashboard/e2e_tests/tests/auth/unauthenticatedRedirect.spec.ts index d8cc26f864..4c6e11800e 100644 --- a/ui/litellm-dashboard/e2e_tests/tests/auth/unauthenticatedRedirect.spec.ts +++ b/ui/litellm-dashboard/e2e_tests/tests/auth/unauthenticatedRedirect.spec.ts @@ -3,9 +3,8 @@ import { test, expect } from "@playwright/test"; test.describe("Authentication Checks", () => { test("should redirect unauthenticated user from a protected page", async ({ page }) => { const protectedPageUrl = "http://localhost:4000/ui?page=llm-playground"; - const expectedRedirectUrl = "http://localhost:4000/ui/login/"; await page.goto(protectedPageUrl, { waitUntil: "domcontentloaded" }); - await expect(page).toHaveURL(expectedRedirectUrl); + await expect(page).toHaveURL(/\/ui\/login/); await expect(page.getByRole("heading", { name: "Login" })).toBeVisible(); }); }); diff --git a/ui/litellm-dashboard/e2e_tests/tests/keys/createKey.spec.ts b/ui/litellm-dashboard/e2e_tests/tests/keys/createKey.spec.ts index 4343063b30..682d1a1b45 100644 --- a/ui/litellm-dashboard/e2e_tests/tests/keys/createKey.spec.ts +++ b/ui/litellm-dashboard/e2e_tests/tests/keys/createKey.spec.ts @@ -14,7 +14,7 @@ test.describe("Create Key", () => { await page.getByTestId("base-input").fill("e2eUITestingCreateKeyAllTeamModels"); await page.locator(".ant-select-selection-overflow").click(); await page.getByText("All Team Models").click(); - await page.getByRole("combobox", { name: "* Models info-circle :" }).press("Escape"); + await page.getByRole("combobox", { name: /models/i }).press("Escape"); await page.getByRole("button", { name: "Create Key" }).click(); await page.keyboard.press("Escape"); await expect(page.getByText("e2eUITestingCreateKeyAllTeamModels")).toBeVisible();