Files
clean-architecture-frontend…/tests/unit/feature-tracked-files.test.ts
T
DongHyeonka b2042de9be test(scale): 규모 측정을 참조 기능 대신 생성 기능 사본으로 잰다
규모 측정(S4 3.1절 S-6)은 참조 기능을 복사해 이름을 바꿔 잰다.

create:feature의 planFeature로 사본마다 --with-create --keyed 기능
파일을 만든다(자기 계약 패키지와 topic, context당 200개). 초기 JS
기록에 firstFeatureGzipBytes를 더하고, context 비용은 둘째 기능을 새
context에 둘 때와 같은 context에 둘 때의 차이로 잰다. 옛 정의는 기능이
없는 템플릿에서 첫 기능의 공용 코드까지 context 비용으로 세어 5,788B로
상한 512B를 넘었다. 몇 바이트짜리 비용에는 기록 허용치 하한 16B를
둔다(빌드 ID에 따라 gzip이 1~2B 흔들린다). 이 트리(샘플이 아직 있는
상태)의 기록: 204,266B, 27파일, 첫 기능 797B, 기능 521B, context 12B.

위험: 성장 기준선(0·25·100개)은 샘플을 지운 트리에서 뒤 커밋이 다시
잰다. 이 커밋의 기준선 파일은 아직 참조 사본으로 잰 값이다.

검증(desktop): feature-shape-growth 등 4파일 57 passed, test:unit 통과.
2026-11-08 14:07:53 +09:00

57 lines
2.4 KiB
TypeScript

import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
import { FEATURE_TRACKED_FILE_REWRITES } from "../../scripts/create-feature.ts";
/**
* 1105/16-01. Adding a feature changes two tracked template files: the dev
* server's manifest (`create:feature` rewrites it) and the initial
* JavaScript record (rewritten by command). The 03
* manual's section A said the command writes two files outside the feature
* folder and named neither, the canonical table in starter-experience.md
* had neither, and nothing said what to do when two feature branches change
* the same `setDigest` line. The documents name each file with the command
* that rewrites it, which is also how a merge conflict on it is resolved.
*
* 1106/12-01. Every test here reads a document, so the removal drills that
* copy no documents leave this file out (REMOVAL_FIXTURE_DOCUMENT_TESTS in
* scripts/lib/removal-fixture.ts). The generator's own list is checked in
* tests/unit/feature-tracked-file-rewrites.test.ts, which every drill runs.
*/
function between(text: string, start: string, end: string): string {
const from = text.indexOf(start);
const to = text.indexOf(end, from + start.length);
if (from < 0 || to < 0) throw new Error(`no section from "${start}" to "${end}"`);
return text.slice(from, to);
}
describe("tracked files a feature changes (1105/16-01)", () => {
it("names each file and its rewrite command in the 03 manual's section A", async () => {
const section = between(
await readFile("docs/manual/03-outside-feature-folder.md", "utf8"),
"## A. 생성 명령이 만든다",
"## B. ",
);
for (const file of FEATURE_TRACKED_FILE_REWRITES) {
expect(section, file.path).toContain(file.path);
expect(section, file.path).toContain(file.command);
}
expect(section).toMatch(/충돌/u);
});
it("names each file and its rewrite command in the canonical table", async () => {
const table = between(
await readFile("docs/architecture/starter-experience.md", "utf8"),
"Files outside the feature directory.",
"The central catalogs",
);
for (const file of FEATURE_TRACKED_FILE_REWRITES) {
const row = table.split("\n").find((line) => line.startsWith("|") && line.includes(file.path));
expect(row, file.path).toBeDefined();
expect(row, file.path).toContain(file.command);
expect(row, file.path).toMatch(/merge conflict/u);
}
});
});