Carries 359 template commits, tag v0.2.0 plus one documentation commit: the generator-built feature index with its app, bounded-context and feature declarations, the src/platform kernel and scale tooling, the 2026-09-24 src review fixes, and the 2026-09-25 maturity review round with its CHANGELOG [보안]/[계약] rows. 691 of the 824 template paths are applied, 85 of them merged with product changes; 127 are not carried. Product identity is unchanged: name, version 0.1.0, routes, design and the TechLog domain. Three decisions worth naming. TechLog stays composed directly, as the last two syncs recorded; its directory carries a NOT_INSTALLED marker that says so, and every installed-* composer takes the template's projection with TechLog added on top. The reference sample is no longer installed: the template now installs a feature only through feature-module.ts and context-routes.ts, which load the screens this product deleted, so its three operations, six schemas and one topic leave the registries, recorded as registry change evidence. And AppRouter mounts the platform and TechLog routes only; the template's bounded-context route gateway waits for a generator-installed feature. Required fixes: readSubject on the BFF session owner (without it every HTTP Studio session would close as integration-failed), zod through the facade in nine TechLog files, noUnusedLocals, and public/config.json written out to match the local profile. Derived baselines were recomputed after reproducing both sides' values: CI contract 101 commands / 106 references / 141 artifacts, gate shape c9adcf85; registry approval 2dc6c3a3; the runtime config schema baseline equals the schema at8210d48. Verified here: types, lint, architecture, adapter inventory, CI contract, i18n, design system, diagnostics, browser security, dev release manifest, TechLog contract and build pass; 220 component, 155 integration, 15 contract, 418 TechLog, 43 reference-feature, 18 recipe and 46 release-coherence tests pass, and 2381 of 2383 unit tests. Reproduced at8210d48first and unchanged: check:registries (byte-identical), test:runtime-schema, verify:documentation. Brought by the template and escalated rather than suppressed: check:request-fanout on TechLog's cursor pagination, check:remediation-ledger (fails upstream too), the shared-chunk hash test, and the registry-dependent sample removal and second-feature tests. Playwright suites were not run. Full record, the five open questions and the follow-ups in docs/operations/template-sync-2026-09-29.md. (cherry picked from commit b2170cf265dea45dc9cc05d3c61e627e97f31cdb)
167 lines
6.7 KiB
TypeScript
167 lines
6.7 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { createAnonymousSessionAdapter } from "../../src/adapters/auth/external-session-adapter.ts";
|
|
import type { ApplicationOutputPorts } from "../../src/application/create-application.ts";
|
|
import { createTechLogFeatureInstalledInput } from "../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
|
|
import { PreferenceProviders } from "../../src/presentation/providers/preference-providers.tsx";
|
|
import { MOCK_STUDIO_INSTALL_CONTEXT } from "../helpers/studio-install-context.ts";
|
|
import { createTestApplication } from "../helpers/create-test-application.ts";
|
|
|
|
/**
|
|
* §3.5. The runtime kill switch, exercised through the running app.
|
|
*
|
|
* Withdrawing a feature from navigation is not the same as taking it out of
|
|
* service: a typed deep link would still mount it. Both halves are asserted on
|
|
* the same render, so the switch cannot be half-wired.
|
|
*
|
|
* The template asserted this by rendering its own demonstration screens. Those
|
|
* screens exist to explain the template, and a product replaces them with its
|
|
* domain — so a test that needs them makes deleting them look like a
|
|
* regression. It is not: the mechanism under test is the ownership lookup plus
|
|
* `isFeatureActive`, and neither has anything to do with which screens ship.
|
|
*
|
|
* So the ownership map is the fixture. `ROUTE_FEATURE_OWNER` is empty in this
|
|
* product because no installed feature contributes a route; one real registered
|
|
* route is attributed to a feature here, and everything else — router, shell,
|
|
* components, codecs — is the product's own.
|
|
*
|
|
* Template sync (af3d8e6). No feature is generator-installed here any more
|
|
* (the sample carries NOT_INSTALLED), so the runtime's feature port is the
|
|
* other half of the fixture: it reports the owner active or switched off.
|
|
*/
|
|
|
|
const OWNED_ROUTE_ID = "TECH_LOG_EXPLORE";
|
|
const OWNER_FEATURE_ID = "fixture-feature";
|
|
const OWNED_ROUTE_PATH = "/explore";
|
|
|
|
vi.mock("../../src/features/installed-feature-contracts.ts", async (original) => {
|
|
const actual = await original<
|
|
typeof import("../../src/features/installed-feature-contracts.ts")
|
|
>();
|
|
return {
|
|
...actual,
|
|
ROUTE_FEATURE_OWNER: Object.freeze({
|
|
[OWNED_ROUTE_ID]: OWNER_FEATURE_ID,
|
|
}),
|
|
};
|
|
});
|
|
|
|
const { AppRouter } = await import("../../src/presentation/routes/app-router.tsx");
|
|
const { ApplicationProvider } = await import(
|
|
"../../src/presentation/providers/application-provider.tsx"
|
|
);
|
|
const { renderWithQueryProviders } = await import("../helpers/query-providers.tsx");
|
|
|
|
function ownerFeaturePort(
|
|
disabled: boolean,
|
|
): ApplicationOutputPorts["productFeatures"] {
|
|
const status = Object.freeze({
|
|
featureId: OWNER_FEATURE_ID,
|
|
state: disabled ? ("DISABLED_BY_CONFIG" as const) : ("ACTIVE" as const),
|
|
});
|
|
return Object.freeze({
|
|
getSnapshot: () => Object.freeze([status]),
|
|
isActive: (featureId: string) => featureId === OWNER_FEATURE_ID && !disabled,
|
|
});
|
|
}
|
|
|
|
function renderAt(path: string, disabled: boolean) {
|
|
window.history.pushState({}, "", path);
|
|
return render(
|
|
renderWithQueryProviders(
|
|
<ApplicationProvider
|
|
application={createTestApplication({
|
|
session: createAnonymousSessionAdapter(),
|
|
featureInputs: { "tech-log": createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input },
|
|
productFeatures: ownerFeaturePort(disabled),
|
|
})}
|
|
>
|
|
<PreferenceProviders>
|
|
<AppRouter />
|
|
</PreferenceProviders>
|
|
</ApplicationProvider>,
|
|
),
|
|
);
|
|
}
|
|
|
|
function outOfServiceSurface() {
|
|
return screen.queryByText(
|
|
(_, element) =>
|
|
element?.getAttribute("data-disabled-feature") === OWNER_FEATURE_ID,
|
|
);
|
|
}
|
|
|
|
describe("runtime product feature switch", () => {
|
|
it("takes the owned route out of service for a direct deep link", async () => {
|
|
renderAt(OWNED_ROUTE_PATH, true);
|
|
const surface = await screen.findByText(
|
|
(_, element) =>
|
|
element?.getAttribute("data-disabled-feature") === OWNER_FEATURE_ID,
|
|
{},
|
|
{ timeout: 5000 },
|
|
);
|
|
expect(surface).toBeTruthy();
|
|
});
|
|
|
|
it("serves the same deep link while the feature is active", async () => {
|
|
renderAt(OWNED_ROUTE_PATH, false);
|
|
expect(outOfServiceSurface()).toBeNull();
|
|
});
|
|
});
|
|
|
|
/**
|
|
* Composition invariants that hold whichever screens a product ships. The first
|
|
* one is what caught a bad merge resolution: composing the route registry from
|
|
* every installed feature's `contract.routes` registered the reference
|
|
* feature's paths after this product had deleted their components.
|
|
*/
|
|
describe("route composition", () => {
|
|
it("registers no route that cannot be mounted", async () => {
|
|
const { ROUTE_REGISTRY } = await vi.importActual<
|
|
typeof import("../../src/features/installed-feature-contracts.ts")
|
|
>("../../src/features/installed-feature-contracts.ts");
|
|
const { ROUTE_RUNTIME } = await import(
|
|
"../../src/features/installed-feature-runtimes.tsx"
|
|
);
|
|
const unmountable = Object.keys(ROUTE_REGISTRY).filter(
|
|
(routeId) => !(routeId in ROUTE_RUNTIME),
|
|
);
|
|
expect(unmountable).toEqual([]);
|
|
});
|
|
|
|
/**
|
|
* The other half of the switch — withdrawing a disabled feature's entry from
|
|
* navigation — lives in the template's `PrimaryNavigation`, which this
|
|
* product does not render: TechLog's public header is a hand-written list of
|
|
* paths, and the studio shell has its own. So the withdrawal half is not
|
|
* implemented here.
|
|
*
|
|
* That is harmless only while no feature-owned route is navigable, which is
|
|
* what this asserts. If it fails, the header has to consult
|
|
* `ROUTE_FEATURE_OWNER` (or navigation has to move back onto
|
|
* `NAVIGATION_ROUTES`) before that route ships — otherwise a disabled
|
|
* feature would keep advertising a link to a page that refuses to load.
|
|
*/
|
|
it("has no navigable feature-owned route while the shell is not feature-aware", async () => {
|
|
const actual = await vi.importActual<
|
|
typeof import("../../src/features/installed-feature-contracts.ts")
|
|
>("../../src/features/installed-feature-contracts.ts");
|
|
const navigableOwned = actual.NAVIGATION_ROUTES.filter(
|
|
(definition) => actual.ROUTE_FEATURE_OWNER[definition.routeId] !== undefined,
|
|
).map((definition) => definition.routeId);
|
|
expect(navigableOwned).toEqual([]);
|
|
});
|
|
|
|
it("attributes ownership only to routes the product registered", async () => {
|
|
const actual = await vi.importActual<
|
|
typeof import("../../src/features/installed-feature-contracts.ts")
|
|
>("../../src/features/installed-feature-contracts.ts");
|
|
for (const routeId of Object.keys(actual.ROUTE_FEATURE_OWNER)) {
|
|
expect(Object.keys(actual.ROUTE_REGISTRY)).toContain(routeId);
|
|
}
|
|
});
|
|
});
|