Files
stock-manager/tests/e2e/i18n-cookie.spec.ts
T

38 lines
1.2 KiB
TypeScript

import { expect, type Page, test } from "@playwright/test"
async function setSpanishLocaleCookie(page: Page, baseURL?: string) {
await page.context().addCookies([
{
name: "stock-manager-locale",
value: "es",
url: baseURL ?? "http://127.0.0.1:3100",
},
])
}
test.describe("i18n locale cookie", () => {
test("renders Spanish pilot copy on login and dashboard home", async ({
baseURL,
page,
}) => {
await setSpanishLocaleCookie(page, baseURL)
await page.goto("/login")
await expect(
page.getByRole("heading", { name: "Iniciar sesión" }),
).toBeVisible()
await page.getByLabel("Usuario").fill("admin")
await page.getByLabel("Contraseña").fill("admin-password")
await page.getByRole("button", { name: "Iniciar sesión" }).click()
await expect(page).toHaveURL("/")
await expect(
page.getByRole("heading", { name: "Panel de control" }),
).toBeVisible()
await expect(page.locator("html")).toHaveAttribute("lang", "es")
await expect(page.getByText("Total de artículos")).toBeVisible()
await expect(page.getByText("Total de activos")).toBeVisible()
await expect(page.getByText("Total de destinatarios")).toBeVisible()
})
})