fix(removal): spec 본문 잔여를 적힌 그대로, -가 든 이름만 찾는다
문제: af3344b가 더한 Playwright spec 본문 검색은 대소문자를 무시하고
`_`를 이름 경계로 봤다(`(?<![A-Za-z0-9-])…(?![A-Za-z0-9-])`, `i`).
create:feature는 한 단어 ID(`messages`, `reports`)를 받고 폴더 이름도
ID와 같다. 그래서 `messages` 기능을 지우면 템플릿 자신의
tests/e2e/accessibility.spec.ts(`KO_MESSAGES`)와 scrollbar-gutter
visual spec이 잔여로 잡혀 드릴이 실패한다. `status`·`reports`는 템플릿
spec 여러 개가 평범한 단어로 쓴다. errors.md는 목록에 템플릿 파일이
나오면 템플릿 결함이라 적으므로 제품은 고칠 곳이 없다.
고른 방법: 메인 세션 기준대로 적힌 그대로(대소문자 구분) 찾고, 경계는
식별자 문자 `[A-Za-z0-9_-]`다. 폴더 이름이 ID와 다르면 같은 규칙을 쓴다.
그런데 이 둘만으로는 `status`·`reports`가 0건이 되지 않는다. 템플릿
spec에 `status: 200`, `getByRole("status")`, 테스트 제목의 "reports"가
있다(git grep). `getByRole("status")`는 따옴표 안 한 단어라 따옴표나
문맥 규칙으로도 실제 참조와 구별되지 않는다. 그래서 `-`가 든 이름만 spec
본문에서 찾는다. 한 단어 ID·폴더 이름은 spec 본문 검색에서 빠진다.
검사를 좁히는 변경이지만 이 발견이 바로 그 거짓 양성이다. 거짓 양성은
제거를 막고 고칠 길이 없는 반면, 빠지는 쪽(한 단어 ID만 본문에 적은
spec)은 1106/16-01 전처럼 다음 CI의 브라우저 게이트가 잡는다.
테스트: 템플릿의 spec 파일 전부를 사본에 옮겨 `product-feature`,
`messages`, `status`, `reports`로 돌리면 잔여 0건이다. 적힌 그대로의
ID와 다른 폴더 이름(`invoice-docs`)은 잔여이고, `Invoice-Feature`와
`invoice-feature_v2`는 아니다. 매뉴얼 01 11단계, errors.md, CHANGELOG
1106 절의 16-01 행·확인 2·알려진 제한을 고쳤다.
버린 대안: 따옴표나 `/features/` 문맥만 센다. `getByRole("status")`가
남고, `test.describe("invoice-feature")` 같은 실제 잔여도 문맥에 따라
빠진다. 한 단어 ID를 막는 생성기 규칙은 이 수정 범위 밖이다.
위험·한계: `-`가 든 흔한 이름(예: `read-only`)을 ID로 쓰면 템플릿 spec이
그 이름을 쓸 때 다시 거짓 양성이 난다. 템플릿 spec 0건 테스트는 네
ID만 본다. src 쪽 부분 문자열 검색(1105/16-04)은 그대로다. CHANGELOG
행의 커밋 칸에는 이 커밋 해시를 아직 적지 않았다(같은 커밋에 자기 해시를
적을 수 없다).
검증: desktop batch에서 확인.
node scripts/run-vitest.ts run tests/unit/feature-residue.test.ts
node scripts/run-vitest.ts run tests/unit/changelog-review-ids.test.ts
Refs: 1106/16-01 (diff review DR-02)
This commit is contained in:
@@ -22,10 +22,17 @@ import path from "node:path";
|
||||
* `tests/`, vitest.config.ts), and no step of the drill runs a Playwright
|
||||
* spec. So a spec (`*.spec.ts`) that names the feature only in its text,
|
||||
* such as `test.describe("invoice-feature", ...)`, is residue: its text is
|
||||
* searched for the ID or folder name as a whole kebab-case name. A longer
|
||||
* name that contains it (`generate-product-feature-index.ts` for
|
||||
* `product-feature`) does not count. A spec that names only the feature's
|
||||
* routes or URLs is not found; 03's hand list removes the feature's specs.
|
||||
* searched for the ID or folder name as written, case-sensitive, with no
|
||||
* identifier character (`[A-Za-z0-9_-]`) on either side. A longer name
|
||||
* that contains it (`generate-product-feature-index.ts` for
|
||||
* `product-feature`, `KO_MESSAGES` for `messages`) does not count. A spec
|
||||
* that names only the feature's routes or URLs is not found; 03's hand list
|
||||
* removes the feature's specs.
|
||||
* Diff review DR-02: only a name with a hyphen is searched. A one-word ID
|
||||
* or folder (`status`, `reports`, `messages`) is an ordinary word in the
|
||||
* template's own specs (`status: 200`, `getByRole("status")`, "reports" in
|
||||
* a test title), and no text rule tells that from a reference, so a spec
|
||||
* that names only a one-word ID is not found either.
|
||||
*
|
||||
* The reference sample keeps its own, wider pattern in
|
||||
* scripts/test-sample-removal.ts: the template owns all of its files.
|
||||
@@ -56,7 +63,13 @@ export async function productFeatureResidue(
|
||||
String.raw`(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\bmock\s*\(\s*)["'][^"'\n]*/features/(?:${names})/`,
|
||||
"u",
|
||||
);
|
||||
const wholeName = new RegExp(`(?<![A-Za-z0-9-])(?:${names})(?![A-Za-z0-9-])`, "iu");
|
||||
const specNames = [...new Set([featureId, directory])]
|
||||
.filter((name) => name.includes("-"))
|
||||
.map(escapeRegExp);
|
||||
const wholeName =
|
||||
specNames.length === 0
|
||||
? null
|
||||
: new RegExp(`(?<![A-Za-z0-9_-])(?:${specNames.join("|")})(?![A-Za-z0-9_-])`, "u");
|
||||
const playwrightSpec = /\.spec\.[cm]?[jt]sx?$/u;
|
||||
const residue: string[] = [];
|
||||
const relative = (file: string) => path.relative(root, file).split(path.sep).join("/");
|
||||
@@ -70,7 +83,7 @@ export async function productFeatureResidue(
|
||||
if (
|
||||
named.test(name) ||
|
||||
imported.test(text) ||
|
||||
(playwrightSpec.test(name) && wholeName.test(text))
|
||||
(wholeName !== null && playwrightSpec.test(name) && wholeName.test(text))
|
||||
) {
|
||||
residue.push(name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user