test(features): 제품 확장 타입 검사 탐침이 제품 이름·파일·제거 상태와 겹치지 않는다
문제 tests/unit/product-extension-typecheck.test.ts(1103/09-02)는 복사본에 제품 파일과 기능 하나를 넣고 tsc 세 프로그램을 돈다. 세 가지가 제품과 제거 드릴에서 깨진다(리뷰 조치 X2 #1, #7). - 탐침 ID가 notice-feature·notice-context다. 매뉴얼 예시가 모두 "공지"라 제품이 같은 ID를 쓰면 FE-GATE-005가 원인을 말하지 않는 TS 오류 약 20줄로 실패한다. - product-capabilities.ts가 템플릿의 빈 선언 그대로여야 한다고 단언하고 그 선언을 바꿔 쓴다. 자기 capability를 적은 제품에서 실패한다. - 복사 대상을 모두 복사한다. test:optional-recipe-removal의 fixture에는 recipes/가 없어 ENOENT로 떨어진다. 고른 방법 - 탐침 이름을 typecheck-probe-*(capability typecheckProbeSettings, 설정 키 TYPECHECK_PROBE_PAGE_SIZE)로 바꾸고, 그 기능 폴더가 이미 있으면 이름을 말하며 실패한다. - capability 타입은 제품 파일 끝에 같은 이름 interface로 덧붙인다. TypeScript가 합치므로 제품의 선언이 남는다. - 없는 복사 대상은 건너뛴다. 위험·한계 - product-contracts.ts·product-composition.ts는 여전히 탐침 내용으로 바꿔 쓴다. 제품 기능이 이 두 파일의 이름 있는 export를 import하면 복사본에서 타입 오류가 날 수 있다. 검증 - 테스트 통과, eslint 통과. Refs: docs/reviews/2026-11-03-maturity-review/09-app-core.md 09-02, README.md 14.6 X2
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync } from "node:fs";
|
||||
import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
@@ -23,21 +24,29 @@ import { REMOVAL_FIXTURE_COPY_TARGETS } from "../../scripts/lib/removal-fixture.
|
||||
* own tests must not have to spell out.
|
||||
*
|
||||
* Only product-owned files and the feature's own directory are written.
|
||||
*
|
||||
* The probe's names (`typecheck-probe-*`) are reserved for it: they are not
|
||||
* the manual's example names, which a product may well use (1103 X2 #1). The
|
||||
* capability type is appended to the product's own declaration, which a
|
||||
* TypeScript interface merges, so a product that already declares
|
||||
* capabilities keeps them.
|
||||
*/
|
||||
/** Filled into the shipped `product-capabilities.ts`, the rest kept. */
|
||||
const PRODUCT_CAPABILITY_TYPES = `export interface ProductFeaturePlatformCapabilities {
|
||||
readonly noticeSettings: Readonly<{ pageSize(): number }>;
|
||||
}`;
|
||||
/** Appended to the product's own `product-capabilities.ts`. */
|
||||
const PRODUCT_CAPABILITY_TYPES = `
|
||||
export interface ProductFeaturePlatformCapabilities {
|
||||
readonly typecheckProbeSettings: Readonly<{ pageSize(): number }>;
|
||||
}
|
||||
`;
|
||||
|
||||
const PRODUCT_CONTRACTS = `import { z } from "./zod.ts";
|
||||
|
||||
/** Product-owned. Filled by the 1103/09-02 typecheck fixture. */
|
||||
export const PRODUCT_RUNTIME_CONFIG_FIELDS = Object.freeze({
|
||||
NOTICE_PAGE_SIZE: z.int().min(1).max(100).default(20),
|
||||
TYPECHECK_PROBE_PAGE_SIZE: z.int().min(1).max(100).default(20),
|
||||
});
|
||||
|
||||
export const PRODUCT_ENV_REGISTRY = Object.freeze({
|
||||
NOTICE_PAGE_SIZE: {
|
||||
TYPECHECK_PROBE_PAGE_SIZE: {
|
||||
phase: "runtime",
|
||||
classification: "public",
|
||||
required: false,
|
||||
@@ -63,18 +72,18 @@ export function composeProductSessionOwner(
|
||||
}
|
||||
|
||||
export function composeProduct(context: ProductCompositionContext) {
|
||||
const pageSize = context.config.NOTICE_PAGE_SIZE;
|
||||
const pageSize = context.config.TYPECHECK_PROBE_PAGE_SIZE;
|
||||
return {
|
||||
capabilities: {
|
||||
noticeSettings: Object.freeze({ pageSize: () => pageSize }),
|
||||
typecheckProbeSettings: Object.freeze({ pageSize: () => pageSize }),
|
||||
},
|
||||
credentialProviders: {},
|
||||
} satisfies ProductComposition;
|
||||
}
|
||||
`;
|
||||
|
||||
const FEATURE_ID = "notice-feature";
|
||||
const CONTEXT_ID = "notice-context";
|
||||
const FEATURE_ID = "typecheck-probe-feature";
|
||||
const CONTEXT_ID = "typecheck-probe-context";
|
||||
|
||||
const FEATURE_MODULE = `import { defineFeatureModule } from "../feature-module.ts";
|
||||
|
||||
@@ -99,8 +108,8 @@ export const FEATURE_MODULE = defineFeatureModule({
|
||||
// Both locales: with the sample features removed (test:sample-removal)
|
||||
// this is the only catalog the message key types come from.
|
||||
messages: {
|
||||
"ko-KR": { "notice.title": "공지" },
|
||||
"en-US": { "notice.title": "Notice" },
|
||||
"ko-KR": { "typecheckProbe.title": "타입 검사 탐침" },
|
||||
"en-US": { "typecheckProbe.title": "Typecheck probe" },
|
||||
},
|
||||
loadRuntime: async () => (await import("./feature-runtime.ts")).FEATURE_RUNTIME,
|
||||
} as const);
|
||||
@@ -109,11 +118,11 @@ export const FEATURE_MODULE = defineFeatureModule({
|
||||
const FEATURE_RUNTIME = `import { defineFeatureAdapterContribution } from "../feature-adapter-contribution.ts";
|
||||
import { defineFeatureRuntime } from "../feature-module.ts";
|
||||
|
||||
type NoticeFeatureInput = Readonly<{ pageSize(): number }>;
|
||||
type TypecheckProbeInput = Readonly<{ pageSize(): number }>;
|
||||
|
||||
declare module "../../application/ports/in/application-api.ts" {
|
||||
interface ApplicationFeatureInputs {
|
||||
"${FEATURE_ID}": NoticeFeatureInput;
|
||||
"${FEATURE_ID}": TypecheckProbeInput;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,11 +132,11 @@ export const FEATURE_RUNTIME = defineFeatureRuntime({
|
||||
adapters: [
|
||||
defineFeatureAdapterContribution({
|
||||
featureId: "${FEATURE_ID}",
|
||||
needs: ["noticeSettings"] as const,
|
||||
createInput: ({ noticeSettings }) =>
|
||||
needs: ["typecheckProbeSettings"] as const,
|
||||
createInput: ({ typecheckProbeSettings }) =>
|
||||
Object.freeze({
|
||||
featureId: "${FEATURE_ID}",
|
||||
input: Object.freeze({ pageSize: () => noticeSettings.pageSize() }),
|
||||
input: Object.freeze({ pageSize: () => typecheckProbeSettings.pageSize() }),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
@@ -142,7 +151,7 @@ export const FEATURE_CONTEXT_ROUTES: readonly RouteObject[] = Object.freeze([]);
|
||||
|
||||
const CONTEXT_MODULE = `export const CONTEXT_MODULE_ID = "${CONTEXT_ID}";
|
||||
export const CONTEXT_APP_ID = "template-app";
|
||||
export const CONTEXT_ROUTE_PATH = "notice/*";
|
||||
export const CONTEXT_ROUTE_PATH = "typecheck-probe/*";
|
||||
export const CONTEXT_MAX_FEATURES = 1;
|
||||
`;
|
||||
|
||||
@@ -156,8 +165,12 @@ describe("1103/09-02 a product filled through its own files typechecks", () => {
|
||||
it("passes the app, node and test programs", async () => {
|
||||
const root = await mkdtemp(path.join(tmpdir(), "product-extension-typecheck-"));
|
||||
roots.push(root);
|
||||
// The repository's one copy-target list for a fixture copy.
|
||||
// The repository's one copy-target list for a fixture copy. A removal
|
||||
// drill runs this test in a copy that has already lost some of them
|
||||
// (test:optional-recipe-removal deletes recipes/).
|
||||
expect(existsSync(path.resolve("src/features", FEATURE_ID)), FEATURE_ID).toBe(false);
|
||||
for (const entry of REMOVAL_FIXTURE_COPY_TARGETS) {
|
||||
if (!existsSync(path.resolve(entry))) continue;
|
||||
await cp(path.resolve(entry), path.join(root, entry), {
|
||||
recursive: true,
|
||||
filter: (source) => !source.includes(`${path.sep}.generated`),
|
||||
@@ -165,10 +178,8 @@ describe("1103/09-02 a product filled through its own files typechecks", () => {
|
||||
}
|
||||
await linkFixtureNodeModules(root);
|
||||
const shipped = await readFile(path.resolve("src/features/product-capabilities.ts"), "utf8");
|
||||
const emptyTypes = "export interface ProductFeaturePlatformCapabilities {}";
|
||||
expect(shipped.split(emptyTypes)).toHaveLength(2);
|
||||
const files: Readonly<Record<string, string>> = {
|
||||
"src/features/product-capabilities.ts": shipped.replace(emptyTypes, PRODUCT_CAPABILITY_TYPES),
|
||||
"src/features/product-capabilities.ts": `${shipped}${PRODUCT_CAPABILITY_TYPES}`,
|
||||
"src/contracts/product-contracts.ts": PRODUCT_CONTRACTS,
|
||||
"src/bootstrap/product-composition.ts": PRODUCT_COMPOSITION,
|
||||
[`src/contexts/${CONTEXT_ID}/context-module.ts`]: CONTEXT_MODULE,
|
||||
|
||||
Reference in New Issue
Block a user