문제 tests/visual/fonts.conf는 Noto Sans·Noto Sans CJK·Liberation Mono가 있는 OS 글꼴 디렉터리만 읽는다. 생성 workflow의 브라우저 설치 단계는 `playwright install --with-deps` 한 줄이고, Playwright 의존 패키지에는 이 글꼴이 없다. 그래서 빈 러너에서는 FE-GATE-008이 코드와 무관하게 `visual-fonts` 단계에서 실패한다(1101/11-02의 남은 절반). 고른 방법 - 생성기(scripts/generate-ci-workflow.ts)의 browser-install 단계가 `--with-deps` 뒤에 글꼴 패키지 4개를 apt-get으로 설치한다. `--with-deps`가 이미 패키지 목록을 갱신했으므로 update를 다시 하지 않는다. root가 아닌 러너에서만 sudo를 붙인다. - 패키지 목록을 scripts/lib/visual-test-fonts.ts 한 곳에 두고 생성기와 tests/visual/fonts.setup.ts의 설치 안내가 같이 읽는다. - 글꼴이 필요한 것은 FE-GATE-008뿐이지만 브라우저 단계 두 곳 모두에 넣었다. 게이트 ID로 갈라 쓰면 생성기가 게이트 목록에 묶인다. - 버린 대안: job container 고정(러너의 컨테이너 지원 미확인), ci:gate가 패키지 설치(개발자 PC에서도 sudo 요구). 위험·한계 - 실제 러너나 깨끗한 Ubuntu 24.04 컨테이너에서 이 단계를 돌리지 않았다. 패키지 이름과 디렉터리는 이 호스트(Ubuntu)와 fonts.conf로만 확인했다. - CJK 패키지 때문에 브라우저 job 설치 시간이 수십 MB만큼 는다. - gates.json은 바꾸지 않았다(단계 종류는 그대로 browser-install). 검증 - ci-workflow-generation 새 테스트: 생성기 수정 전 실패, 수정 뒤 통과. 파일 전체 424건 통과(스냅샷 1건 갱신). - generate:ci-workflow로 workflow 재생성. check:ci PASS. - lint, check:types:node, check:types:test, verify:documentation PASS. Refs: docs/reviews/2026-11-03-maturity-review/11-tests-browser-release-scale.md 11-02
69 lines
2.6 KiB
TypeScript
69 lines
2.6 KiB
TypeScript
import {
|
|
expect,
|
|
test,
|
|
type Page,
|
|
} from "../support/browser/strict-browser-test.ts";
|
|
import { VISUAL_TEST_FONT_INSTALL_ARGUMENTS } from "../../scripts/lib/visual-test-fonts.ts";
|
|
|
|
// 11-02. The goldens were captured with these four faces. `fonts.conf` shows
|
|
// Chromium only the directories that hold them; this check runs before the
|
|
// screenshots so a missing or substituted font fails here with an install
|
|
// hint instead of as a whole-page pixel diff. Probes sit in the real page so
|
|
// they get its CSS (`--font-sans`) and `lang`, which decide the fallbacks.
|
|
const expectedFaces = {
|
|
latin: "Noto Sans",
|
|
korean: "Noto Sans CJK KR",
|
|
"korean-800": "Noto Sans CJK KR Black",
|
|
code: "Liberation Mono",
|
|
};
|
|
|
|
const installHint = [
|
|
"Visual tests must draw with the fonts the goldens were captured with.",
|
|
// 1103/11-02. The CI browser step installs the same list.
|
|
`Debian/Ubuntu: sudo ${VISUAL_TEST_FONT_INSTALL_ARGUMENTS}`,
|
|
"tests/visual/fonts.conf reads them from the Debian/Ubuntu font directories; other OSes have no Linux goldens.",
|
|
].join("\n");
|
|
|
|
async function drawnFaces(page: Page) {
|
|
await page.goto("/");
|
|
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
|
|
await page.evaluate(() => {
|
|
const probes = document.createElement("div");
|
|
probes.innerHTML = `
|
|
<p data-font-probe="latin">Clean Architecture Frontend</p>
|
|
<p data-font-probe="korean">플랫폼구성화면상태</p>
|
|
<p data-font-probe="korean-800" style="font-weight: 800">플랫폼구성화면상태</p>
|
|
<code data-font-probe="code">const value = 42;</code>`;
|
|
document.body.append(probes);
|
|
});
|
|
|
|
const cdp = await page.context().newCDPSession(page);
|
|
await cdp.send("DOM.enable");
|
|
await cdp.send("CSS.enable");
|
|
const { root } = await cdp.send("DOM.getDocument");
|
|
const drawn: Record<string, string> = {};
|
|
for (const probe of Object.keys(expectedFaces)) {
|
|
const { nodeId } = await cdp.send("DOM.querySelector", {
|
|
nodeId: root.nodeId,
|
|
selector: `[data-font-probe="${probe}"]`,
|
|
});
|
|
const { fonts } = await cdp.send("CSS.getPlatformFontsForNode", { nodeId });
|
|
drawn[probe] = fonts.map((font) => font.familyName).join(" + ");
|
|
}
|
|
return drawn;
|
|
}
|
|
|
|
test("visual fonts match the goldens", async ({ page }) => {
|
|
let drawn: Record<string, string>;
|
|
try {
|
|
drawn = await drawnFaces(page);
|
|
} catch (error) {
|
|
// With no font at all the renderer crashes, so the page never draws.
|
|
throw new Error(
|
|
`${installHint}\nThe font probe page did not render: ${String(error)}`,
|
|
{ cause: error },
|
|
);
|
|
}
|
|
expect(drawn, installHint).toEqual(expectedFaces);
|
|
});
|