Files
tech-log-frontend/tests/e2e/app-shell.spec.ts
T
DongHyeonka c408cc2e0e test(e2e): 템플릿에서 온 화면 시험을 TechLog 화면으로 옮긴다
09-29 템플릿 동기화(c80320d, ebea300→af3d8e6)가 템플릿 e2e 시험을
그대로 들여왔다. 그 시험은 이 제품이 지운 템플릿 예시 화면을 연다.
- app-shell: 제목 「Tech Log」(지금 브랜드는 「TechLog」), 템플릿 drawer의
  「메뉴」 버튼과 /examples/states.
- production-csp: 제목 「Clean Architecture Frontend」와 「화면 상태」 링크.
- scroll-restoration: /examples/ui와 .app-shell__header.
그래서 세 엔진 모두에서 요소를 찾지 못해 떨어진다.

같은 동작을 TechLog 화면으로 본다.
- 홈 제목은 TechLog, 이동할 화면은 주요 탐색의 「프로젝트」.
- drawer는 TechLog의 details.mobile-nav와 「모바일 주요 탐색」.
- 긴 화면은 Case(1280x720에서 약 6,000px), 해시 대상은 그 안의 h2.
- production-csp는 경로가 바뀐 것을 URL과 제목으로만 확인한다. 초점은
  app-shell 시험이 따로 본다. 그래야 초점 결함과 상관없이 CSP 검사가 돈다.

위험·한계: 옮긴 시험 가운데 셋은 제품이 그 동작을 하지 않아 여전히
떨어진다. 시험을 고쳐서 생긴 실패가 아니라, 템플릿 이름 때문에 가려져
있던 실패다.
- 경로 이동 뒤 초점: app-router.tsx는 「shell이 초점을 맡는다」며 이동을
  뺐지만, TechLog Public shell에는 초점 처리가 없다. drawer 링크로 이동해도
  새 화면의 제목으로 초점이 가지 않는다.
- 뒤로 가기 스크롤 복원: Case에서 900px 내려갔다가 다른 화면에 갔다
  돌아오면 0이다.
- 해시로 연 Case에서 대상 h2로 스크롤하지 않는다. TechLog 화면은 해시를
  처리하는 PageHeader를 쓰지 않는다(project-decisions-page만 따로 처리).
정할 것(초점 정책)이 있어 이 PR에서 제품을 고치지 않는다.

검증: production-csp는 세 엔진 모두 통과한다. 첫 번째 app-shell
시험(홈 부팅)과 scroll-restoration의 화면 열기까지는 통과하고, 위 세
동작에서 떨어진다.
2026-11-12 15:03:16 +09:00

71 lines
2.8 KiB
TypeScript

import { expect, test } from "../support/browser/strict-browser-test.ts";
import { gotoTechLog } from "../support/browser/tech-log-fixtures.ts";
test("boots the public app shell", async ({ page }) => {
await gotoTechLog(page, "/");
await expect(page.getByRole("heading", { level: 1 })).toHaveText("TechLog");
await expect(page.getByRole("navigation", { name: "주요 탐색" })).toBeVisible();
await expect(page.getByRole("main")).toBeVisible();
});
test("navigates to a registry-backed Public route without a page reload", async ({
page,
}) => {
await gotoTechLog(page, "/");
await page
.getByRole("navigation", { name: "주요 탐색" })
.getByRole("link", { name: "프로젝트" })
.click();
await expect(page).toHaveURL(/\/projects$/);
await expect(
page.getByRole("heading", { level: 1, name: "프로젝트" }),
).toBeVisible();
});
test("provides an escape-dismissible mobile navigation", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await gotoTechLog(page, "/");
const menu = page.locator("details.mobile-nav > summary");
await menu.click();
await expect(page.locator("details.mobile-nav")).toHaveAttribute("open", "");
await expect(page.getByRole("navigation", { name: "모바일 주요 탐색" })).toBeVisible();
await page.keyboard.press("Escape");
await expect(page.locator("details.mobile-nav")).not.toHaveAttribute("open", "");
await expect(page.getByRole("navigation", { name: "모바일 주요 탐색" })).toBeHidden();
await expect(menu).toBeFocused();
});
// R3-6 (template sync af3d8e6). A drawer link closes the drawer and changes
// the route in the same click. The new page's heading takes focus; it must not
// go back to the menu. Upstream drives its own drawer and example page; this is
// TechLog's `details.mobile-nav` and a primary-navigation page.
test("moves focus to the new page after a mobile drawer link, not back to the menu", async ({
page,
}) => {
await page.setViewportSize({ width: 390, height: 844 });
await gotoTechLog(page, "/");
const drawer = page.locator("details.mobile-nav");
const menu = drawer.locator("> summary");
const navigation = page.getByRole("navigation", { name: "모바일 주요 탐색" });
await menu.click();
await navigation.getByRole("link", { name: "프로젝트" }).click();
await expect(page).toHaveURL(/\/projects$/);
await expect(drawer).not.toHaveAttribute("open", "");
const heading = page.getByRole("heading", { level: 1, name: "프로젝트" });
await expect(heading).toBeFocused();
// Give any late restore (lazy route commit) time to run.
await page.waitForTimeout(300);
expect(
await page.evaluate(() => {
const active = document.activeElement;
return active?.matches("h1, main") === true;
}),
).toBe(true);
await expect(menu).not.toBeFocused();
});