46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { flattenNavigationItems } from "./navigation";
|
|
|
|
describe("admin navigation sidebar preview boundary", () => {
|
|
it("does not build app sidebar links with an empty tenant slug", () => {
|
|
const source = readFileSync(join(process.cwd(), "apps/web/app/routes/admin/navigation.tsx"), "utf8");
|
|
|
|
expect(source).toContain("if (params.tenant)");
|
|
expect(source).not.toContain('tenantId: params.tenant || ""');
|
|
});
|
|
|
|
it("flattens sidebar children while keeping collapsible parents toggle-only", () => {
|
|
const items = flattenNavigationItems(
|
|
[
|
|
{
|
|
title: "Settings",
|
|
path: "/settings",
|
|
isCollapsible: true,
|
|
items: [
|
|
{ title: "Profile", path: "/settings/profile" },
|
|
{ title: "Hidden", path: "/settings/hidden", hidden: true },
|
|
],
|
|
},
|
|
{
|
|
title: "Accounts",
|
|
path: "/accounts",
|
|
items: [{ title: "Users", path: "/accounts/users" }],
|
|
},
|
|
],
|
|
true
|
|
);
|
|
|
|
expect(items.map((item) => item.path)).toEqual(["/settings/profile", "/accounts", "/accounts/users"]);
|
|
expect(items.every((item) => item.adminOnly)).toBe(true);
|
|
});
|
|
|
|
it("uses resolved sidebar labels directly instead of translating them again", () => {
|
|
const source = readFileSync(join(process.cwd(), "apps/web/app/routes/admin/navigation.tsx"), "utf8");
|
|
|
|
expect(source).toContain("{item.title}");
|
|
expect(source).not.toContain("{t(item.title)}");
|
|
});
|
|
});
|