import { expect, test } from "../support/browser/strict-browser-test.ts"; // 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); }); // 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/, ); });