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); } }); });