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(); });