Files
clean-architecture-frontend…/tests/unit/run-isolation.test.ts
DongHyeonka 411c9338c6
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / main / self-tests and removal drills (pull_request) Skipped
frontend-quality-gates / merge / static checks (pull_request) Successful in 1m9s
frontend-quality-gates / merge / tests (pull_request) Successful in 10m55s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 5m11s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
revert: 그룹 C 검사기 PR(#55)을 되돌려 main 제거 드릴을 살린다
This reverts commit b489589403, reversing
changes made to 9e1cfd5975.

문제: main run 376(b4895894)의 `main / self-tests and removal drills`
job에서 FE-GATE-030이 실패한다. browser-file-storage 제거 드릴 사본에서
tests/unit/test-evidence-source-rules.test.ts 6건이 모두 같은 이유로
떨어진다. scripts/check-test-evidence.ts의 missingForbidOnly가
playwright.capabilities.config.ts를 읽다 ENOENT로 죽는다. #55가
forbidOnly 검사를 전체 검사에서 fixture 모드까지 모든 모드로 옮겼다.
드릴은 그 설정 파일을 지우지만 config/repository-layout.json의
playwright-configs 목록에는 그대로 남는다. 이 job은 main 단계에만 있어
PR run에서는 돌지 않았다.

고른 방법: CI 매뉴얼 9.3대로 main을 먼저 초록으로 돌리려고 #55 병합
커밋을 통째로 되돌린다(git revert -m 1 b4895894). 되돌린 트리는
9e1cfd59 트리(9b3237dd)와 같다.
버린 대안: 그 자리에서 고치기(없는 설정을 건너뛰거나, 드릴이 목록에서도
빼기)는 어느 쪽이 맞는지 판단과 검증이 필요해 main 빨강이 길어진다.
고침은 #55를 다시 올리는 PR에서 한다.

위험·한계: #55의 고침 12커밋(검사기 진단과 시험 빈틈)이 main에서
빠진다. 다시 올릴 때 이 드릴(FE-GATE-030, main 단계)을 PR 쪽에서 따로
돌리지 않으면 같은 일이 다시 난다.

검증: desktop 공유 잠금 아래 test:browser-file-storage-removal.
b4895894 트리(7536337a) 3회 모두 rc=1(64·69·53초). 3회차 로그에서 6건 실패,
6건 모두 run 376과 같은 ENOENT(playwright.capabilities.config.ts).
9e1cfd59 트리(9b3237dd, 이 커밋의 트리) 1회 rc=0(92초). 로그 desktop
/tmp/claude-gates/fe-run376-b489-removal/, fe-run376-9e1c-removal/.
2026-11-19 13:20:00 +09:00

167 lines
6.4 KiB
TypeScript

import { createServer, type Server } from "node:net";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
checkoutBuildReadFailure,
findFreePort,
moduleSpecifier,
reservePort,
runOutputPath,
runOutputRoot,
testRunPath,
testRunRoot,
} from "../../scripts/lib/run-isolation.ts";
const servers: Server[] = [];
afterEach(async () => {
await Promise.all(
servers.splice(0).map((server) => new Promise<void>((resolve) => server.close(() => resolve()))),
);
});
async function listen(port: number): Promise<number> {
const server = createServer();
servers.push(server);
await new Promise<void>((resolve, reject) => {
server.once("error", reject);
server.listen(port, "127.0.0.1", () => resolve());
});
const address = server.address();
return typeof address === "object" && address !== null ? address.port : -1;
}
/**
* 1105/12-04. Builds and Playwright runs wrote to fixed paths (`dist`,
* `artifacts/tests/*`), so a second run in one checkout emptied the first
* one's dist and deleted its results. These are the path rules every config
* and build step uses.
*/
describe("test run paths (TEST_RUN_ID)", () => {
it("are the checkout's own paths without a run ID", () => {
for (const environment of [{}, { TEST_RUN_ID: "" }]) {
expect(testRunRoot(environment)).toBe(".");
expect(testRunPath("artifacts/tests/e2e/results", environment)).toBe(
"artifacts/tests/e2e/results",
);
expect(testRunPath("dist", environment)).toBe("dist");
}
});
it("give each run ID its own folder under .tmp/runs", () => {
const a = { TEST_RUN_ID: "gate-008.a" };
const b = { TEST_RUN_ID: "gate-008.b" };
expect(testRunRoot(a)).toBe(".tmp/runs/gate-008.a");
expect(testRunPath("artifacts/tests/e2e/results", a)).toBe(
".tmp/runs/gate-008.a/artifacts/tests/e2e/results",
);
expect(testRunPath("dist", b)).toBe(".tmp/runs/gate-008.b/dist");
expect(testRunPath("dist", a)).not.toBe(testRunPath("dist", b));
});
it("refuse a run ID that is not one folder name", () => {
for (const runId of ["../dist", "a/b", ".hidden", "-a", "a b", "x".repeat(65), "a\\b"]) {
expect(() => testRunRoot({ TEST_RUN_ID: runId }), runId).toThrow(/TEST_RUN_ID/u);
}
});
});
describe("build output root (RUN_OUTPUT_ROOT)", () => {
it("is the checkout without a root", () => {
for (const environment of [{}, { RUN_OUTPUT_ROOT: "" }, { RUN_OUTPUT_ROOT: "." }]) {
expect(runOutputRoot(environment)).toBe(".");
expect(runOutputPath("dist", environment)).toBe("dist");
expect(runOutputPath(".generated/frontend-runtime", environment)).toBe(
".generated/frontend-runtime",
);
}
});
it("puts every build output under a root in .tmp", () => {
const environment = { RUN_OUTPUT_ROOT: "./.tmp/runs/a/" };
expect(runOutputRoot(environment)).toBe(".tmp/runs/a");
expect(runOutputPath("dist/config.json", environment)).toBe(".tmp/runs/a/dist/config.json");
expect(runOutputPath("artifacts/release/build-manifest.json", environment)).toBe(
".tmp/runs/a/artifacts/release/build-manifest.json",
);
});
it("refuses a root outside .tmp, which git, Tailwind and the watchers do not ignore", () => {
for (const root of ["dist", "out/a", "/tmp/a", ".tmp", ".tmp/../dist", "../other", ".tmp\\a"]) {
expect(() => runOutputRoot({ RUN_OUTPUT_ROOT: root }), root).toThrow(/RUN_OUTPUT_ROOT/u);
}
});
// 1106/12-02. The steps after the build read the checkout's dist/ and
// artifacts/; under another root they judged an earlier build.
it("lets a step that reads the checkout's build run only when the build writes there", () => {
for (const environment of [{}, { RUN_OUTPUT_ROOT: "" }, { RUN_OUTPUT_ROOT: "." }, { RUN_OUTPUT_ROOT: "./" }]) {
expect(checkoutBuildReadFailure("check-bundle", environment), JSON.stringify(environment))
.toBeUndefined();
}
expect(checkoutBuildReadFailure("check-bundle", { RUN_OUTPUT_ROOT: "./.tmp/runs/a/" })).toBe(
"check-bundle reads the build at this checkout's paths (dist/, artifacts/), but " +
"RUN_OUTPUT_ROOT=.tmp/runs/a makes the build write under .tmp/runs/a/, so it would " +
"judge an earlier build. Unset RUN_OUTPUT_ROOT, build again and run check-bundle again.",
);
// A root the build itself refuses is no reason to read the checkout's.
expect(checkoutBuildReadFailure("check-bundle", { RUN_OUTPUT_ROOT: "dist" })).toMatch(
/^check-bundle: RUN_OUTPUT_ROOT must be/u,
);
});
});
describe("server ports", () => {
it("finds a port a server can listen on right away", async () => {
const port = await findFreePort();
expect(port).toBeGreaterThan(0);
expect(await listen(port)).toBe(port);
});
it("never offers a port another run's server holds", async () => {
const taken = await listen(0);
for (let attempt = 0; attempt < 20; attempt += 1) {
expect(await findFreePort()).not.toBe(taken);
}
});
it("keeps the port it picked in the variable, so the next evaluation reuses it", async () => {
const environment: Record<string, string | undefined> = {};
const find = vi.fn(async () => 41_234);
expect(await reservePort("TEST_E2E_PORT", environment, find)).toBe(41_234);
expect(environment["TEST_E2E_PORT"]).toBe("41234");
// A Playwright worker: same config, the runner's environment.
expect(await reservePort("TEST_E2E_PORT", environment, find)).toBe(41_234);
expect(find).toHaveBeenCalledTimes(1);
});
it("uses a port the caller pinned and refuses one that is not a port", async () => {
const find = vi.fn(async () => 41_234);
expect(await reservePort("TEST_DEV_PORT", { TEST_DEV_PORT: "5173" }, find)).toBe(5173);
expect(find).not.toHaveBeenCalled();
for (const value of ["0", "65536", "-1", "4173x", "abc", "41.5"]) {
await expect(reservePort("TEST_DEV_PORT", { TEST_DEV_PORT: value }, find), value)
.rejects.toThrow(/TEST_DEV_PORT/u);
}
});
});
describe("generated module specifiers", () => {
it("keep today's specifier in .generated and reach src from a deeper root", () => {
expect(
moduleSpecifier(".generated/frontend-runtime/contract-set.ts", "src/contracts/contract-set.ts"),
).toBe("../../src/contracts/contract-set.ts");
expect(
moduleSpecifier(
".tmp/runs/a/.generated/frontend-runtime/contract-set.ts",
"src/contracts/contract-set.ts",
),
).toBe("../../../../../src/contracts/contract-set.ts");
});
});