frontend-quality-gates / merge / static checks (pull_request) Successful in 2m50s
frontend-quality-gates / merge / tests (pull_request) Failing after 14m15s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 10m29s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
frontend-quality-gates / main / checker self-tests (pull_request) Skipped
템플릿 시험과 드릴이 저장소 사본에 고정 ID로 기능을 만든다. 매뉴얼 코드 조각 시험은 매뉴얼 예시 invoice-feature를(FE-GATE-005), 생성 기능 e2e·청크 복구·부팅 실패 spec은 order-feature를(FE-GATE-008), scaffold 드릴은 scaffold-feature를(FE-GATE-020) 쓴다. 사본에는 제품 기능이 들어 있고 create:feature는 같은 ID나 같은 접두어를 거부한다. 그래서 매뉴얼 1단계 예시대로 invoice-feature를 만든 제품은 기능 코드와 상관없이 merge 게이트에서 막힌다. 고른 방법: 사본에 만드는 기능 ID를 모두 이미 정한 예약 접두어 typecheck-probe-로 옮기고 scripts/lib/template-probe-features.ts 한 곳에 둔다. 매뉴얼 조각은 invoice-feature 기준 그대로 두고, 시험이 조각과 검사 파일의 이름(INVOICE_, Invoice, invoice-, invoice)을 예약 기능의 이름으로 바꿔 넣는다(renameFeatureText). 생성 기능 e2e는 메시지 키와 계약 이름을 ID에서 만든다. 버린 대안: 사본에서 제품의 같은 이름 기능을 먼저 지우기(등록·조립 파일까지 지워야 해 사본이 제품과 달라진다), create:feature가 흔한 이름을 거부하기(제품 이름을 막는다). 위험·한계: 이름 바꾸기는 낱말 단위 치환이라 조각의 영어 문장 속 invoice도 바뀐다(조각과 검사가 함께 바뀌어 결과는 같다). 제품이 typecheck-probe-로 시작하는 기능을 만들면 다시 부딪친다. 매뉴얼과 create-feature 참조에 쓰지 말라고 적었고 생성 명령이 막지는 않는다. measure-feature-shape-growth의 s000-feature 꼴 ID는 그대로 뒀다. 검증: desktop에서 RED(이 커밋의 시험을 기준 커밋에 얹음)와 GREEN, 제품 상태(invoice-feature·order-feature를 만든 사본)의 FE-GATE-005·008 재현은 PR 본문에 적는다. Refs: 1112/08-02
153 lines
6.6 KiB
TypeScript
153 lines
6.6 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { existsSync } from "node:fs";
|
|
import { cp, mkdir, mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { afterAll, describe, expect, it } from "vitest";
|
|
|
|
import { linkFixtureNodeModules } from "../../scripts/lib/fixture-node-modules.ts";
|
|
import { REMOVAL_FIXTURE_COPY_TARGETS } from "../../scripts/lib/removal-fixture.ts";
|
|
import { selectRepositoryPaths } from "../../scripts/lib/repository-layout.ts";
|
|
import {
|
|
MANUAL_EXAMPLE_FEATURE_ID,
|
|
MANUAL_PROBE_FEATURE_ID,
|
|
renameFeatureText,
|
|
} from "../../scripts/lib/template-probe-features.ts";
|
|
|
|
/**
|
|
* 2026-11-07. The template ships no sample feature: what the generated
|
|
* feature does not show, docs/manual shows as code blocks a product copies
|
|
* into its feature folder. Each such block has `<!-- manual-code-block: <path> -->`
|
|
* above it, the path in the feature `create:feature invoice-feature
|
|
* --with-create` writes. Here a copy of the repository gets that feature, each
|
|
* block goes to its path unchanged, and the app and test typecheck programs,
|
|
* lint and the feature's tests run on it. A block that is a test runs as it
|
|
* is; what the other blocks do is checked by tests/fixtures/manual-code-blocks.
|
|
*
|
|
* 1112/08-02. The copy holds the product's own features, and a product may
|
|
* well have built `invoice-feature`. So the copy gets the reserved probe
|
|
* feature instead, and every block and check is renamed to it on the way in
|
|
* (`renameFeatureText`): paths, constants, types and words alike.
|
|
*/
|
|
const MANUAL = "docs/manual";
|
|
const FEATURE_ID = MANUAL_PROBE_FEATURE_ID;
|
|
const toProbe = (text: string) => renameFeatureText(text, MANUAL_EXAMPLE_FEATURE_ID, FEATURE_ID);
|
|
const CHECKS = "tests/fixtures/manual-code-blocks";
|
|
const MARKED_BLOCK = /<!-- manual-code-block: (\S+) -->\n```tsx?\n([\s\S]*?)\n```/gu;
|
|
|
|
async function manualDocuments(directory: string): Promise<string[]> {
|
|
const documents: string[] = [];
|
|
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
const target = path.join(directory, entry.name);
|
|
if (entry.isDirectory()) documents.push(...(await manualDocuments(target)));
|
|
else if (entry.name.endsWith(".md")) documents.push(target);
|
|
}
|
|
return documents.sort();
|
|
}
|
|
|
|
/** Each marked block by the path it goes to. */
|
|
async function markedBlocks(): Promise<ReadonlyMap<string, string>> {
|
|
const blocks = new Map<string, string>();
|
|
for (const document of await manualDocuments(MANUAL)) {
|
|
for (const [, target = "", body = ""] of (await readFile(document, "utf8")).matchAll(MARKED_BLOCK)) {
|
|
if (blocks.has(target)) throw new Error(`${target} is marked twice in ${MANUAL}`);
|
|
blocks.set(target, `${body}\n`);
|
|
}
|
|
}
|
|
return blocks;
|
|
}
|
|
|
|
const roots: string[] = [];
|
|
|
|
afterAll(async () => {
|
|
await Promise.all(roots.map((root) => rm(root, { recursive: true, force: true })));
|
|
});
|
|
|
|
async function copyRepository(): Promise<string> {
|
|
const root = await mkdtemp(path.join(tmpdir(), "manual-code-blocks-"));
|
|
roots.push(root);
|
|
for (const entry of REMOVAL_FIXTURE_COPY_TARGETS) {
|
|
// A removal drill runs this test in a copy that has already lost some.
|
|
if (!existsSync(path.resolve(entry))) continue;
|
|
await cp(path.resolve(entry), path.join(root, entry), {
|
|
recursive: true,
|
|
filter: (source) => !source.includes(`${path.sep}.generated`),
|
|
});
|
|
}
|
|
await linkFixtureNodeModules(root);
|
|
return root;
|
|
}
|
|
|
|
function run(root: string, command: string, args: readonly string[]) {
|
|
const result = spawnSync(command, args, { cwd: root, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
|
|
return { status: result.status, output: `${result.stdout}${result.stderr}` };
|
|
}
|
|
|
|
describe("docs/manual code blocks, pasted into a generated feature", () => {
|
|
it("marks each block with a path in the feature it is written for", async () => {
|
|
const targets = [...(await markedBlocks()).keys()].sort();
|
|
|
|
expect(targets).toEqual([
|
|
"src/features/invoice-feature/adapters/invoice-problem-mapping.ts",
|
|
"src/features/invoice-feature/contracts/invoice-list-search.ts",
|
|
"src/features/invoice-feature/contracts/invoice-problem-details.ts",
|
|
"src/features/invoice-feature/domain/invoice.ts",
|
|
"src/features/invoice-feature/presentation/use-invoice-failure-action.ts",
|
|
"src/features/invoice-feature/presentation/use-invoice-list-filters.ts",
|
|
"tests/features/invoice-feature/invoice-forbidden.test.tsx",
|
|
]);
|
|
});
|
|
|
|
it("typechecks, lints and does what the manual says", async () => {
|
|
const blocks = await markedBlocks();
|
|
const root = await copyRepository();
|
|
const node = process.execPath;
|
|
|
|
// The generator runs first, as `corepack pnpm create:feature` does.
|
|
const indexed = run(root, node, ["scripts/generate-product-feature-index.ts"]);
|
|
expect(indexed.status, indexed.output).toBe(0);
|
|
const created = run(root, node, ["scripts/create-feature.ts", FEATURE_ID, "--with-create"]);
|
|
expect(created.status, created.output).toBe(0);
|
|
|
|
for (const [target, block] of blocks) {
|
|
const file = path.join(root, toProbe(target));
|
|
// A block adds a file; it never stands in for one the command wrote.
|
|
expect(existsSync(file), `${target} exists before the block is pasted`).toBe(false);
|
|
await mkdir(path.dirname(file), { recursive: true });
|
|
await writeFile(file, toProbe(block));
|
|
}
|
|
const checks = (await readdir(CHECKS)).filter((name) => name.endsWith(".check.tsx"));
|
|
expect(checks.length).toBeGreaterThan(0);
|
|
for (const check of checks) {
|
|
await writeFile(
|
|
path.join(root, "tests/features", FEATURE_ID, check.replace(/\.check\.tsx$/u, ".test.tsx")),
|
|
toProbe((await readFile(path.join(CHECKS, check), "utf8")).replaceAll("{{feature}}", MANUAL_EXAMPLE_FEATURE_ID)),
|
|
);
|
|
}
|
|
|
|
for (const program of selectRepositoryPaths("feature-typecheck")) {
|
|
const typecheck = run(root, path.resolve("node_modules/.bin/tsc"), ["--project", program]);
|
|
expect(typecheck.output, program).toBe("");
|
|
expect(typecheck.status, program).toBe(0);
|
|
}
|
|
const lint = run(root, path.resolve("node_modules/.bin/eslint"), [
|
|
`src/features/${FEATURE_ID}`,
|
|
`tests/features/${FEATURE_ID}`,
|
|
"--max-warnings=0",
|
|
]);
|
|
expect(lint.output).toBe("");
|
|
expect(lint.status).toBe(0);
|
|
const architecture = run(root, node, ["scripts/check-architecture.ts"]);
|
|
expect(architecture.status, architecture.output).toBe(0);
|
|
|
|
const tests = run(root, node, [
|
|
"scripts/run-vitest.ts",
|
|
"run",
|
|
`tests/features/${FEATURE_ID}`,
|
|
"--reporter=dot",
|
|
]);
|
|
expect(tests.status, tests.output).toBe(0);
|
|
}, 300_000);
|
|
});
|