BangSo/apps/web/e2e/localization.spec.ts

26 lines
1.0 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { captureScreenshot } from "./helpers";
test("renders the sign-in screen in Traditional Chinese with Huninn", async ({
page,
}, testInfo) => {
await page.addInitScript(() => {
localStorage.setItem("rakazo.uiLocale", "zh-TW");
});
await page.route("**/api/auth/get-session", (route) =>
route.fulfill({ status: 200, contentType: "application/json", body: "null" }),
);
await page.goto("/sign-in");
await expect(page.getByRole("heading", { name: "登入 BangSo Bot" })).toBeVisible();
await expect(page.getByPlaceholder("你的電子郵件地址")).toBeVisible();
await expect(page.getByRole("button", { name: "繼續使用電子郵件" })).toBeVisible();
await expect(page.locator("html")).toHaveAttribute("lang", "zh-TW");
await expect
.poll(() => page.locator("body").evaluate((element) => getComputedStyle(element).fontFamily))
.toContain("Huninn");
await captureScreenshot(page, testInfo, "traditional-chinese-sign-in");
});