diff --git a/CHANGELOG.md b/CHANGELOG.md index e203972f..9a355b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ ## 미출시 — `db6a6eb6` → CI를 runner에서 초록으로, merge 시간 줄이기 -Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지 않고 같은 시험을 두 번 도는 곳과 job마다 같은 것을 내려받는 곳을 없앤다. 제품 코드는 바뀌지 않는다. +Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지 않고 같은 시험을 두 번 도는 곳과 job마다 같은 것을 내려받는 곳을 없앤다. 긴 릴리스 ID와 지원 참조가 320px 화면을 넘치던 결함도 고친다. ### 먼저 할 일 @@ -55,6 +55,8 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지 | FE-GATE-013의 시스템 컨테이너가 systemd 전에 root cgroup 제어기를 켠다. 부팅 중 `docker exec`가 root cgroup에 남으면 systemd가 user manager에 제어기를 넘기지 못해 provider 시험 18개가 exit 125로 떨어졌다(desktop 4회 중 1회). 사전 점검이 user manager의 cpu·memory·pids 제어기를 보고, provider 실패 메시지에 우리 단계가 쓴 고정 이유 줄을 남긴다 | `scripts/run-in-system-container.sh`, `scripts/check-system-test-prerequisites.ts`, `scripts/lib/provider-sandbox-diagnostics.ts`, `scripts/run-and-validate-provider.ts`, `scripts/lib/provider-scope-wrapper.ts` | `6d6fd61a`, `4e1a385f`, `13b40934` | | `ci:gate`가 실패하면 job 로그의 끝 줄 앞에 실패한 명령의 첫 실패 블록을 「first failure in the log」로 싣는다. Playwright는 번호 붙은 실패 줄부터, vitest는 `Failed Suites`·`Failed Tests`·`Unhandled Errors` 줄부터 싣고, 길이 상한은 `FIRST_FAILURE_MAX_LINES`다. 끝 줄만 남던 때는 단언의 기대·받은 값이 밀려나 artifact를 받아야 원인이 보였다. 블록을 못 찾으면 지금처럼 끝 줄만 보인다 | `scripts/lib/ci-gate-failure.ts`, `tests/unit/ci-gate-failure.test.ts` | `829733cf` | | 시험 증거 전체 검사(FE-GATE-008)가 checkout에 없는 Playwright 설정에서 ENOENT 스택으로 죽지 않고, 그 파일과 출처(`config/repository-layout.json`의 `playwright-configs` 항목, 또는 `--playwright-config`)를 대는 실패 줄을 보고서와 로그에 남긴다. 릴리스 증거 토큰을 읽는 `playwright.config.ts`가 없을 때도 같다. 게이트 판정은 그대로 실패다. capability를 지우며 설정 파일만 지우고 등록부 항목을 남기면 이 실패가 난다. 매뉴얼 03 E절이 루트 항목을 지울 때 등록부 항목과 secret-scan `trackedRoots`도 지우라고 적는다 | `scripts/check-test-evidence.ts`, `tests/unit/test-evidence-repository-configs.test.ts`, `docs/manual/03-outside-feature-folder.md` | `439d3271` | +| 끊을 곳 없는 긴 RELEASE_ID·build id, 서버의 상관 ID(128자까지)와 item id가 320px 화면을 넘치지 않는다. 지원 참조는 새 `SupportReference` 하나가 그리고(`ui-support-reference`), 홈 런타임 요약·부팅 오류 화면의 값·상세 화면 메타데이터의 값은 `overflow-wrap: anywhere`를 쓴다. 홈은 grid 항목이라 고치기 전 세 엔진에서 594~641px로 넓어졌다. 기능 화면이 지원 참조를 직접 그렸으면 디자인 시스템 배럴의 컴포넌트에 넘긴다. 오류 화면은 `TerminalErrorSurface`·`StatusPage`의 `supportReference`로 넘긴다. `AsyncSurface`의 `supportReference`는 결과를 모르는 저장일 때만 그려지고(`useAppForm().supportReference`), 오류로 끝난 상태는 `failure.requestId`를 스스로 그린다. `SupportReference`는 배럴 밖이다 | `src/presentation/components/support-reference.tsx`, `src/presentation/components/async-surface.tsx`, `src/presentation/templates/page-templates.tsx`, `src/presentation/boundaries/`, `src/presentation/styles/theme/`, `tests/e2e/responsive.spec.ts`, `tests/e2e/generated-feature.spec.ts`, `tests/e2e/support/reflow.ts` | `953e1ca5` | +| `scripts/verify.sh`가 RELEASE_ID에 checkout 브랜치 이름을 넣지 않고 CI와 같은 꼴의 고정 ref(`refs/heads/verify-1-1`)를 쓴다. 같은 트리의 FE-GATE-008 결과가 브랜치 이름 길이로 갈렸다 | `scripts/verify.sh`, `scripts/tests/test_verify.py` | `4ab62f81` | ## 미출시 — `8327e221` → 하네스와 작업 매뉴얼 diff --git a/scripts/tests/test_verify.py b/scripts/tests/test_verify.py index b0be140a..64a44ced 100644 --- a/scripts/tests/test_verify.py +++ b/scripts/tests/test_verify.py @@ -166,34 +166,71 @@ class CiEnvironmentTest(unittest.TestCase): self.assertRegex(image, r"@sha256:[0-9a-f]{64}$") +def remote_project(base: Path) -> tuple[Path, Path, Path, dict]: + """A project with an origin and a clone of it as the remote checkout, and the env that sends a run there.""" + project, bare, remote, logs = (base / name for name in ("project", "origin.git", "remote", "logs")) + (project / "scripts").mkdir(parents=True) + (project / "config/ci").mkdir(parents=True) + shutil.copy(VERIFY, project / "scripts/verify.sh") + shutil.copy(REPO / "config/ci/gates.json", project / "config/ci/gates.json") + shutil.copy(REPO / ".nvmrc", project / ".nvmrc") + (project / "scripts/check-work-docs.py").write_text("print('docs checked')\n", encoding="utf-8") + sh(["git", "init", "-q", "-b", "main"], cwd=project) + sh(["git", "add", "-A"], cwd=project) + sh(["git", "commit", "-q", "-m", "init"], cwd=project) + sh(["git", "clone", "-q", "--bare", str(project), str(bare)], cwd=base) + sh(["git", "remote", "add", "origin", str(bare)], cwd=project) + sh(["git", "fetch", "-q", "origin"], cwd=project) + sh(["git", "clone", "-q", str(bare), str(remote)], cwd=base) + fake_ssh = base / "fake-ssh" + fake_ssh.write_text('#!/bin/sh\nshift\nexec bash -c "$*"\n', encoding="utf-8") + fake_ssh.chmod(0o755) + env = {"VERIFY_SSH": str(fake_ssh), "VERIFY_REMOTE_REPO": str(remote), "VERIFY_LOCK": str(base / "lock"), + "VERIFY_LOG_ROOT": str(logs), "VERIFY_NODE_BIN": "/nonexistent"} + return project, remote, logs, env + + +class ReleaseIdTest(unittest.TestCase): + """The build a run makes is named as in CI, with a fixed ref: never after the branch the checkout is on. + + The ref used to be the checkout's branch. A long branch name made a release id the home page could not wrap at + 320 px, so FE-GATE-008 passed detached and failed on the branch, on the same tree. + """ + + def test_a_long_branch_and_a_detached_checkout_build_the_same_release_id(self) -> None: + with tempfile.TemporaryDirectory() as folder: + base = Path(folder) + project, _, _, env = remote_project(base) + # Stands in for the remote's node bin: the gate's `corepack pnpm -s ci:gate` records what it was given. + tools, seen = base / "bin", base / "release-ids" + tools.mkdir() + (tools / "corepack").write_text('#!/bin/sh\nprintf "%s\\n" "$RELEASE_ID" >> "$SEEN_RELEASE_IDS"\n', + encoding="utf-8") + (tools / "corepack").chmod(0o755) + # VERIFY_RUN is cleared: a caller's own run number must not reach the expected value. + env = {**env, "VERIFY_NODE_BIN": str(tools), "VERIFY_INSTALL": "0", "SEEN_RELEASE_IDS": str(seen), + "VERIFY_RUN": ""} + gate = gates()["gates"][0]["id"] + + sh(["git", "switch", "-q", "-c", "fix/" + "a-branch-name-that-keeps-going-" * 4 + "on"], cwd=project) + sh(["scripts/verify.sh", "gate", gate, "--on", "build-host"], cwd=project, env=env) + sh(["git", "switch", "-q", "--detach"], cwd=project) + sh(["scripts/verify.sh", "gate", gate, "--on", "build-host"], cwd=project, env=env) + + # .gitea/workflows/quality-gates.yml: "${{ gitea.ref }}-${{ gitea.run_id }}-${{ gitea.run_attempt }}" + self.assertEqual(seen.read_text(encoding="utf-8").splitlines(), ["refs/heads/verify-1-1"] * 2) + + class RemoteTransportTest(unittest.TestCase): """--on <호스트>: the patch lands in a fresh worktree, the tree matches, the run is logged, the worktree goes.""" def test_the_working_tree_is_run_remotely_on_the_same_tree_and_cleaned_up(self) -> None: with tempfile.TemporaryDirectory() as folder: base = Path(folder) - project, bare, remote, logs = (base / name for name in ("project", "origin.git", "remote", "logs")) - (project / "scripts").mkdir(parents=True) - (project / "config/ci").mkdir(parents=True) - shutil.copy(VERIFY, project / "scripts/verify.sh") - shutil.copy(REPO / "config/ci/gates.json", project / "config/ci/gates.json") - shutil.copy(REPO / ".nvmrc", project / ".nvmrc") - (project / "scripts/check-work-docs.py").write_text("print('docs checked')\n", encoding="utf-8") - sh(["git", "init", "-q", "-b", "main"], cwd=project) - sh(["git", "add", "-A"], cwd=project) - sh(["git", "commit", "-q", "-m", "init"], cwd=project) - sh(["git", "clone", "-q", "--bare", str(project), str(bare)], cwd=base) - sh(["git", "remote", "add", "origin", str(bare)], cwd=project) - sh(["git", "fetch", "-q", "origin"], cwd=project) - sh(["git", "clone", "-q", str(bare), str(remote)], cwd=base) + project, remote, logs, env = remote_project(base) (project / "notes.md").write_text("커밋 안 한 새 파일\n", encoding="utf-8") with (project / "scripts/check-work-docs.py").open("a", encoding="utf-8") as handle: handle.write("print('changed here')\n") - fake_ssh = base / "fake-ssh" - fake_ssh.write_text('#!/bin/sh\nshift\nexec bash -c "$*"\n', encoding="utf-8") - fake_ssh.chmod(0o755) - env = {"VERIFY_SSH": str(fake_ssh), "VERIFY_REMOTE_REPO": str(remote), "VERIFY_LOCK": str(base / "lock"), - "VERIFY_LOG_ROOT": str(logs), "VERIFY_NODE_BIN": "/nonexistent"} temp_index = base / "index" shutil.copy(project / ".git/index", temp_index) sh(["git", "add", "-A"], cwd=project, env={"GIT_INDEX_FILE": str(temp_index)}) diff --git a/scripts/verify.sh b/scripts/verify.sh index 3c57b403..324c05ec 100755 --- a/scripts/verify.sh +++ b/scripts/verify.sh @@ -97,11 +97,12 @@ for number, line in enumerate(open(sys.argv[1], encoding="utf-8"), 1): run_hooks() { python3 -m unittest discover -s scripts/tests; } # CI workflow의 전역 env(.gitea/workflows/quality-gates.yml)와 같은 꼴. CI=true가 있어야 빌드 식별값을 엄격하게 본다. +# RELEASE_ID의 ref는 고정 값이다. checkout의 브랜치 이름을 넣으면 같은 트리의 결과가 브랜치 이름 길이에 따라 갈렸다. ci_env() { local sha sha=$(git rev-parse HEAD) export CI=true VITE_COMMIT_SHA="$sha" VITE_BUILD_ID="gitea-${VERIFY_RUN:-1}-1" \ - RELEASE_ID="refs/heads/${VERIFY_REF:-verify}-${VERIFY_RUN:-1}-1" \ + RELEASE_ID="refs/heads/verify-${VERIFY_RUN:-1}-1" \ CI_RUNNER_IMAGE="local/runner@sha256:$(printf 'a%.0s' $(seq 64))" \ SOURCE_DATE_EPOCH="$(git log -1 --format=%ct)" # ci:gate makes SOURCE_DATE_EPOCH from HEAD itself; parts and script call the commands directly. @@ -255,14 +256,13 @@ run_here() { run_remote() { local host=$1 log=$2 ssh=${VERIFY_SSH:-ssh} shift 2 - local name base tree tmp_index patch id remote_repo lock log_root node_bin args ref install=${VERIFY_INSTALL:-1} rc=0 back + local name base tree tmp_index patch id remote_repo lock log_root node_bin args install=${VERIFY_INSTALL:-1} rc=0 back name=$(basename "$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")") remote_repo=${VERIFY_REMOTE_REPO:-"workspace/$name"} lock=${VERIFY_LOCK:-/tmp/claude-gates/heavy.lock} log_root=${VERIFY_LOG_ROOT:-/tmp/claude-gates} node_bin=${VERIFY_NODE_BIN:-"\$HOME/.nvm/versions/node/v$(tr -d '[:space:]' < .nvmrc)/bin"} base=$(git merge-base HEAD "${VERIFY_BASE_REF:-origin/main}") - ref=$(git branch --show-current | tr '/' '-') laptop_stage "$1" && install=0 tmp_index=$(mktemp) patch=$(mktemp) @@ -314,7 +314,7 @@ if [ $install = 1 ]; then || CI=true corepack pnpm install --frozen-lockfile >> "\$logs/install.log" 2>&1 \ || { echo "의존성 설치 실패: \$logs/install.log" >&2; exit 4; } fi -export VERIFY_SUMMARY="\$logs/summary.txt" VERIFY_STEP_LOGS="\$logs" VERIFY_REF="$ref" VERIFY_HOST_ENVIRONMENT="${VERIFY_HOST_ENVIRONMENT:-on}" +export VERIFY_SUMMARY="\$logs/summary.txt" VERIFY_STEP_LOGS="\$logs" VERIFY_HOST_ENVIRONMENT="${VERIFY_HOST_ENVIRONMENT:-on}" flock $lock ./scripts/verify.sh $args 2>&1 | tee "\$logs/run.log" rc=\${PIPESTATUS[0]} git status --porcelain > "\$logs/status-after.txt" diff --git a/src/presentation/boundaries/boot-error-shell.tsx b/src/presentation/boundaries/boot-error-shell.tsx index 97e90da5..84c4fff7 100644 --- a/src/presentation/boundaries/boot-error-shell.tsx +++ b/src/presentation/boundaries/boot-error-shell.tsx @@ -37,7 +37,7 @@ export function BootErrorShell({ }: BootErrorShellProps) { const retry = onRetry !== undefined && RETRYABLE_CODES.has(code); return ( -
+

