문제: 두 테스트가 검사 대상을 "파일이 있으면"으로 정한다. - `playwright-run-isolation.test.ts`는 capabilities 설정이 있을 때만 그 설정의 검사 8개를 정의한다(`existsSync`). browser-file-storage 드릴 사본에서 33개가 25개로 줄었는데 skip 보고가 없다. 템플릿에서 설정 이름을 바꾸고 테스트의 문자열만 놓쳐도 같이 빠진다. - `vite-build-inputs.test.ts`는 목록 소비자 둘을 `existsSync`로 거른다. 어느 제거 목록에도 없는 `product-feature-selection-build.test.ts`의 이름이 바뀌어도 검사가 빈 반복으로 통과한다. - 주석의 skip 차단 ID가 0929/10-04로 틀렸다. 1101/10-04다. 고른 방법(리뷰 문서 ⓐ): - capabilities 검사 8개를 `playwright-capabilities-run-isolation.test.ts`로 옮기고 설정을 이름으로 import한다. browser-file-storage 드릴이 설정과 이 파일을 이름으로 함께 지운다. 같은 드릴이 `ci-workflow-generation` 테스트를 지우는 방식이다. `force` 없이 지워, 이름이 바뀐 파일은 드릴이 그 자리에서 멈춘다. - 두 파일이 같은 검사를 쓰도록 불러오기·포트·결과 폴더 검사를 `tests/helpers/playwright-run-isolation.ts`로 뺐다. 단언은 그대로다. - `vite-build-inputs`는 빌드 테스트를 늘 읽는다. 측정 스크립트는 그 파일을 가진 제거 가능 기능(`removable-template-features.ts`)이 설치돼 있을 때(feature-module.ts가 있을 때, verify:documentation과 같은 규칙) 읽는다. 그 소유 기능이 없으면 실패한다. 기능 ID를 테스트에 쓰지 않는 것은 샘플 드릴의 residue 검사가 `src`·`tests`의 샘플 이름을 잡기 때문이다. - 틀린 ID 주석은 옮긴 검사와 함께 없어지고, 새 파일 머리말에 1101/10-04로 적었다. 버린 대안: 드릴이 표시를 넘기고 테스트가 읽는 방식(ⓑ). 드릴과 테스트 사이 계약이 늘고, capability를 지우는 제품이 테스트를 고쳐야 한다. 주석 ID만 고치기(ⓒ)는 공백이 남는다. 위험·한계: - 테스트 수는 템플릿 33개(25 + 8)로 같다. browser-file-storage 사본에서는 25개가 돌고 8개는 파일째 지워진다(드릴 코드에 적힘). - 측정 스크립트의 조건은 여전히 파일 존재(소유 기능의 feature-module.ts)다. 대상이 지울 수 있다고 등록된 소유자로 바뀌었다. - 이 노트북에서는 실행하지 못했다. 검증: desktop batch에서 확인. node scripts/run-vitest.ts run tests/unit/playwright-run-isolation.test.ts tests/unit/playwright-capabilities-run-isolation.test.ts tests/unit/vite-build-inputs.test.ts 이름 바꾸기 변이 둘(capabilities 설정, product-feature-selection-build 테스트), check:types, lint, ci:gate FE-GATE-020 Refs: 1106/10-01
209 lines
6.6 KiB
TypeScript
209 lines
6.6 KiB
TypeScript
import {
|
|
mkdir,
|
|
readFile,
|
|
rm,
|
|
writeFile,
|
|
} from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
import {
|
|
assertNoRuntimeImports,
|
|
createRemovalFixtureRoot,
|
|
prepareRemovalFixture,
|
|
pruneRemovalFixtureCiContract,
|
|
regenerateRemovalFixtureWorkflow,
|
|
removeRuntimeDependentTests,
|
|
renderRemovalJunit,
|
|
requireRemovalFixtureEnvironment,
|
|
runRemovalFixtureCheck,
|
|
type RemovalCheck,
|
|
} from "./lib/removal-fixture.ts";
|
|
|
|
const pnpmCli = requireRemovalFixtureEnvironment("npm_execpath");
|
|
const fixtureRoot = await createRemovalFixtureRoot("browser-file-storage-runtime-removal");
|
|
const RUNTIME_RECIPE_MODULES = [
|
|
"browser-file-storage-contracts.ts",
|
|
"browser-file-storage-fakes.ts",
|
|
] as const;
|
|
const runtimePaths = [
|
|
"src/application/ports/browser-file-storage",
|
|
"src/application/ports/browser-transfer",
|
|
"src/adapters/browser-file-storage",
|
|
"src/adapters/browser-files",
|
|
"src/adapters/browser-transfer",
|
|
"src/adapters/cache-storage",
|
|
"src/adapters/storage/indexeddb",
|
|
"src/adapters/storage/opfs",
|
|
"tests/browser-capabilities",
|
|
"tests/fixtures/browser-file-storage-boundaries",
|
|
// The composition examples of this runtime go with it.
|
|
"recipes/frontend-capabilities/indexeddb-feature-capability.ts",
|
|
"recipes/frontend-capabilities/browser-file-session-capability.ts",
|
|
// [0929] 05-03. These recipe contracts re-export this runtime's ports and
|
|
// their fakes implement them, so they go with it too, with their test.
|
|
...RUNTIME_RECIPE_MODULES.map(
|
|
(module) => `recipes/frontend-capabilities/${module}`,
|
|
),
|
|
"tests/recipes/browser-file-storage-contracts.test.ts",
|
|
] as const;
|
|
const runtimeSourceRoots = runtimePaths.filter((entry) =>
|
|
entry.startsWith("src/"),
|
|
);
|
|
const removedScripts = new Set([
|
|
"test:browser-capabilities",
|
|
"verify:browser-capability-evidence",
|
|
"check:browser-file-storage-boundaries",
|
|
"test:browser-file-storage-removal",
|
|
]);
|
|
const removedEvidencePathFragments = [
|
|
"browser-capabilities",
|
|
"browser-file-storage-runtime-removal",
|
|
] as const;
|
|
function check(name: string, script: string): RemovalCheck {
|
|
return runRemovalFixtureCheck(name, fixtureRoot, pnpmCli, script);
|
|
}
|
|
|
|
let checks: RemovalCheck[];
|
|
let removedRuntimeTests: number;
|
|
try {
|
|
await prepareRemovalFixture(fixtureRoot);
|
|
|
|
// The recipe barrel stops exporting the removed recipe modules first, so the
|
|
// import graph below does not count every other recipe test as dependent.
|
|
const recipeIndexPath = path.join(
|
|
fixtureRoot,
|
|
"recipes/frontend-capabilities/index.ts",
|
|
);
|
|
const recipeIndex = await readFile(recipeIndexPath, "utf8");
|
|
const keptRecipeExports = recipeIndex
|
|
.split("\n")
|
|
.filter(
|
|
(line) =>
|
|
!RUNTIME_RECIPE_MODULES.some((module) =>
|
|
line.includes(`"./${module}"`),
|
|
),
|
|
);
|
|
if (
|
|
keptRecipeExports.length !==
|
|
recipeIndex.split("\n").length - RUNTIME_RECIPE_MODULES.length
|
|
) {
|
|
throw new Error("Expected the recipe barrel to export each runtime recipe module once");
|
|
}
|
|
await writeFile(recipeIndexPath, keptRecipeExports.join("\n"));
|
|
|
|
removedRuntimeTests =
|
|
await removeRuntimeDependentTests(fixtureRoot, runtimeSourceRoots);
|
|
for (const runtimePath of runtimePaths) {
|
|
await rm(path.join(fixtureRoot, runtimePath), {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
}
|
|
|
|
const catalogPath = path.join(
|
|
fixtureRoot,
|
|
"config/recipes/frontend-capability-recipes.json",
|
|
);
|
|
const catalog = JSON.parse(await readFile(catalogPath, "utf8")) as {
|
|
recipes: Array<Record<string, unknown>>;
|
|
};
|
|
const browserFileRuntimeRecipeIds = new Set([
|
|
"offline-indexeddb",
|
|
"service-worker-pwa",
|
|
"file-transfer",
|
|
]);
|
|
let removedRuntimeEntries = 0;
|
|
for (const recipe of catalog.recipes) {
|
|
if (
|
|
typeof recipe.id !== "string" ||
|
|
!browserFileRuntimeRecipeIds.has(recipe.id) ||
|
|
!Object.hasOwn(recipe, "referenceRuntime")
|
|
) {
|
|
continue;
|
|
}
|
|
delete recipe.referenceRuntime;
|
|
removedRuntimeEntries += 1;
|
|
}
|
|
if (removedRuntimeEntries !== 3) {
|
|
throw new Error(
|
|
`Expected three reference runtime catalog entries, removed ${removedRuntimeEntries}`,
|
|
);
|
|
}
|
|
await writeFile(catalogPath, `${JSON.stringify(catalog, null, 2)}\n`);
|
|
|
|
// 1106/10-01. The capabilities config goes with this runtime, and so do its
|
|
// run-isolation checks, by name: the template's test:unit runs them, this
|
|
// copy has nothing for them to check. Without `force`, so a renamed file
|
|
// stops the drill here instead of failing its typecheck later.
|
|
for (const capabilityConfigFile of [
|
|
"playwright.capabilities.config.ts",
|
|
"tests/unit/playwright-capabilities-run-isolation.test.ts",
|
|
]) {
|
|
await rm(path.join(fixtureRoot, capabilityConfigFile));
|
|
}
|
|
await rm(
|
|
path.join(fixtureRoot, "scripts/check-browser-file-storage-boundaries.ts"),
|
|
{ force: true },
|
|
);
|
|
await rm(
|
|
path.join(fixtureRoot, "scripts/verify-browser-capability-evidence.ts"),
|
|
{ force: true },
|
|
);
|
|
await rm(
|
|
path.join(fixtureRoot, "scripts/test-browser-file-storage-runtime-removal.ts"),
|
|
{ force: true },
|
|
);
|
|
// The root snapshot locks the full repository inventory. This removal fixture
|
|
// validates its smaller registry through check:ci and its regenerated workflow.
|
|
await rm(
|
|
path.join(fixtureRoot, "tests/unit/ci-workflow-generation.test.ts"),
|
|
{ force: true },
|
|
);
|
|
await rm(
|
|
path.join(
|
|
fixtureRoot,
|
|
"tests/unit/__snapshots__/ci-workflow-generation.test.ts.snap",
|
|
),
|
|
{ force: true },
|
|
);
|
|
|
|
await pruneRemovalFixtureCiContract({
|
|
root: fixtureRoot,
|
|
removedScripts,
|
|
removedEvidencePathFragments,
|
|
});
|
|
await regenerateRemovalFixtureWorkflow(fixtureRoot);
|
|
await assertNoRuntimeImports(
|
|
fixtureRoot,
|
|
runtimeSourceRoots,
|
|
"browser file/storage",
|
|
);
|
|
|
|
checks = [
|
|
check("typecheck", "check:types"),
|
|
check("lint", "lint"),
|
|
check("architecture", "check:architecture"),
|
|
check("test", "test:all"),
|
|
check("build", "build"),
|
|
check("optional-catalog", "check:optional-recipes:source"),
|
|
check("ci-contract", "check:ci"),
|
|
];
|
|
} finally {
|
|
await rm(fixtureRoot, { recursive: true, force: true });
|
|
}
|
|
const failed = checks.filter((entry) => !entry.passed);
|
|
await mkdir("artifacts/tests", { recursive: true });
|
|
await writeFile(
|
|
"artifacts/tests/browser-file-storage-runtime-removal.xml",
|
|
renderRemovalJunit("browser-file-storage-runtime-removal", checks),
|
|
);
|
|
if (failed.length > 0) {
|
|
process.stderr.write(
|
|
`Browser file/storage runtime removal failed: ${failed.map((entry) => entry.name).join(", ")}\n`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write(
|
|
`Browser file/storage runtime removal: PASS (${checks.length} base checks, ${removedRuntimeTests} runtime-dependent tests removed by import graph)\n`,
|
|
);
|