test(platform): run platform tests on a test-only feature, not the sample (14-01)

Six platform tests imported or named the removable reference feature, so
FE-GATE-020 failed on typecheck, unit, coverage, home smoke and residue.
Router surfaces now install tests/helpers/fixture-feature.tsx by mocking
the generated indexes; the rest use neutral names or read the installed
modules. test:sample-removal passes 13/13.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-25 21:18:39 +09:00
co-authored by Claude Opus 5.5
parent e771e5e032
commit 991da882e2
7 changed files with 195 additions and 36 deletions
+17 -16
View File
@@ -9,16 +9,17 @@ import { AppRouter } from "../../src/presentation/routes/app-router.tsx";
import { createTestApplication } from "../helpers/create-test-application.ts";
/**
* Three bounded contexts cut from the real reference routes, so canonical
* Three bounded contexts cut from the test-only feature's routes, so canonical
* redirects and access rules stay valid: A owns the list, B the status page,
* and the third one's routes module fails to download.
*/
vi.mock("../../src/.generated/product-feature-index.ts", async () => ({
PRODUCT_FEATURE_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_FEATURE_MODULE],
}));
vi.mock("../../src/apps/template-app.ts", async () => {
const { FEATURE_CONTEXT_ROUTES } = await import(
"../../src/features/reference-feature/context-routes.ts"
);
const { FIXTURE_CONTEXT_ROUTES } = await import("../helpers/fixture-feature.tsx");
const only = (id: string) => async () =>
FEATURE_CONTEXT_ROUTES.filter((route) => route.id === id);
FIXTURE_CONTEXT_ROUTES.filter((route) => route.id === id);
return {
TEMPLATE_APP_MODULE: {
id: "two-context-app",
@@ -27,21 +28,21 @@ vi.mock("../../src/apps/template-app.ts", async () => {
{
id: "context-a",
route: {
path: "examples/reference-resources/*",
loadRoutes: only("REFERENCE_RESOURCE_LIST"),
path: "fixture/items/*",
loadRoutes: only("FIXTURE_ITEMS"),
},
},
{
id: "context-b",
route: {
path: "examples/reference-resources/status/*",
loadRoutes: only("REFERENCE_RESOURCE_STATUS"),
path: "fixture/items/status/*",
loadRoutes: only("FIXTURE_ITEM_STATUS"),
},
},
{
id: "context-offline",
route: {
path: "examples/reference-resources/new/*",
path: "fixture/items/new/*",
loadRoutes: async () => {
throw new TypeError(
"Failed to fetch dynamically imported module: /assets/context-routes.js",
@@ -71,7 +72,7 @@ function reportedRoutes(record: ReturnType<typeof vi.fn>): string[] {
describe("context route gateway", () => {
it("never matches a new context's URL against the previous context's routes", async () => {
const record = vi.fn();
window.history.pushState({}, "", "/examples/reference-resources");
window.history.pushState({}, "", "/fixture/items");
render(
<ApplicationProvider
application={createTestApplication({ diagnostics: { record } })}
@@ -82,13 +83,13 @@ describe("context route gateway", () => {
</ApplicationProvider>,
);
await waitFor(() =>
expect(reportedRoutes(record)).toContain("REFERENCE_RESOURCE_LIST"),
expect(reportedRoutes(record)).toContain("FIXTURE_ITEMS"),
);
navigateByHistory("/examples/reference-resources/status");
navigateByHistory("/fixture/items/status");
await waitFor(() =>
expect(reportedRoutes(record)).toContain("REFERENCE_RESOURCE_STATUS"),
expect(reportedRoutes(record)).toContain("FIXTURE_ITEM_STATUS"),
);
expect(reportedRoutes(record)).not.toContain("NOT_FOUND");
});
@@ -101,11 +102,11 @@ describe("context route gateway", () => {
configSchemaVersion: "1",
apiContractVersion: "1",
assetManifestHash: "hash",
routeChunks: { "route-reference-resource-form": "assets/form.js" },
routeChunks: { "route-fixture-item-form": "assets/form.js" },
});
// The reload-once guard only trusts a marker it can read back (Q-6.9-9).
const stored = new Map<string, unknown>();
window.history.pushState({}, "", "/examples/reference-resources/new");
window.history.pushState({}, "", "/fixture/items/new");
render(
<ApplicationProvider
application={createTestApplication({
+11 -2
View File
@@ -15,6 +15,15 @@ import { PreferenceProviders } from "../../src/presentation/providers/preference
import { AppRouter } from "../../src/presentation/routes/app-router.tsx";
import { createTestApplication } from "../helpers/create-test-application.ts";
// Feature-route surfaces run against a test-only feature, not the removable
// sample (FE-GATE-020 runs the suite after deleting the sample).
vi.mock("../../src/.generated/product-feature-index.ts", async () => ({
PRODUCT_FEATURE_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_FEATURE_MODULE],
}));
vi.mock("../../src/.generated/product-context-index.ts", async () => ({
PRODUCT_CONTEXT_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_CONTEXT_MODULE],
}));
function deferred() {
let reject: (error: unknown) => void = () => {};
const promise = new Promise<void>((_, fail) => {
@@ -63,7 +72,7 @@ describe("route-level status surfaces", () => {
const user = userEvent.setup();
const pending = deferred();
const beginSignIn = vi.fn(() => pending.promise);
const { container } = renderApp("/examples/reference-resources#results", {
const { container } = renderApp("/fixture/items#results", {
session: sessionWithSignIn(beginSignIn),
});
@@ -80,7 +89,7 @@ describe("route-level status surfaces", () => {
await user.click(screen.getByRole("button", { name: "로그인 시작" }));
expect(beginSignIn).toHaveBeenCalledWith(
"/examples/reference-resources#results",
"/fixture/items#results",
);
expect(screen.getByRole("button", { name: "처리 중…" })).toBeDisabled();
+18 -9
View File
@@ -13,6 +13,15 @@ import { AppRouter } from "../../src/presentation/routes/app-router.tsx";
import { createTestApplication } from "../helpers/create-test-application.ts";
import { createProductFeaturesStub } from "../helpers/runtime-capabilities-stub.ts";
// Feature-route surfaces run against a test-only feature, not the removable
// sample (FE-GATE-020 runs this file after deleting the sample).
vi.mock("../../src/.generated/product-feature-index.ts", async () => ({
PRODUCT_FEATURE_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_FEATURE_MODULE],
}));
vi.mock("../../src/.generated/product-context-index.ts", async () => ({
PRODUCT_CONTEXT_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_CONTEXT_MODULE],
}));
function renderRouter(
diagnostics: ApplicationOutputPorts["diagnostics"] = { record: () => {} },
productFeatures?: ApplicationOutputPorts["productFeatures"],
@@ -141,23 +150,23 @@ describe("generic application router", () => {
it.each([
{
surface: "authentication-required",
url: "/examples/reference-resources",
routeId: "REFERENCE_RESOURCE_LIST",
title: "Reference resources · Frontend Skeleton",
url: "/fixture/items",
routeId: "FIXTURE_ITEMS",
title: "Fixture items · Frontend Skeleton",
disableFeature: false,
},
{
surface: "invalid-route",
url: "/examples/reference-resources?limit=invalid",
routeId: "REFERENCE_RESOURCE_LIST",
title: "Reference resources · Frontend Skeleton",
url: "/fixture/items?limit=invalid",
routeId: "FIXTURE_ITEMS",
title: "Fixture items · Frontend Skeleton",
disableFeature: false,
},
{
surface: "disabled-feature",
url: "/examples/reference-resources",
routeId: "REFERENCE_RESOURCE_LIST",
title: "Reference resources · Frontend Skeleton",
url: "/fixture/items",
routeId: "FIXTURE_ITEMS",
title: "Fixture items · Frontend Skeleton",
disableFeature: true,
},
])(
+131
View File
@@ -0,0 +1,131 @@
import type { RouteObject } from "react-router-dom";
import { z } from "zod";
import { defineBoundedContextModule } from "../../src/contexts/bounded-context-module.ts";
import { defineFeatureModule } from "../../src/features/feature-module.ts";
/**
* A test-only product feature for platform tests that need a feature route: one
* that requires a session, parses a search codec, and belongs to a feature the
* runtime can switch off. Those tests install it by mocking the generated
* indexes, so they do not depend on the removable sample feature (FE-GATE-020):
*
* vi.mock("../../src/.generated/product-feature-index.ts", async () => ({
* PRODUCT_FEATURE_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_FEATURE_MODULE],
* }));
* vi.mock("../../src/.generated/product-context-index.ts", async () => ({
* PRODUCT_CONTEXT_MODULES: [(await import("../helpers/fixture-feature.tsx")).FIXTURE_CONTEXT_MODULE],
* }));
*/
export const FIXTURE_FEATURE_ID = "fixture-feature";
function fixtureRoute(
routeId: string,
path: string,
searchSchema: string | null,
chunkId: string,
) {
return Object.freeze({
routeId,
path,
paramsSchema: null,
searchSchema,
access: "session-required",
loadingSurface: "fixture-page",
errorSurface: "feature-boundary",
chunkId,
title: routeId,
navigationLabel: null,
navigationOrder: null,
});
}
const FIXTURE_ROUTES = Object.freeze({
FIXTURE_ITEMS: fixtureRoute("FIXTURE_ITEMS", "/fixture/items", "FixtureItemsQuery", "route-fixture-items"),
FIXTURE_ITEM_STATUS: fixtureRoute("FIXTURE_ITEM_STATUS", "/fixture/items/status", null, "route-fixture-item-status"),
FIXTURE_ITEM_FORM: fixtureRoute("FIXTURE_ITEM_FORM", "/fixture/items/new", null, "route-fixture-item-form"),
});
const FIXTURE_TITLES: Readonly<Record<keyof typeof FIXTURE_ROUTES, string>> = {
FIXTURE_ITEMS: "Fixture items",
FIXTURE_ITEM_STATUS: "Fixture item status",
FIXTURE_ITEM_FORM: "Create fixture item",
};
const FIXTURE_MESSAGES = Object.freeze(
Object.fromEntries(
Object.entries(FIXTURE_TITLES).flatMap(([routeId, title]) => [
[`route.${routeId}.title`, title],
[`route.${routeId}.navigation`, title],
]),
),
);
export const FIXTURE_FEATURE_MODULE = defineFeatureModule({
id: FIXTURE_FEATURE_ID,
contracts: Object.freeze({
featureId: FIXTURE_FEATURE_ID,
routes: FIXTURE_ROUTES,
routeRuntimeContracts: Object.freeze(
Object.fromEntries(
Object.values(FIXTURE_ROUTES).map((route) => [
route.routeId,
Object.freeze({
routeId: route.routeId,
moduleId: `${route.chunkId}-page`,
paramsCodec: "none",
searchCodec: route.searchSchema ?? "none",
}),
]),
),
),
apiOperations: Object.freeze({}),
invalidation: Object.freeze({ topics: [], namespaces: [], edges: [] }),
topicVersions: Object.freeze([]),
schemas: Object.freeze({}),
runtimeSchemas: Object.freeze({}),
mappers: Object.freeze({}),
}),
routes: FIXTURE_ROUTES,
adapters: [],
runtimes: [
Object.freeze({
featureId: FIXTURE_FEATURE_ID,
routeCodecs: Object.freeze({
FixtureItemsQuery: z.object({
limit: z.coerce.number().int().min(1).max(100).default(20),
}),
}),
routeRuntime: Object.freeze({}),
}),
],
messages: Object.freeze({ "ko-KR": FIXTURE_MESSAGES, "en-US": FIXTURE_MESSAGES }),
contractContributions: [],
});
function FixturePage() {
return <p>Fixture page</p>;
}
export const FIXTURE_CONTEXT_ROUTES: readonly RouteObject[] = Object.freeze(
Object.values(FIXTURE_ROUTES).map((route) =>
Object.freeze({
id: route.routeId,
path: route.path,
handle: Object.freeze({
routeId: route.routeId,
runtime: Object.freeze({ moduleId: `${route.chunkId}-page`, Component: FixturePage }),
}),
}),
),
);
export const FIXTURE_CONTEXT_MODULE = defineBoundedContextModule({
id: "fixture-context",
features: [FIXTURE_FEATURE_MODULE],
budget: { maxFeatures: 1 },
route: {
path: "fixture/items/*",
loadRoutes: async () => FIXTURE_CONTEXT_ROUTES,
},
});
@@ -38,9 +38,9 @@ describe("redactTelemetryPayload", () => {
it("keeps legitimate telemetry values and innocent keys untouched", () => {
const legitimate = {
reason: "REQUEST_TIMEOUT",
operation: "LIST_REFERENCE_RESOURCES",
routeId: "reference.resources.detail",
featureId: "reference-feature",
operation: "LIST_ORDER_ITEMS",
routeId: "orders.items.detail",
featureId: "order-feature",
resourceId: "01J8Z3K7Q9W4N2B6C5D1E0F7GH",
uuid: "3f2a9c1e-5b7d-4e8f-9a0b-1c2d3e4f5a6b",
traceHex: "4bf92f3577b34da6a3ce929d0e0e4736",
+14 -5
View File
@@ -4,13 +4,22 @@ import {
composeInstalledMessageCatalogs,
INSTALLED_MESSAGE_CATALOGS,
} from "../../src/features/installed-feature-messages.ts";
import { REFERENCE_MESSAGE_CATALOGS } from "../../src/features/reference-feature/contracts/reference-message-catalog.ts";
import { INSTALLED_PRODUCT_FEATURE_MODULES } from "../../src/features/installed-product-manifest.ts";
describe("installed feature message catalogs (Q-6.9-12)", () => {
it("keeps the installed ko-KR and en-US catalogs", () => {
expect(Object.keys(INSTALLED_MESSAGE_CATALOGS).sort()).toEqual(["en-US", "ko-KR"]);
expect(INSTALLED_MESSAGE_CATALOGS["ko-KR"]).toEqual(REFERENCE_MESSAGE_CATALOGS["ko-KR"]);
expect(INSTALLED_MESSAGE_CATALOGS["en-US"]).toEqual(REFERENCE_MESSAGE_CATALOGS["en-US"]);
it("keeps every message each installed feature declares", () => {
// Read from the installed modules, not a named sample: the catalog is
// empty once the sample is removed (FE-GATE-020), and that is still valid.
const locales = new Set(
INSTALLED_PRODUCT_FEATURE_MODULES.flatMap((module) => Object.keys(module.messages)),
);
expect(Object.keys(INSTALLED_MESSAGE_CATALOGS).sort()).toEqual([...locales].sort());
for (const module of INSTALLED_PRODUCT_FEATURE_MODULES) {
for (const [locale, catalog] of Object.entries(module.messages)) {
expect(INSTALLED_MESSAGE_CATALOGS[locale as keyof typeof INSTALLED_MESSAGE_CATALOGS])
.toMatchObject(catalog);
}
}
});
it("composes every locale a feature declares, not a fixed list", () => {
+1 -1
View File
@@ -87,7 +87,7 @@ describe("shared operationId and status-group grammar", () => {
it.each([
"getUser",
"LIST_REFERENCE_RESOURCES",
"LIST_ORDER_ITEMS",
"users.v1.get-item",
`a${"b".repeat(127)}`,
])("keeps both observability records for operationId %s", (operationId) => {