{MESSAGES["boot.failure.title"]}

{MESSAGES["boot.field.error"]}
@@ -77,7 +77,7 @@ export function BootErrorShell({ )} -

+

{MESSAGES["boot.supportReference"].replace( "{reference}", () => supportReference, diff --git a/src/presentation/boundaries/chunk-recovery-boundary.tsx b/src/presentation/boundaries/chunk-recovery-boundary.tsx index 8af8d5a9..43b42fc3 100644 --- a/src/presentation/boundaries/chunk-recovery-boundary.tsx +++ b/src/presentation/boundaries/chunk-recovery-boundary.tsx @@ -3,6 +3,7 @@ import { type ErrorInfo, type ReactNode, } from "react"; +import { SupportReference } from "../components/support-reference.tsx"; import { Button, LoadingSurface } from "../design-system/index.ts"; import { useLocale } from "../i18n/index.ts"; import { newIncidentId } from "../../platform/errors/incident-id.ts"; @@ -138,13 +139,7 @@ function ChunkRecoverySurface({ - {supportReference ? ( -

- {message("template.supportReference", { - reference: supportReference, - })} -

- ) : null} + {supportReference ? : null} ); } diff --git a/src/presentation/components/async-surface.tsx b/src/presentation/components/async-surface.tsx index 783f0c08..3fd9a734 100644 --- a/src/presentation/components/async-surface.tsx +++ b/src/presentation/components/async-surface.tsx @@ -10,6 +10,7 @@ import { type HeadingLevel, NotFoundSurface, } from "./state-surfaces.tsx"; +import { SupportReference } from "./support-reference.tsx"; import { Button } from "./ui/button.ts"; export function LoadingSurface({ @@ -105,13 +106,7 @@ export function TerminalErrorSurface({ {action !== "none" && onAction && ( )} - {supportReference ? ( -

- {message("template.supportReference", { - reference: supportReference, - })} -

- ) : null} + {supportReference ? : null} ); } @@ -176,11 +171,7 @@ export function AsyncSurface({
{state.failure.requestId ? ( -

- {message("template.supportReference", { - reference: state.failure.requestId, - })} -

+ ) : null}
); @@ -240,11 +231,7 @@ export function AsyncSurface({ ) : null} {state.indicator === "mutation-effect-unknown" && notice ?

{notice}

: null} {state.indicator === "mutation-effect-unknown" && supportReference ? ( -

- {message("template.supportReference", { - reference: supportReference, - })} -

+ ) : null} ) : null} diff --git a/src/presentation/components/support-reference.tsx b/src/presentation/components/support-reference.tsx new file mode 100644 index 00000000..eaadd698 --- /dev/null +++ b/src/presentation/components/support-reference.tsx @@ -0,0 +1,17 @@ +import { useLocale } from "../i18n/index.ts"; + +/** + * The support reference a failure shows: the build, the incident or the + * server's request id a user reads out to support. Every surface draws it + * here, so each breaks a long id the same way (`.ui-support-reference`). The + * boot error shell draws its own paragraph with that class: it renders + * without the locale provider. + */ +export function SupportReference({ reference }: Readonly<{ reference: string }>) { + const { message } = useLocale(); + return ( +

+ {message("template.supportReference", { reference })} +

+ ); +} diff --git a/src/presentation/styles/theme/pages.css b/src/presentation/styles/theme/pages.css index 0bdae05c..3cb5f475 100644 --- a/src/presentation/styles/theme/pages.css +++ b/src/presentation/styles/theme/pages.css @@ -6,6 +6,14 @@ gap: var(--space-6); } + /* The deployment names the build and the release: a commit digest or a + long branch ref has no place to break. This paragraph is a grid item, so + the id set its min-content width and widened the page past 320 px. + `anywhere` breaks the id and shrinks that width. */ + .ui-runtime-summary { + overflow-wrap: anywhere; + } + .readiness-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); diff --git a/src/presentation/styles/theme/primitives.css b/src/presentation/styles/theme/primitives.css index 8713f9e6..3a2689d6 100644 --- a/src/presentation/styles/theme/primitives.css +++ b/src/presentation/styles/theme/primitives.css @@ -5,6 +5,15 @@ box-sizing: border-box; } + /* A support reference names a build, an incident or the server's request + id (up to 128 characters, src/adapters/http/backend-envelope.ts), often + with no place to break. `anywhere`, not the base `break-word`: it also + shrinks min-content, so a grid or flex ancestor does not size itself to + the whole id and push the page past 320 px. */ + .ui-support-reference { + overflow-wrap: anywhere; + } + .ui-panel { @apply rounded-surface p-6; box-shadow: var(--elevation-panel); diff --git a/src/presentation/styles/theme/templates.css b/src/presentation/styles/theme/templates.css index d2d0f33a..7a59315d 100644 --- a/src/presentation/styles/theme/templates.css +++ b/src/presentation/styles/theme/templates.css @@ -163,7 +163,15 @@ justify-content: flex-start; } - .status-page__support { + .status-page > .ui-support-reference { color: var(--color-content-muted); } + + /* The boot error shell's values and a detail page's metadata: a build or + release id, an item id, a list of keys. The base rule breaks a long word + only on a Korean page (`:lang(ko)`), and an en-US page has none. */ + .boot-error-shell dd, + .detail-page__metadata dd { + overflow-wrap: anywhere; + } } diff --git a/src/presentation/templates/page-templates.tsx b/src/presentation/templates/page-templates.tsx index 0488385d..515d5638 100644 --- a/src/presentation/templates/page-templates.tsx +++ b/src/presentation/templates/page-templates.tsx @@ -1,6 +1,7 @@ import type { ReactNode } from "react"; import { PageHeader } from "../components/page-header.tsx"; +import { SupportReference } from "../components/support-reference.tsx"; import { Button } from "../components/ui/button.ts"; import { LinkButton, @@ -241,7 +242,6 @@ export function StatusPage( children?: ReactNode; }>, ) { - const { message } = useLocale(); return (
- {message("template.supportReference", { - reference: props.supportReference, - })} -

+ ) : null}
); diff --git a/tests/e2e/generated-feature.spec.ts b/tests/e2e/generated-feature.spec.ts index fd864fe3..39914bf9 100644 --- a/tests/e2e/generated-feature.spec.ts +++ b/tests/e2e/generated-feature.spec.ts @@ -16,6 +16,7 @@ import { routePath, type GeneratedFeature, } from "../../scripts/lib/generated-feature.ts"; +import { expectReflowed } from "./support/reflow.ts"; import { startBuildServer } from "./support/service-worker-builds.ts"; /** @@ -31,6 +32,13 @@ import { startBuildServer } from "./support/service-worker-builds.ts"; const META = Object.freeze({ requestId: "req-e2e", traceId: "0af7651916cd43dd8448eb211c80319c" }); const ITEM = Object.freeze({ id: "browser-order", name: "Browser order" }); const WCAG_TAGS = [...WCAG_AXE_TAGS]; +/** + * Server values with no place to break, as long as the client takes them: a + * correlation id up to 128 characters (src/adapters/http/http-execution-v3.ts), + * an item id up to 120 (the generated contract's id). + */ +const LONG_REQUEST_ID = "0123456789abcdef".repeat(8); +const LONG_ITEM_ID = `${"0123456789abcdef".repeat(7)}01234567`; let builds: FixtureBuilds<"a"> | undefined; let server: Awaited> | undefined; @@ -188,6 +196,18 @@ test.describe("the route", () => { await expect(main.getByRole("button", { name: english[generatedMessageKey("form.save")]! })).toBeVisible(); await expect(main).not.toContainText(/[가-힣]/u); }); + + // The detail page's metadata shows the server's item id. An en-US page has + // no `:lang(ko)` rule to break a long word. + test("wraps a long item id on its en-US detail page at 320px", async ({ page }) => { + await answerReads(page); + await signInAt(page, routePath(feature.detail, LONG_ITEM_ID), ITEM.name); + await page.getByRole("combobox", { name: "언어" }).first().selectOption("en-US"); + await expect(page.locator("html")).toHaveAttribute("lang", "en-US"); + await page.setViewportSize({ width: 320, height: 720 }); + + await expectReflowed(page, page.getByRole("main").getByText(LONG_ITEM_ID, { exact: true })); + }); }); test.describe("the form", () => { @@ -295,6 +315,30 @@ test.describe("the save", () => { await saveFromKeyboard(page, KO_MESSAGES["action.retry"]); }); + + // A terminal failure's own support reference (the failure surface). + test("wraps a long request id within a 320px viewport", async ({ page }) => { + await page.setViewportSize({ width: 320, height: 720 }); + await openForm(page); + await answerCreates(page, [ + (route) => + route.fulfill({ + status: 429, + headers: { + "retry-after": "1", + "x-correlation-id": LONG_REQUEST_ID, + "access-control-expose-headers": "x-correlation-id", + }, + json: failure("RATE_LIMIT_EXCEEDED", "RATE_LIMIT", true), + }), + ]); + + await nameField(page).fill(ITEM.name); + await saveButton(page).click(); + + await expect(page.getByText(KO_MESSAGES["error.rate_limited"])).toBeVisible(); + await expectReflowed(page, page.getByText(`지원 참조: ${LONG_REQUEST_ID}`)); + }); }); test.describe("after a save whose result is unknown", () => { @@ -324,6 +368,30 @@ test.describe("the save", () => { await expect(page.getByText(/^지원 참조: /u)).toBeVisible(); }); + // The unknown result's support reference, in the status row above the + // form. + test("wraps a long request id within a 320px viewport", async ({ page }) => { + await page.setViewportSize({ width: 320, height: 720 }); + await openForm(page); + await answerCreates(page, [ + (route) => + route.fulfill({ + status: 500, + headers: { + "x-correlation-id": LONG_REQUEST_ID, + "access-control-expose-headers": "x-correlation-id", + }, + json: failure("INTERNAL_ERROR", "INTERNAL", false), + }), + ]); + + await nameField(page).fill(ITEM.name); + await saveButton(page).click(); + + await expect(page.getByText(KO_MESSAGES["async.mutationEffectUnknown"])).toBeVisible(); + await expectReflowed(page, page.getByText(`지원 참조: ${LONG_REQUEST_ID}`)); + }); + test("keeps keyboard focus in the unknown-result status", async ({ page }) => { await openForm(page); await answerCreates(page, [lost]); diff --git a/tests/e2e/responsive.spec.ts b/tests/e2e/responsive.spec.ts index 215322f4..4f72ea61 100644 --- a/tests/e2e/responsive.spec.ts +++ b/tests/e2e/responsive.spec.ts @@ -1,4 +1,48 @@ +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>; + manifest?: Readonly>; + }>, +): Promise { + const answer = (pathname: string, fields: Readonly>) => + 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. @@ -21,6 +65,70 @@ test("reflows the shell at the 320px minimum without horizontal overflow", async 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 `
`: 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 { + await page.route( + (url) => url.pathname === "/", + async (route) => { + const response = await route.fetch(); + const html = await response.text(); + if (html.split('').length !== 2) { + throw new Error('Expected one 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('', ``), + }); + }, + ); +} + +// 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)); + }); +} + // 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. diff --git a/tests/e2e/support/reflow.ts b/tests/e2e/support/reflow.ts new file mode 100644 index 00000000..76880c09 --- /dev/null +++ b/tests/e2e/support/reflow.ts @@ -0,0 +1,24 @@ +import type { Locator, Page } from "@playwright/test"; + +import { expect } from "../../support/browser/strict-browser-test.ts"; + +/** + * WCAG 1.4.10 at the viewport the test set: the page scrolls only vertically, + * and `text` is drawn whole inside its own box. The second check fails a fix + * that clips the value (`overflow: hidden`) instead of breaking it. `text` is + * a block (a `p`, a `dd`): an inline element has no client box to compare. + */ +export async function expectReflowed(page: Page, text: Locator): Promise { + await expect(text).toBeVisible(); + const viewport = await page.evaluate(() => ({ + clientWidth: document.documentElement.clientWidth, + scrollWidth: document.documentElement.scrollWidth, + })); + expect(viewport.scrollWidth).toBeLessThanOrEqual(viewport.clientWidth); + const box = await text.evaluate((element) => ({ + clientWidth: element.clientWidth, + scrollWidth: element.scrollWidth, + })); + expect(box.clientWidth, "the value's element has a block box").toBeGreaterThan(0); + expect(box.scrollWidth).toBeLessThanOrEqual(box.clientWidth); +}