import { describe, expect, it } from "vitest"; import { TEMPLATE_APP_MODULE } from "../../../src/apps/template-app.ts"; import { REFERENCE_FEATURE_CONTRACT } from "../../../src/features/reference-feature/contracts/reference-feature-contract.ts"; import { createAppRouteModules } from "../../../src/platform/routing/context-route-module.ts"; // 16-02. Other installed features bring their own contexts; only the // reference context is this sample's to check. const REFERENCE_CONTEXT_ID = "reference-context"; // X1 (2026-11-04). A product feature may join the reference context // (`create:feature --context reference-context`) and load its routes with // it; only the reference feature's own routes are this sample's to check. const REFERENCE_ROUTE_IDS: ReadonlySet = new Set( Object.keys(REFERENCE_FEATURE_CONTRACT.routes), ); describe("installed context routing", () => { it("boots one bounded-context entry instead of flattening feature routes", () => { const modules = createAppRouteModules(TEMPLATE_APP_MODULE); expect(modules.map((module) => module.id)).toContain(REFERENCE_CONTEXT_ID); expect(modules.some((module) => module.id === "REFERENCE_RESOURCE_LIST")).toBe(false); }); it("loads the reference feature routes lazily without changing public URLs", async () => { const context = createAppRouteModules(TEMPLATE_APP_MODULE).find( (module) => module.id === REFERENCE_CONTEXT_ID, ); expect(context).toBeDefined(); const routes = (await context!.loadRoutes()).filter((route) => REFERENCE_ROUTE_IDS.has(String(route.id)), ); expect(routes.map((route) => [route.id, route.path])).toEqual([ ["REFERENCE_RESOURCE_LIST", "/examples/reference-resources"], ["REFERENCE_RESOURCE_DETAIL", "/examples/reference-resources/items/:resourceId"], ["REFERENCE_RESOURCE_FORM", "/examples/reference-resources/new"], ["REFERENCE_RESOURCE_STATUS", "/examples/reference-resources/status"], ]); }); });