부트 실패 화면의 유일한 조작인 재시도 버튼에 class가 없어 높이가 24px이다. 정적 class ui-button ui-button--primary만 단다. Button을 import하는 안은 버렸다. 깊은 경로는 import 규칙이 막고, 배럴은 규칙을 통과하지만 앱 그래프 없이 떠야 하는 화면의 부트 의존이 는다. 전용 CSS는 같은 규칙이 둘이 되어 버렸다. 한계: 320px에서 높이와 너비만 쟀다. render-error-boundary의 버튼은 DES-FE-0005가 다룬다. 검증: 고치기 전 component 4개와 세 엔진의 e2e(높이 24) 실패, 고친 뒤 component 12개와 responsive spec 27개 통과. Refs: DES-FE-0009
215 lines
8.3 KiB
TypeScript
215 lines
8.3 KiB
TypeScript
import type { Page } from "@playwright/test";
|
|
|
|
import { expect, test } from "../support/browser/strict-browser-test.ts";
|
|
import { expectReflowed } from "./support/reflow.ts";
|
|
|
|
/**
|
|
* A release id is the deployment's value: a commit digest or a long branch
|
|
* ref, with no place to break. The build this spec serves takes its id from
|
|
* whatever environment built it (a CI run names its branch), so these tests
|
|
* answer the runtime config and the release manifest with a long one
|
|
* themselves.
|
|
*/
|
|
const LONG_RELEASE_ID = `release-${"0123456789abcdef".repeat(4)}`;
|
|
|
|
/**
|
|
* Answers the build's own runtime config and release manifest with `config`
|
|
* and `manifest` merged in. `/release-manifest.json` is the config's
|
|
* `RELEASE_MANIFEST_URL` (`public/config.json`); a manifest this misses keeps
|
|
* the build's release id, and the boot fails on the mismatch.
|
|
*/
|
|
async function answerReleaseDocuments(
|
|
page: Page,
|
|
changes: Readonly<{
|
|
config: Readonly<Record<string, unknown>>;
|
|
manifest?: Readonly<Record<string, unknown>>;
|
|
}>,
|
|
): Promise<void> {
|
|
const answer = (pathname: string, fields: Readonly<Record<string, unknown>>) =>
|
|
page.route(
|
|
(url) => url.pathname === pathname,
|
|
async (route) => {
|
|
const response = await route.fetch();
|
|
const headers = { ...response.headers() };
|
|
delete headers["content-length"];
|
|
delete headers["content-encoding"];
|
|
await route.fulfill({
|
|
status: response.status(),
|
|
headers,
|
|
body: JSON.stringify({ ...((await response.json()) as object), ...fields }),
|
|
});
|
|
},
|
|
);
|
|
await answer("/config.json", changes.config);
|
|
if (changes.manifest) await answer("/release-manifest.json", changes.manifest);
|
|
}
|
|
|
|
// The gallery's own 320px reflow is a workshop check
|
|
// (tests/storybook/galleries.spec.ts); this one is the shell around a page.
|
|
test("reflows the shell at the 320px minimum without horizontal overflow", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 320, height: 720 });
|
|
await page.goto("/");
|
|
await expect(
|
|
page.getByRole("heading", { level: 1, name: "Clean Architecture Frontend" }),
|
|
).toBeVisible();
|
|
await expect(
|
|
page.getByRole("button", { name: "메뉴", exact: true }),
|
|
).toBeVisible();
|
|
|
|
const viewport = await page.evaluate(() => ({
|
|
clientWidth: document.documentElement.clientWidth,
|
|
scrollWidth: document.documentElement.scrollWidth,
|
|
}));
|
|
expect(viewport.scrollWidth).toBeLessThanOrEqual(viewport.clientWidth);
|
|
});
|
|
|
|
// The home page's runtime summary is a grid item: a long release id set its
|
|
// min-content width and widened the page past 320px (to 371px in Firefox and
|
|
// WebKit with a long branch ref).
|
|
test("wraps a long release id on the home page at the 320px minimum", async ({
|
|
page,
|
|
}) => {
|
|
await answerReleaseDocuments(page, {
|
|
config: { RELEASE_ID: LONG_RELEASE_ID },
|
|
manifest: { releaseId: LONG_RELEASE_ID },
|
|
});
|
|
await page.setViewportSize({ width: 320, height: 720 });
|
|
await page.goto("/");
|
|
|
|
// The summary's own words, not the boot error shell's `<dd>`: a manifest
|
|
// this misses fails the boot, and the shell shows the same id.
|
|
await expectReflowed(page, page.getByText(`릴리스 ${LONG_RELEASE_ID}`));
|
|
await expect(page.getByRole("alert")).toHaveCount(0);
|
|
});
|
|
|
|
/** Serves the page's HTML with `lang` on its root element instead of `ko`. */
|
|
async function answerDocumentLanguage(page: Page, lang: string): Promise<void> {
|
|
await page.route(
|
|
(url) => url.pathname === "/",
|
|
async (route) => {
|
|
const response = await route.fetch();
|
|
const html = await response.text();
|
|
if (html.split('<html lang="ko">').length !== 2) {
|
|
throw new Error('Expected one <html lang="ko"> in the served page.');
|
|
}
|
|
const headers = { ...response.headers() };
|
|
delete headers["content-length"];
|
|
delete headers["content-encoding"];
|
|
await route.fulfill({
|
|
status: response.status(),
|
|
headers,
|
|
body: html.replace('<html lang="ko">', `<html lang="${lang}">`),
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
// A config that names another build fails the boot closed after one reload
|
|
// (CONFIG_BUILD_MISMATCH), and the boot error shell shows the config's
|
|
// release id. The shell is plain block layout, which the base `:lang(ko)`
|
|
// rule already wraps; a product whose page is not Korean (`lang="en"`) has
|
|
// no such rule, so the shell must break the id itself.
|
|
for (const lang of ["ko", "en"]) {
|
|
test(`wraps a long release id in the boot error shell of a lang=${lang} page at the 320px minimum`, async ({
|
|
page,
|
|
}) => {
|
|
if (lang !== "ko") await answerDocumentLanguage(page, lang);
|
|
await answerReleaseDocuments(page, {
|
|
config: { BUILD_ID: "another-build", RELEASE_ID: LONG_RELEASE_ID },
|
|
});
|
|
await page.setViewportSize({ width: 320, height: 720 });
|
|
await page.goto("/");
|
|
|
|
await expect(page.locator("html")).toHaveAttribute("lang", lang);
|
|
const shell = page.getByRole("alert");
|
|
await expect(shell).toContainText("CONFIG_BUILD_MISMATCH");
|
|
await expectReflowed(page, shell.getByText(LONG_RELEASE_ID));
|
|
});
|
|
}
|
|
|
|
// DES-FE-0009. The only control of a boot failure a fresh load can fix.
|
|
test.describe("a runtime config that cannot be fetched", () => {
|
|
// The aborted request, and Chromium's console line for it, which names no
|
|
// URL. Another request that failed would still be recorded with its path.
|
|
test.use({
|
|
allowedBrowserFailure:
|
|
/^(?:requestfailed:GET:\/config\.json:|console:error:Failed to load resource: net::ERR_FAILED$)/u,
|
|
});
|
|
|
|
test("draws the boot retry button at least 44px in both directions at the 320px minimum", async ({
|
|
page,
|
|
}) => {
|
|
await page.route(
|
|
(url) => url.pathname === "/config.json",
|
|
(route) => route.abort(),
|
|
);
|
|
await page.setViewportSize({ width: 320, height: 720 });
|
|
await page.goto("/");
|
|
|
|
const shell = page.getByRole("alert");
|
|
await expect(shell).toContainText("CONFIG_FETCH_FAILED");
|
|
const retry = shell.getByRole("button", { name: "다시 시도" });
|
|
await expect(retry).toBeVisible();
|
|
const size = await retry.evaluate((button) => {
|
|
const { width, height } = button.getBoundingClientRect();
|
|
return { width, height };
|
|
});
|
|
expect.soft(size.height, "retry button height").toBeGreaterThanOrEqual(44);
|
|
expect.soft(size.width, "retry button width").toBeGreaterThanOrEqual(44);
|
|
});
|
|
});
|
|
|
|
// 08-01. Below 48rem the header hides the theme selector, the session status
|
|
// and the brand. WCAG 1.4.10 allows moving them, not dropping them: the menu
|
|
// drawer carries them. 640px is a 1280px window at 200% zoom.
|
|
for (const width of [320, 375, 640]) {
|
|
test(`keeps the theme selector and session status in the menu drawer at ${width}px`, async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width, height: 720 });
|
|
await page.goto("/");
|
|
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
|
|
await page.getByRole("button", { name: "메뉴", exact: true }).click();
|
|
const drawer = page.getByRole("dialog", { name: "메뉴" });
|
|
await expect(drawer).toBeVisible();
|
|
|
|
const theme = drawer.getByRole("combobox", { name: "색상 테마" });
|
|
await expect(theme).toBeVisible();
|
|
// Keyboard reach: the selector follows the last navigation link.
|
|
await drawer
|
|
.getByRole("navigation", { name: "주요 탐색" })
|
|
.getByRole("link")
|
|
.last()
|
|
.focus();
|
|
await page.keyboard.press("Tab");
|
|
await expect(theme).toBeFocused();
|
|
await theme.selectOption("dark");
|
|
await expect(page.locator("html")).toHaveAttribute("data-theme", "dark");
|
|
await theme.selectOption("light");
|
|
await expect(page.locator("html")).toHaveAttribute("data-theme", "light");
|
|
|
|
await expect(drawer.getByText("로그인 전", { exact: true })).toBeVisible();
|
|
await expect(
|
|
drawer.getByText("Frontend Skeleton", { exact: true }),
|
|
).toBeVisible();
|
|
});
|
|
}
|
|
|
|
test("keeps desktop navigation and two-column sections at wide viewports", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1440, height: 900 });
|
|
await page.goto("/examples/platform");
|
|
|
|
await expect(page.getByRole("navigation", { name: "주요 탐색" })).toBeVisible();
|
|
await expect(
|
|
page.getByRole("button", { name: "메뉴", exact: true }),
|
|
).toBeHidden();
|
|
await expect(page.locator(".component-grid--two").first()).toHaveCSS(
|
|
"grid-template-columns",
|
|
/.+px .+px/,
|
|
);
|
|
});
|