Files
tech-log-frontend/tests/features/tech-log/navigation-derivation.test.ts
T

71 lines
2.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { techLogNavigation } from "../../../src/features/tech-log/presentation/tech-log-navigation.ts";
import { TECH_LOG_ROUTE_REGISTRY } from "../../../src/features/tech-log/contracts/tech-log-route-contract.ts";
import { TECH_LOG_MESSAGE_CATALOGS } from "../../../src/features/tech-log/contracts/tech-log-message-catalog.ts";
/**
* The headers used to repeat the route contract's navigation facts in their own
* literal arrays, so a renamed route or a reordered menu could be right in one
* place and stale in the other. These pin the derived result against the shape
* the headers rendered before the change, and against the contract itself.
*/
describe("TechLog navigation derivation", () => {
it("derives the public menu in contract order", () => {
expect(
techLogNavigation("PUBLIC").map((entry) => [
TECH_LOG_MESSAGE_CATALOGS["ko-KR"][entry.messageKey],
entry.path,
]),
).toEqual([
["탐색", "/explore"],
["주제", "/topics"],
["프로젝트", "/projects"],
["프로필", "/profile"],
]);
});
it("derives the studio menu in contract order", () => {
expect(
techLogNavigation("STUDIO").map((entry) => [
TECH_LOG_MESSAGE_CATALOGS["ko-KR"][entry.messageKey],
entry.path,
]),
).toEqual([
["작업본", "/studio/documents"],
["게시 기록", "/studio/publications"],
["새 문서", "/studio/documents/new"],
["주제·프로젝트", "/studio/taxonomy"],
["Asset", "/studio/assets"],
["릴리즈", "/studio/releases"],
]);
});
it("advertises exactly the routes the contract marks navigable", () => {
const navigable = Object.values(TECH_LOG_ROUTE_REGISTRY)
.filter((definition) => definition.navigationOrder !== null)
.map((definition) => definition.routeId)
.sort();
const derived = [
...techLogNavigation("PUBLIC"),
...techLogNavigation("STUDIO"),
]
.map((entry) => entry.routeId)
.sort();
expect(derived).toEqual(navigable);
});
it("keeps each shell's entries inside its own layout group", () => {
for (const group of ["PUBLIC", "STUDIO"] as const) {
for (const entry of techLogNavigation(group)) {
expect(
TECH_LOG_ROUTE_REGISTRY[
entry.routeId as keyof typeof TECH_LOG_ROUTE_REGISTRY
]?.layoutGroup,
entry.routeId,
).toBe(group);
}
}
});
});