문제 dev-release-manifest 테스트의 둘째 경우가 생성 결과를 커밋된 자리표시자와 통째로 비교한다. 템플릿 기능만 있으면 같지만, 기능을 더한 제품이나 생성 기능을 넣은 제거 드릴 fixture에서는 contract set이 달라 실패한다. 깨끗한 clone의 FE-GATE-020(test:sample-removal 안의 test:unit)에서 떨어졌다. 이 리뷰가 여러 번 고친 "템플릿 그대로일 때만 맞는 테스트"와 같은 결함을 새로 만들었다. 고른 방법 - 둘째 경우는 contract set을 뺀 나머지 칸이 자리표시자와 같고, contract set이 설치된 기능의 buildContractSet()과 같은지 본다. 검증 - 테스트 2건, eslint, check:types 통과. Refs: docs/reviews/2026-11-03-maturity-review/README.md 14.6 X2 #3
65 lines
2.5 KiB
TypeScript
65 lines
2.5 KiB
TypeScript
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
import { buildContractSet } from "../../scripts/generate-contract-set.ts";
|
|
import { writeDevReleaseManifest } from "../../scripts/write-dev-release-manifest.ts";
|
|
|
|
/**
|
|
* 1103 X2. `create:feature` declares a contract package; the dev server used
|
|
* to serve the committed placeholder with a fixed empty set, so the app it
|
|
* had just generated refused to boot in `corepack pnpm dev`.
|
|
*/
|
|
describe("dev release manifest", () => {
|
|
let directory: string | undefined;
|
|
afterEach(async () => {
|
|
if (directory) await rm(directory, { recursive: true, force: true });
|
|
directory = undefined;
|
|
});
|
|
|
|
it("serves the placeholder with the contract set of the installed features", async () => {
|
|
directory = await mkdtemp(path.join(tmpdir(), "dev-release-manifest-"));
|
|
const source = path.join(directory, "release-manifest.json");
|
|
const output = path.join(directory, "generated", "dev-release-manifest.json");
|
|
await writeFile(
|
|
source,
|
|
JSON.stringify({
|
|
schemaVersion: 2,
|
|
buildId: "local-build",
|
|
contractSet: {
|
|
setAlgorithm: "CA_CONTRACT_SET_V1",
|
|
setDigest: "sha256:stale",
|
|
packages: [{ packageId: "@org-contracts/removed" }],
|
|
},
|
|
}),
|
|
);
|
|
|
|
await writeDevReleaseManifest(source, output);
|
|
|
|
const written = JSON.parse(await readFile(output, "utf8")) as Record<string, unknown>;
|
|
expect(written["buildId"]).toBe("local-build");
|
|
expect(written["contractSet"]).toEqual(JSON.parse(JSON.stringify(buildContractSet())));
|
|
});
|
|
|
|
it("keeps every other field of the committed placeholder", async () => {
|
|
directory = await mkdtemp(path.join(tmpdir(), "dev-release-manifest-"));
|
|
const output = path.join(directory, "dev-release-manifest.json");
|
|
|
|
await writeDevReleaseManifest("public/release-manifest.json", output);
|
|
|
|
// Whatever features are installed (a product's, or a drill's generated
|
|
// one): only the contract set may differ from the placeholder.
|
|
const { contractSet, ...written } = JSON.parse(await readFile(output, "utf8")) as Record<
|
|
string,
|
|
unknown
|
|
>;
|
|
const { contractSet: _placeholderSet, ...placeholder } = JSON.parse(
|
|
await readFile("public/release-manifest.json", "utf8"),
|
|
) as Record<string, unknown>;
|
|
expect(written).toEqual(placeholder);
|
|
expect(contractSet).toEqual(JSON.parse(JSON.stringify(buildContractSet())));
|
|
});
|
|
});
|