diff --git a/tests/e2e/app-shell.spec.ts b/tests/e2e/app-shell.spec.ts index a0455e9..88b6044 100644 --- a/tests/e2e/app-shell.spec.ts +++ b/tests/e2e/app-shell.spec.ts @@ -3,9 +3,7 @@ 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( - "Tech Log", - ); + await expect(page.getByRole("heading", { level: 1 })).toHaveText("TechLog"); await expect(page.getByRole("navigation", { name: "주요 탐색" })).toBeVisible(); await expect(page.getByRole("main")).toBeVisible(); }); @@ -40,25 +38,27 @@ test("provides an escape-dismissible mobile navigation", async ({ page }) => { await expect(menu).toBeFocused(); }); -// R3-6. A drawer link closes the modal drawer and changes the route in the -// same click. The drawer's deferred focus restore must not win over the new -// page's heading focus; Escape (no navigation) still returns to the menu. +// 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 page.goto("/"); - const menu = page.getByRole("button", { name: "메뉴", exact: true }); - const navigation = page.getByRole("navigation", { name: "주요 탐색" }); + 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 navigation.getByRole("link", { name: "프로젝트" }).click(); - await expect(page).toHaveURL(/\/examples\/states$/); - await expect(menu).toHaveAttribute("aria-expanded", "false"); - const heading = page.getByRole("heading", { level: 1, name: "화면 상태" }); + 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 (dialog close timer, lazy route commit) time to run. + // Give any late restore (lazy route commit) time to run. await page.waitForTimeout(300); expect( await page.evaluate(() => { @@ -67,10 +67,4 @@ test("moves focus to the new page after a mobile drawer link, not back to the me }), ).toBe(true); await expect(menu).not.toBeFocused(); - - await menu.click(); - await expect(navigation).toBeVisible(); - await page.keyboard.press("Escape"); - await expect(navigation).toBeHidden(); - await expect(menu).toBeFocused(); }); diff --git a/tests/e2e/production-csp.spec.ts b/tests/e2e/production-csp.spec.ts index 954eafd..811ce0e 100644 --- a/tests/e2e/production-csp.spec.ts +++ b/tests/e2e/production-csp.spec.ts @@ -54,17 +54,21 @@ test("boots and changes route under the production security headers", async ({ p expect(response?.headers()["content-security-policy"]).toBe( securityHeaders["Content-Security-Policy"], ); - await expect(page.getByRole("heading", { level: 1 })).toHaveText( - "Clean Architecture Frontend", - ); + // Template sync (af3d8e6): TechLog's home and a primary-navigation page in + // place of upstream's example screens. + await expect(page.getByRole("heading", { level: 1 })).toHaveText("TechLog"); await page .getByRole("navigation", { name: "주요 탐색" }) - .getByRole("link", { name: "화면 상태" }) + .getByRole("link", { name: "프로젝트" }) .click(); + // Upstream also waits for route focus here. TechLog's Public shell does not + // move focus on navigation (app-router.tsx leaves it to the shell); that is + // app-shell.spec.ts's to check, so this smoke stays about the policy. + await expect(page).toHaveURL(/\/projects$/); await expect( - page.getByRole("heading", { level: 1, name: "화면 상태" }), - ).toBeFocused(); + page.getByRole("heading", { level: 1, name: "프로젝트" }), + ).toBeVisible(); expect(await cspViolations(page)).toEqual([]); }); diff --git a/tests/e2e/scroll-restoration.spec.ts b/tests/e2e/scroll-restoration.spec.ts index f4f99d8..b96b8d8 100644 --- a/tests/e2e/scroll-restoration.spec.ts +++ b/tests/e2e/scroll-restoration.spec.ts @@ -2,37 +2,47 @@ import { expect, test, type Page } from "../support/browser/strict-browser-test. const scrollY = (page: Page) => page.evaluate(() => Math.round(window.scrollY)); +// Template sync (af3d8e6). Upstream scrolls its long example page; this product +// deleted it, and a TechLog Case (about 6,000px at 1280x720) is the long page. +const LONG_PAGE = "/cases/collection-fetch-join-pagination"; +const LONG_PAGE_TITLE = "컬렉션 Fetch Join과 페이징은 왜 충돌하는가"; + // 08-08. Back restores where the user was; a new route starts at the top. +// The Case body fills in after the title, so the test waits for it before it +// scrolls. test("restores the scroll position when navigating back", async ({ page }) => { const heading = page.getByRole("heading", { level: 1 }); - await page.goto("/examples/ui"); - await expect(heading).toHaveText("UI 구성요소"); + await page.goto(LONG_PAGE); + await expect(heading).toHaveText(LONG_PAGE_TITLE); + await expect(page.locator("main [aria-busy='true']")).toHaveCount(0); + await expect(page.locator("#remaining-cost")).toBeAttached(); await page.evaluate(() => window.scrollTo(0, 900)); await expect.poll(() => scrollY(page)).toBe(900); await page .getByRole("navigation", { name: "주요 탐색" }) - .getByRole("link", { name: "화면 상태" }) + .getByRole("link", { name: "프로젝트" }) .click(); - await expect(heading).toHaveText("화면 상태"); + await expect(heading).toHaveText("프로젝트"); await expect.poll(() => scrollY(page)).toBe(0); await page.goBack(); - await expect(heading).toHaveText("UI 구성요소"); + await expect(heading).toHaveText(LONG_PAGE_TITLE); await expect.poll(() => scrollY(page)).toBe(900); }); +// A section well below the first screen. The header is the TechLog site header. test("opens a hash link at its target below the sticky header", async ({ page, }) => { - await page.goto("/examples/ui#tokens-title"); - const target = page.locator("#tokens-title"); + await page.goto(`${LONG_PAGE}#separate-loading`); + const target = page.locator("#separate-loading"); await expect(target).toBeInViewport(); const top = await target.evaluate((element) => Math.round(element.getBoundingClientRect().top), ); const headerBottom = await page - .locator(".app-shell__header") + .locator(".site-header") .evaluate((element) => Math.round(element.getBoundingClientRect().bottom)); expect(top).toBeGreaterThanOrEqual(headerBottom); expect(await scrollY(page)).toBeGreaterThan(0);