문제: 문서를 복사하지 않는 capability 드릴 셋은 `REMOVAL_FIXTURE_DOCUMENT_TESTS` 의 파일을 통째로 지운다. 문서를 읽는 테스트 하나 때문에 `backend-contract-pin.test.ts`가 목록에 들어가, config와 코드만 보는 나머지 14건(pin 커밋, 답 표 사본, 생성기 사실, Envelope 판정 대조)도 그 드릴에서 돌지 않는다. `feature-tracked-files.test.ts`의 생성기 목록 검사 1건도 같다. 목록을 지키는 검사는 파일 글자에 `README.md|CHANGELOG.md|docs/`가 있는지만 봐서, `backend-contract-pin.test.ts`는 주석 한 줄로 통과했다. 고른 방법(리뷰 문서 ⓐ+ⓑ): - 6.1 표를 읽는 테스트를 `backend-contract-pin-document.test.ts`로 옮기고 목록에는 그 파일을 둔다. pin 파일은 목록에서 빠져 모든 드릴에서 돈다. 새 파일은 pin에서 문서 경로만 읽고, 그 경로가 `docs/` 아래인지 확인한다. - `feature-tracked-files.test.ts`의 문서와 무관한 1건을 `feature-tracked-file-rewrites.test.ts`로 옮긴다. 남은 두 건은 모두 문서를 읽어 그 파일은 목록에 남는다(`create-feature.ts`의 참조도 그대로 맞다). - 목록 검사는 Babel로 파일을 파싱해 코드의 문자열·템플릿 리터럴에 문서 경로가 있는지 본다. 주석은 세지 않는다. 주석만 있는 소스를 거절하는지 자체 테스트를 더했다. - 6.1 대조를 가리키던 `external-contract-runtime.ts` 주석과 계약 문서 한 줄을 새 파일 이름으로 고쳤다. 버린 대안: capability 드릴이 계약 문서 하나만 복사하기. 문서 테스트가 늘 때마다 복사 목록이 늘고, 그 드릴이 "문서 없이"를 증명한다는 전제가 흐려진다. 목록 검사만 고치기는 빠지는 범위가 그대로다. 위험·한계: - 목록 검사는 파일 단위다. 파일 안의 모든 테스트가 문서를 읽는지는 기계로 보지 않는다. 목록 주석에 규칙을 적었다. - 검사는 코드에 문서 경로 문자열이 있는지 본다. 그 문자열로 실제로 읽는지는 보지 않는다. - 이 노트북에서는 실행하지 못했다. 검증: desktop batch에서 확인. node scripts/run-vitest.ts run tests/unit/removal-fixture.test.ts tests/unit/backend-contract-pin.test.ts tests/unit/backend-contract-pin-document.test.ts tests/unit/feature-tracked-files.test.ts tests/unit/feature-tracked-file-rewrites.test.ts check:types, lint, verify:documentation, ci:gate FE-GATE-020(capability 드릴 셋의 unit 실행에 pin 14건이 나오는지) Refs: 1106/12-01
68 lines
2.6 KiB
TypeScript
68 lines
2.6 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
import { PLATFORM_CODES_POSSIBLY_AFTER_WRITE } from "../../src/contracts/external-contract-runtime.ts";
|
|
|
|
/**
|
|
* 1106/12-01. The one paired-backend pin check that reads a document. It has
|
|
* its own file because the removal drills that copy no documents leave whole
|
|
* files out (REMOVAL_FIXTURE_DOCUMENT_TESTS in scripts/lib/removal-fixture.ts):
|
|
* in tests/unit/backend-contract-pin.test.ts it took that file's fourteen
|
|
* checks of config and code out of those drills with it. The pin names the
|
|
* document; it is a repository document (`docs/`), which is why this file is
|
|
* on that list.
|
|
*/
|
|
const pin = z
|
|
.object({
|
|
frontend: z.object({ contractDocument: z.string().startsWith("docs/") }),
|
|
})
|
|
.parse(JSON.parse(readFileSync("config/contracts/backend-contract-pin.json", "utf8")));
|
|
|
|
/**
|
|
* 1105/03-01. The codes of the contract 6.1 table rows whose stage is "쓰기 뒤
|
|
* 가능" (possibly after the write), read from the document the pin names.
|
|
*/
|
|
function codesPossiblyAfterWrite(): ReadonlySet<string> {
|
|
const text = readFileSync(pin.frontend.contractDocument, "utf8");
|
|
const section = text.split("### 6.1 ")[1]?.split(/\n#{2,3} /u)[0] ?? "";
|
|
const codes = new Set<string>();
|
|
for (const line of section.split("\n")) {
|
|
const cells = line.split("|").map((cell) => cell.trim());
|
|
if (!line.startsWith("|") || cells[3] !== "쓰기 뒤 가능") continue;
|
|
for (const [, code = ""] of (cells[1] ?? "").matchAll(/`([A-Z0-9_]+)`/gu)) {
|
|
codes.add(code);
|
|
}
|
|
}
|
|
return codes;
|
|
}
|
|
|
|
/**
|
|
* Rows of that table whose stage the endpoint decides: the reference domain's
|
|
* codes and web-advanced's patch codes ("부르는 코드가 단계를 정한다"). A
|
|
* feature author who checked the endpoint may declare them.
|
|
*/
|
|
const FEATURE_DECIDED_CODES: readonly string[] = [
|
|
"WORKLOG_INVALID",
|
|
"POSTER_INVALID_STATE",
|
|
"POSTER_IMAGE_REQUIRED",
|
|
"WORKLOG_CONFLICT",
|
|
"POSTER_ALREADY_EXISTS",
|
|
"POSTER_IMAGE_ALREADY_PUBLISHED",
|
|
"PATCH_REJECTED",
|
|
"PATCH_TEST_FAILED",
|
|
];
|
|
|
|
describe("platform codes no operation may declare as refused before its write", () => {
|
|
it("are the 6.1 table's possibly-after-write codes outside the feature-decided rows", () => {
|
|
const table61 = codesPossiblyAfterWrite();
|
|
for (const code of FEATURE_DECIDED_CODES) {
|
|
expect(table61.has(code), code).toBe(true);
|
|
}
|
|
expect([...PLATFORM_CODES_POSSIBLY_AFTER_WRITE].sort()).toEqual(
|
|
[...table61].filter((code) => !FEATURE_DECIDED_CODES.includes(code)).sort(),
|
|
);
|
|
});
|
|
});
|