test(auth): provide window.location.pathname in redirectToLogin mocks

The pathname.startsWith() loop-break added to redirectToLogin needs
pathname on the mock Location object; tests were supplying only href.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hongming Wang 2026-04-23 10:29:53 -07:00
parent b360a4353f
commit 2c3eccf9d6

View File

@ -47,7 +47,12 @@ describe("redirectToLogin", () => {
const href = "https://acme.moleculesai.app/dashboard";
Object.defineProperty(window, "location", {
writable: true,
value: { href },
value: {
href,
pathname: "/dashboard",
hostname: "acme.moleculesai.app",
protocol: "https:",
},
});
redirectToLogin("sign-in");
// href now holds the redirect target. encodeURIComponent(href) must
@ -61,7 +66,12 @@ describe("redirectToLogin", () => {
it("uses signup path for sign-up screenHint", () => {
Object.defineProperty(window, "location", {
writable: true,
value: { href: "https://acme.moleculesai.app/" },
value: {
href: "https://acme.moleculesai.app/",
pathname: "/",
hostname: "acme.moleculesai.app",
protocol: "https:",
},
});
redirectToLogin("sign-up");
expect((window.location as unknown as { href: string }).href).toContain("/cp/auth/signup");