Files
outline/app/hooks/useLastVisitedPath.test.ts
Tom Moor e913715ce1 fix: Return each tab to its own document after cross-tab logout (#14536)
* fix: Return each tab to its own document after cross-tab logout

* Use savePath option for tab-only post login path
2026-11-13 07:56:55 -05:00

33 lines
923 B
TypeScript

import { getCookie, removeCookie } from "tiny-cookie";
import { setPostLoginPath } from "./useLastVisitedPath";
const key = "postLoginRedirectPath";
describe("setPostLoginPath", () => {
beforeEach(() => {
sessionStorage.clear();
removeCookie(key);
});
it("stores the path in session storage and the shared cookie", () => {
setPostLoginPath("/doc/a");
expect(sessionStorage.getItem(key)).toBe("/doc/a");
expect(getCookie(key)).toBe("/doc/a");
});
it("does not change the shared cookie when tabOnly is set", () => {
setPostLoginPath("/doc/a");
setPostLoginPath("/doc/b", { tabOnly: true });
expect(sessionStorage.getItem(key)).toBe("/doc/b");
expect(getCookie(key)).toBe("/doc/a");
});
it("ignores paths that are not allowed as a login redirect", () => {
setPostLoginPath("/home", { tabOnly: true });
expect(sessionStorage.getItem(key)).toBeNull();
});
});