import { describe, expect, it } from "vitest"; import { ROUTE_FEATURE_OWNER, ROUTE_REGISTRY, } from "../../src/features/installed-feature-contracts.ts"; import { ROUTE_RUNTIME } from "../../src/features/installed-feature-runtimes.tsx"; import { INSTALLED_PRODUCT_FEATURE_IDS } from "../../src/features/installed-product-manifest.ts"; /** * §3.5. The runtime kill switch, as it applies to *this* product. * * The template asserted the switch end to end by rendering the reference * feature's screens and taking them out of service. This product deleted those * screens during the UI migration, so that render is no longer possible: the * feature contributes API operations, schemas and mappers, but no route. * * Deleting the test with the screens would have removed the only thing watching * this seam, so what is asserted here is the invariant that survives the * migration and would have caught the trap the merge itself nearly introduced — * a route registered from a feature contract whose component no longer exists. * The moment a feature-owned route is registered again, the second test starts * asserting the switch end to end without being rewritten. */ describe("runtime product feature switch", () => { it("registers no route that cannot be mounted", () => { const unmountable = Object.keys(ROUTE_REGISTRY).filter( (routeId) => !(routeId in ROUTE_RUNTIME), ); expect(unmountable).toEqual([]); }); it("keeps every feature-owned route inside the installed selection", () => { // A route owned by a feature the manifest did not install would be // reachable with nothing behind it. const orphaned = Object.entries(ROUTE_FEATURE_OWNER) .filter(([routeId]) => routeId in ROUTE_REGISTRY) .filter(([, featureId]) => !INSTALLED_PRODUCT_FEATURE_IDS.includes(featureId)); expect(orphaned).toEqual([]); }); it("still declares a product manifest to narrow", () => { // The switch is only meaningful while something is selectable; if this ever // empties, the mechanism above is dead code rather than a guarantee. expect(INSTALLED_PRODUCT_FEATURE_IDS.length).toBeGreaterThan(0); }); });