문제
fb20699의 새 테스트는 보호 라우트 하나를 찾아 단언하고, 없으면 실패한다.
참조 기능을 지운 제거 fixture에는 보호 라우트가 없어서, test:sample-removal
(snapshot fd11d08)의 test:all과 test:coverage가 이 테스트 하나로 실패했다.
고른 방법
- 같은 파일의 "every non-public route" 반복 안에서 recovery-pending과
authenticated를 함께 단언한다. 라우트가 있는 템플릿에서는 같은 변이를 잡고,
보호 라우트가 없는 구성에서는 다른 단언처럼 대상이 없다.
검증
- 파일 4건 통과. 변이 L02(wait-for-session → show-sign-in)를 넣으면 그 반복
테스트가 실패한다(되돌림). eslint 통과.
- snapshot fd11d08의 test:sample-removal: 이 테스트 말고 실패한 검사가
없었다(documentation·lint·i18n·design-system 포함).
Refs: docs/reviews/2026-11-03-maturity-review/10-tests-fast-layers.md 1101/10-03
72 lines
2.5 KiB
TypeScript
72 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
NAVIGATION_ROUTES,
|
|
ROUTE_REGISTRY,
|
|
} from "../../src/features/installed-feature-contracts.ts";
|
|
import type { RouteDefinition } from "../../src/contracts/routes.ts";
|
|
import {
|
|
createRedirectLoopGuard,
|
|
decideRouteAccess,
|
|
} from "../../src/presentation/routes/navigation-policy.ts";
|
|
|
|
describe("installed route registry", () => {
|
|
it("derives visible navigation in explicit order", () => {
|
|
const expected = Object.values(ROUTE_REGISTRY)
|
|
.filter((route) => route.navigationOrder !== null)
|
|
.sort(
|
|
(left, right) =>
|
|
left.navigationOrder! - right.navigationOrder!,
|
|
)
|
|
.map((route) => route.routeId);
|
|
expect(NAVIGATION_ROUTES.map(({ routeId }) => routeId)).toEqual(expected);
|
|
});
|
|
|
|
it("allows public routes without consulting a product permission", () => {
|
|
expect(decideRouteAccess("APP_HOME", "unauthenticated")).toEqual({
|
|
allowed: true,
|
|
action: "none",
|
|
});
|
|
});
|
|
|
|
it("treats every non-public route as explicitly session-required", () => {
|
|
const protectedRoutes = Object.values(
|
|
ROUTE_REGISTRY as Readonly<Record<string, RouteDefinition>>,
|
|
).filter((route) => route.access !== "public");
|
|
|
|
expect(
|
|
protectedRoutes.every((route) => route.access === "session-required"),
|
|
).toBe(true);
|
|
for (const route of protectedRoutes) {
|
|
expect(route.access).toBe("session-required");
|
|
expect(decideRouteAccess(route.routeId, "unauthenticated")).toEqual({
|
|
allowed: false,
|
|
action: "show-sign-in",
|
|
});
|
|
// 1101/10-03. A session still being recovered waits; showing sign-in
|
|
// there would bounce a returning user out of a page they may enter.
|
|
expect(decideRouteAccess(route.routeId, "recovery-pending")).toEqual({
|
|
allowed: false,
|
|
action: "wait-for-session",
|
|
});
|
|
expect(decideRouteAccess(route.routeId, "authenticated")).toEqual({
|
|
allowed: true,
|
|
action: "none",
|
|
});
|
|
}
|
|
});
|
|
|
|
it("bounds automatic redirects by pair and maximum hops", () => {
|
|
const guard = createRedirectLoopGuard(2);
|
|
expect(guard.allow("/private", "/signin")).toBe(true);
|
|
expect(guard.allow("/private", "/signin")).toBe(false);
|
|
expect(guard.allow("/signin", "/signin")).toBe(false);
|
|
expect(guard.allow("/signin", "/continue")).toBe(true);
|
|
expect(guard.allow("/continue", "/final")).toBe(false);
|
|
expect(guard.hopCount).toBe(2);
|
|
|
|
guard.reset();
|
|
expect(guard.allow("/unrelated", "/canonical-unrelated")).toBe(true);
|
|
});
|
|
});
|