test(ui): scrub stale return-url cookie from e2e storageState (#30317)

The login flow stores a post-login return URL in the litellm_return_url
cookie (5 minute TTL). globalSetup snapshots cookies into the per-role
storageState that every spec reuses, so when the snapshot races ahead
of the app consuming that cookie, each test inheriting it gets
redirected to the stale URL (/ui/?login=success) mid-assertion the
first time it mounts a page. That one rogue navigation is behind the
recurring e2e failures whose call logs all show "navigated to
/ui/?login=success" while waiting for an element; which specs die
varies run to run with snapshot timing. Clear the cookie right before
saving the snapshot so no test starts with a pending redirect.
This commit is contained in:
ryan-crabbe-berri 2026-06-22 18:11:05 -07:00 • committed by GitHub
parent ee5b2a367d
commit 3fc73c1aff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,6 +39,11 @@ async function globalSetup() {
if (await dismiss.isVisible({ timeout: 1_500 }).catch(() => false)) {
await dismiss.click();
}
// The login flow stores a post-login return URL in the litellm_return_url
// cookie. If the snapshot captures it before the app consumes it, every
// test inheriting this storageState gets yanked to that stale URL the
// first time it mounts a page (the e2e suite's main flake source).
await page.context().clearCookies({ name: "litellm_return_url" });
await page.context().storageState({ path: storagePath });
} catch (e) {
fs.mkdirSync("test-results", { recursive: true });