Files
clean-architecture-frontend…/tests/unit/e2e-build-helpers.test.ts
T
DongHyeonka dec8a9db32 refactor(e2e): Service Worker 빌드 helper가 fixture 빌드의 준비 함수를 쓴다
문제: `tests/e2e/support/service-worker-builds.ts`가 checkout 복사, node
modules 연결, 빌드 실행(`run`), 한 번 치환(`replaceOnce`)을
`fixture-builds.ts`와 따로 가졌다. 한쪽을 고친 변경(로컬 빌드 env
1103/11-08, 복사 제외 목록 1105/12-04)을 두 번 해야 했다.

고친 것: `fixture-builds.ts`에 `buildEditedCopies` 하나를 두고(복사 →
`prepare` 한 번 → 빌드마다 `edit`·빌드·`dist-<name>`·`collect`),
`prepareFixtureBuilds`와 `prepareServiceWorkerBuilds`가 그것을 쓴다.
`replaceOnce`는 `editOnce`를 가리킨다. 준비 중 실패한 사본은 전처럼
`sharedFixtureBuild`가 지운다.

검증: desktop `tests/unit/e2e-build-helpers.test.ts` 통과, SW update·recovery
e2e와 fixture 빌드 e2e는 FE-GATE-008에서 본다.

Refs: 0929/11-07
2026-11-13 23:29:13 +09:00

37 lines
1.6 KiB
TypeScript

import { readFile, readdir } from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "vitest";
const SUPPORT = "tests/e2e/support";
// 0929/11-07. The Service Worker helper kept its own copy of the checkout
// copy, the build runner and the one-occurrence edit, so a fix to one (the
// local build env of 1103/11-08, the copy skip list of 1105/12-04) had to be
// made twice. Both helpers now go through fixture-builds.ts.
describe("e2e build helpers have one copy-and-build path (0929/11-07)", () => {
it("builds Service Worker fixtures through buildEditedCopies", async () => {
const source = await readFile(path.join(SUPPORT, "service-worker-builds.ts"), "utf8");
expect(source).toMatch(/import \{[^}]*\bbuildEditedCopies\b[^}]*\} from "\.\/fixture-builds\.ts";/u);
expect(source).toContain("buildEditedCopies({");
for (const copy of ["spawnSync", "sharedFixtureBuild", "linkFixtureNodeModules", "await cp(", "function run("]) {
expect(source, copy).not.toContain(copy);
}
});
it("keeps the build runner and the one-occurrence edit in fixture-builds.ts only", async () => {
const files = (await readdir(SUPPORT)).filter((file) => file.endsWith(".ts"));
const defining = async (pattern: RegExp) => {
const found: string[] = [];
for (const file of files) {
if (pattern.test(await readFile(path.join(SUPPORT, file), "utf8"))) found.push(file);
}
return found;
};
expect(await defining(/^function run\(/mu)).toEqual(["fixture-builds.ts"]);
expect(await defining(/split\(search\)\.length !== 2/u)).toEqual(["fixture-builds.ts"]);
});
});