Files
clean-architecture-frontend…/tests/unit/browser-spec-imports.test.ts
DongHyeonka 7679ce6592 revert: #55 되돌림(411c9338)을 되돌려 그룹 C 검사기 변경을 다시 넣는다
This reverts commit 411c9338c6.

문제: #55(b4895894)가 main run 376의 FE-GATE-030(browser file/storage
제거 드릴)을 깨서 411c9338(#64)로 통째로 되돌렸다. #55의 검사기 진단과
시험 빈틈 고침 12커밋이 main에 없다.

고른 방법: 되돌림을 되돌려 #55를 그대로 다시 넣고, 드릴을 깬 원인은
다음 커밋에서 따로 고친다. 리뷰어가 이 커밋이 #55와 같은지 트리로 볼 수
있다. 이 커밋의 트리는 b4895894 트리에 그 뒤 main에 들어온 #63·#65만
더한 것이다(git diff b4895894 <이 커밋>: docs/ledger 두 파일,
cross-context-invalidation adapter 한 파일과 시험 두 파일).
버린 대안: #55 커밋 12개 cherry-pick. 71606ff1 merge의 충돌 해소분을
다시 풀어야 하고 결과 트리를 b4895894와 대조하기 어렵다.

위험·한계: 이 커밋만으로는 main 단계의 FE-GATE-030이 run 376처럼
실패한다(같은 트리 내용). PR 단계 게이트는 돈다.

검증: 다음 커밋 본문에 적는다. 그 커밋의 새 단언을 이 커밋의 검사기에
돌리면 실패한다(RED).

Refs: #55, #64
2026-11-19 16:32:00 +09:00

52 lines
2.8 KiB
TypeScript

import path from "node:path";
import { ESLint } from "eslint";
import { describe, expect, it } from "vitest";
import { childProcessTimeout } from "../helpers/child-process-timeout.ts";
const FOLDERS = ["e2e", "browser-capabilities", "visual", "storybook"] as const;
const BARE = 'import { expect, test } from "@playwright/test";\n\ntest("probe", async () => { expect(1).toBe(1); });\n';
const STRICT =
'import { expect, test } from "../support/browser/strict-browser-test.ts";\n' +
'import type { Page } from "@playwright/test";\n\n' +
'test("probe", async ({ page }: { page: Page }) => { expect(page).toBeTruthy(); });\n';
const DEFAULT_IMPORT = 'import test from "@playwright/test";\n\ntest("probe", async () => {});\n';
const BASE_TEST = 'import { test } from "../support/browser/browser-test.ts";\n\ntest("probe", async () => {});\n';
async function restrictedImports(code: string, file: string): Promise<string[]> {
const linter = new ESLint({ cwd: process.cwd() });
const [result] = await linter.lintText(code, { filePath: path.join(process.cwd(), file), warnIgnored: true });
return (result?.messages ?? [])
.filter((message) => message.ruleId === "no-restricted-imports")
.map((message) => message.message);
}
// 1112/03-04. Strict fixture use was a text search for its path in
// tests/e2e/*.spec.ts: a path in a comment passed, a file could mix in the
// bare test, and tests/browser-capabilities, tests/visual and tests/storybook
// were not looked at. It is an import rule in each of the four folders now.
describe("browser specs take test from the strict fixture (1112/03-04)", () => {
it.each(FOLDERS)("rejects the bare Playwright test in tests/%s", async (folder) => {
const messages = await restrictedImports(BARE, `tests/${folder}/lint-probe.spec.ts`);
expect(messages).toEqual([expect.stringContaining("tests/support/browser/strict-browser-test.ts")]);
}, childProcessTimeout(683));
it("rejects the default import, the base test the strict fixture extends, and accepts the strict test", async () => {
expect(await restrictedImports(DEFAULT_IMPORT, "tests/visual/lint-probe.spec.ts")).toEqual([
expect.stringContaining("tests/support/browser/strict-browser-test.ts"),
]);
expect(await restrictedImports(BASE_TEST, "tests/e2e/lint-probe.spec.ts")).toEqual([
expect.stringContaining("the base test does not check browser errors"),
]);
expect(await restrictedImports(STRICT, "tests/browser-capabilities/lint-probe.spec.ts")).toEqual([]);
}, childProcessTimeout(683));
it("lets only the two specs that need the plain test import it", async () => {
for (const file of ["tests/e2e/preload-use.spec.ts", "tests/browser-capabilities/chunk-load-error.spec.ts"]) {
expect(await restrictedImports(BARE, file), file).toEqual([]);
}
}, childProcessTimeout(683));
});