fabro/apps/fabro-web/app/router.test.tsx
Bryan Helmkamp 96359f95cb Fix login route collision after SPA cutover
Move the browser sign-in page off the backend /auth namespace so direct
navigation works, update Rust and frontend redirects to /login, and add
tests that lock the split between SPA login UI and backend OAuth endpoints.
2026-04-01 21:55:30 -07:00

28 lines
891 B
TypeScript

import { describe, expect, test } from "bun:test";
import type { RouteObject } from "react-router";
import { routes } from "./router";
function collectPaths(routeObjects: RouteObject[], prefix = ""): string[] {
return routeObjects.flatMap((route) => {
const path = route.index
? prefix || "/"
: route.path
? route.path.startsWith("/")
? route.path
: `${prefix}/${route.path}`.replace(/\/+/g, "/")
: prefix;
const childPaths = route.children ? collectPaths(route.children, path) : [];
return route.path || route.index ? [path, ...childPaths] : childPaths;
});
}
describe("browser router", () => {
test("uses /login for the sign-in page instead of the backend auth namespace", () => {
const paths = collectPaths(routes);
expect(paths).toContain("/login");
expect(paths).not.toContain("/auth/login");
});
});