Files
SnapOtter/tests/e2e-landing/i18n-switcher.spec.ts
T
SnapOtterandGitHub 00b651c9f8 feat(i18n): 21-language pipeline, landing/docs/API wiring, landing+API translations
Shared Claude Code translation pipeline (scripts/i18n, no API key) plus Astro/VitePress/Scalar i18n wiring. Landing and API reference translated into all 20 languages; docs i18n wiring + English source anchors. The translated docs markdown (apps/docs/<locale>/**, 3,620 files) follows in a companion PR because it exceeds GitHub's per-PR CI file limit.
2026-07-11 13:01:55 +08:00

28 lines
1.2 KiB
TypeScript

// tests/e2e-landing/i18n-switcher.spec.ts
import { expect, test } from "@playwright/test";
test.describe("landing language switcher", () => {
test("opens and lists native language names", async ({ page }) => {
await page.goto("/faq");
await page.locator("[data-switcher-button]").click();
const menu = page.locator("[data-switcher-menu]");
await expect(menu).toBeVisible();
await expect(menu.locator('a[data-locale="de"]')).toHaveText("Deutsch");
await expect(menu.locator('a[data-locale="ar"]')).toHaveText("العربية");
});
test("navigates to the chosen locale and persists it to localStorage", async ({ page }) => {
await page.goto("/faq");
await page.locator("[data-switcher-button]").click();
await page.locator('[data-switcher-menu] a[data-locale="de"]').click();
await expect(page).toHaveURL(/\/de\/faq\/?$/);
const stored = await page.evaluate(() => localStorage.getItem("snapotter:locale"));
expect(stored).toBe("de");
});
test("switcher shows the active locale label on a prefixed page", async ({ page }) => {
await page.goto("/de/faq");
await expect(page.locator("[data-switcher-button]")).toContainText("Deutsch");
});
});