From 9237fe524cacda702a699416ee59d87a020cb825 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Tue, 9 Jun 2026 15:46:49 -0700 Subject: [PATCH] test(ui): accept expires-based cookie deletion in expired-token assertion The auth context now clears the expired token via clearTokenCookies(), which deletes with an already-past expires date rather than the removed deleteCookie wrapper's Max-Age=0 write. The assertion was pinned to the mechanism instead of the behavior; it now accepts either deletion form --- .../tests/CreateKeyPage.expiredToken.test.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/litellm-dashboard/tests/CreateKeyPage.expiredToken.test.tsx b/ui/litellm-dashboard/tests/CreateKeyPage.expiredToken.test.tsx index 2e1025e18bc..e2e1c9e5a98 100644 --- a/ui/litellm-dashboard/tests/CreateKeyPage.expiredToken.test.tsx +++ b/ui/litellm-dashboard/tests/CreateKeyPage.expiredToken.test.tsx @@ -215,7 +215,7 @@ describe("CreateKeyPage auth behavior", () => { return { exp: Math.floor(Date.now() / 1000) - 60 }; // expired 60s ago }); - // Spy on cookie writes to ensure we clear with Max-Age=0 + // Spy on cookie writes to ensure we write a deletion for the token const cookieSetSpy = vi.spyOn(document, "cookie", "set"); // Act @@ -228,9 +228,13 @@ describe("CreateKeyPage auth behavior", () => { ); }); - // And we attempted to clear the cookie (defensive deletion) + // And we attempted to clear the cookie (defensive deletion, via either + // Max-Age=0 or an already-past expires date) const wroteDeletion = cookieSetSpy.mock.calls.some( - (args) => typeof args[0] === "string" && args[0].includes("Max-Age=0") && args[0].startsWith("token="), + (args) => + typeof args[0] === "string" && + args[0].startsWith("token=;") && + (args[0].includes("Max-Age=0") || args[0].includes("expires=Thu, 01 Jan 1970")), ); expect(wroteDeletion).toBe(true); });