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
This commit is contained in:
ryan-crabbe-berri 2026-06-09 15:46:49 -07:00
parent 24ae260c74
commit 9237fe524c

View file

@ -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);
});