mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-11 22:53:00 +00:00
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
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");
|
|
});
|
|
|
|
test("exposes /setup but not the removed /setup/complete route", () => {
|
|
const paths = collectPaths(routes);
|
|
|
|
expect(paths).toContain("/setup");
|
|
expect(paths).not.toContain("/setup/complete");
|
|
});
|
|
|
|
test("exposes the monitoring settings page", () => {
|
|
const paths = collectPaths(routes);
|
|
|
|
expect(paths).toContain("/settings/monitoring");
|
|
});
|
|
|
|
test("exposes MCP server settings pages", () => {
|
|
const paths = collectPaths(routes);
|
|
|
|
expect(paths).toContain("/settings/mcps");
|
|
expect(paths).toContain("/settings/mcps/new");
|
|
expect(paths).toContain("/settings/mcps/:id/edit");
|
|
});
|
|
});
|