import { describe, expect, it } from "vitest"; import { loader } from "./admin.login"; function expectRedirect(call: () => Response): Response { try { call(); } catch (error) { if (typeof error === "object" && error !== null && "status" in error && "headers" in error) { return error as Response; } throw error; } throw new Error("Expected redirect response"); } describe("admin login alias route", () => { it("redirects legacy /admin/login URLs to the canonical login route", async () => { const response = expectRedirect(() => loader({ request: new Request("https://admin.example.test/admin/login?error=sso_state_invalid"), params: {}, context: {}, }) ); expect(response.status).toBe(302); expect(response.headers.get("Location")).toBe("/login?error=sso_state_invalid"); }); });