who_need_help/e2e/tests/localization.spec.ts

88 lines
3.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { expect, test } from "@playwright/test";
import {
gotoLiveView,
newIsolatedContext,
projectEmail,
registerAndConfirm,
waitForMapReady,
} from "./helpers";
test("public language selection persists across pages", async ({ browser }) => {
const context = await newIsolatedContext(browser);
const page = await context.newPage();
await page.goto("/?locale=ru");
await expect(page.locator("html")).toHaveAttribute("lang", "ru");
await expect(
page.getByRole("heading", { name: "Нужна помощь рядом? Обратитесь к сообществу." }),
).toBeVisible();
await page.goto("/safety");
await expect(page.getByRole("heading", { name: "Правила безопасности" })).toBeVisible();
await page.goto("/privacy");
await expect(page.getByRole("heading", { name: "Политика конфиденциальности" })).toBeVisible();
await expect(page.getByRole("heading", { name: "Какие данные мы обрабатываем" })).toBeVisible();
await page.goto("/terms");
await expect(page.getByRole("heading", { name: "Условия использования" })).toBeVisible();
await expect(page.getByRole("heading", { name: "Допустимое использование" })).toBeVisible();
await page.goto("/?locale=uk");
await expect(page.locator("html")).toHaveAttribute("lang", "uk");
await expect(
page.getByRole("heading", { name: "Потрібна допомога поруч? Зверніться до спільноти." }),
).toBeVisible();
await page.goto("/privacy");
await expect(page.getByRole("heading", { name: "Політика конфіденційності" })).toBeVisible();
await expect(page.getByRole("heading", { name: "Які дані ми обробляємо" })).toBeVisible();
await page.goto("/terms");
await expect(page.getByRole("heading", { name: "Умови використання" })).toBeVisible();
await expect(page.getByRole("heading", { name: "Допустиме використання" })).toBeVisible();
await context.close();
});
test("authenticated LiveView uses the selected browser language", async ({
browser,
request,
}, testInfo) => {
const user = await registerAndConfirm(
browser,
request,
projectEmail("localization", testInfo.project.name),
"E2E Localization",
);
await user.page.goto("/?locale=uk");
await gotoLiveView(user.page, "/requests");
await expect(user.page.locator("html")).toHaveAttribute("lang", "uk");
await expect(user.page.getByRole("heading", { name: "Хто потребує допомоги?" })).toBeVisible();
await expect(user.page.getByRole("link", { name: "Створити термінову заявку" })).toBeVisible();
await gotoLiveView(user.page, "/notifications");
await expect(user.page.getByRole("heading", { name: "Сповіщення" })).toBeVisible();
await expect(user.page.getByText("0 непрочитаних сповіщень")).toBeVisible();
await expect(
user.page.getByText(
"Тут з’являться оновлення заявок, повідомлень і сповіщень поблизу.",
),
).toBeVisible();
await gotoLiveView(user.page, "/activities");
await waitForMapReady(user.page);
await expect(user.page.getByRole("region", { name: "Карта" })).toBeVisible();
if ((await user.page.locator("#activity-map canvas").count()) > 0) {
await expect(user.page.getByRole("button", { name: "Збільшити масштаб" })).toBeVisible();
await expect(
user.page.getByRole("button", { name: "Знайти моє місцезнаходження" }),
).toBeVisible();
}
await user.context.close();
});