max-width 8.5rem과 7rem 때문에 모든 언어에서 선택값이 잘렸다
("Light then", "Englisl", "라이트 테ㅁ"). 커밋된 시각 골든에도 잘린
머리글이 들어 있어, 시각 테스트가 결함을 정답으로 지키고 있었다.
고정 폭을 지웠다. 좁은 화면은 기존 메뉴 서랍 배치가 그대로 맡는다.
새 i18n e2e 테스트가 ko-KR, en-US, en-XA에서 선택 상자 폭을 브라우저가
옵션에 필요한 폭과 비교한다.
위험: 중간 폭에서 머리글이 넓어진다. responsive·app-shell·theme·compact
테스트가 통과했다.
검증: 새 테스트가 고치기 전 실패했고, 고친 뒤 chromium·firefox·webkit
모두 통과했다.
74 lines
3.1 KiB
TypeScript
74 lines
3.1 KiB
TypeScript
import { expect, test } from "../support/browser/strict-browser-test.ts";
|
|
|
|
test("switches the shell locale and keeps pseudo-locale copy within compact layout", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 320, height: 720 });
|
|
await page.goto("/");
|
|
|
|
const locale = page.getByRole("combobox", { name: "언어" });
|
|
await locale.selectOption("en-US");
|
|
await expect(page.locator("html")).toHaveAttribute("lang", "en-US");
|
|
await expect(page.locator("html")).toHaveAttribute("dir", "ltr");
|
|
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
|
|
|
|
await page.getByRole("combobox", { name: "Language" }).selectOption("en-XA");
|
|
await expect(page.locator("html")).toHaveAttribute("lang", "en-XA");
|
|
const dimensions = await page.evaluate(() => ({
|
|
clientWidth: document.documentElement.clientWidth,
|
|
scrollWidth: document.documentElement.scrollWidth,
|
|
}));
|
|
expect(dimensions.scrollWidth).toBeLessThanOrEqual(dimensions.clientWidth);
|
|
await expect(page.getByRole("button", { name: /Ménú/ })).toBeVisible();
|
|
});
|
|
|
|
// UI-04. A fixed max-width clipped the selected value ("Light then",
|
|
// "라이트 테ㅁ"). The selector must be at least as wide as the browser's own
|
|
// width for its options, which depends on the font the machine has.
|
|
test("keeps the header selectors as wide as their options in every locale", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1280, height: 800 });
|
|
await page.goto("/");
|
|
const selectors = page.locator(
|
|
".theme-selector select, .locale-selector select",
|
|
);
|
|
await expect(selectors).toHaveCount(2);
|
|
|
|
for (const locale of ["ko-KR", "en-US", "en-XA"]) {
|
|
await page.locator(".locale-selector select").selectOption(locale);
|
|
await expect(page.locator("html")).toHaveAttribute("lang", locale);
|
|
const shortfalls = await selectors.evaluateAll((elements) =>
|
|
elements.map((element) => {
|
|
const select = element as HTMLSelectElement;
|
|
const actual = select.getBoundingClientRect().width;
|
|
const inline = select.style.cssText;
|
|
select.style.maxWidth = "none";
|
|
select.style.width = "auto";
|
|
const needed = select.getBoundingClientRect().width;
|
|
select.style.cssText = inline;
|
|
return Math.max(0, Math.round(needed - actual));
|
|
}),
|
|
);
|
|
expect(shortfalls, locale).toEqual([0, 0]);
|
|
}
|
|
});
|
|
|
|
test("applies RTL to the shell and modal navigation without changing action semantics", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
await page.goto("/");
|
|
await page.getByRole("combobox", { name: "언어" }).selectOption("ar-EG");
|
|
|
|
await expect(page.locator("html")).toHaveAttribute("lang", "ar-EG");
|
|
await expect(page.locator("html")).toHaveAttribute("dir", "rtl");
|
|
const trigger = page.getByRole("button", { name: "Menu" });
|
|
await trigger.click();
|
|
await expect(page.getByRole("dialog", { name: "Menu" })).toBeVisible();
|
|
await expect(page.getByRole("navigation", { name: "Primary navigation" }))
|
|
.toHaveCount(1);
|
|
await page.keyboard.press("Escape");
|
|
await expect(trigger).toBeFocused();
|
|
});
|