feat(i18n): localize inventory items UI

This commit is contained in:
2026-06-13 11:12:02 +02:00
parent 9f7d1b8ef8
commit 964b1648ca
12 changed files with 414 additions and 33 deletions
+59
View File
@@ -0,0 +1,59 @@
import { expect, type Page, test } from "@playwright/test"
async function setLocaleCookie(
page: Page,
locale: "en" | "es",
baseURL?: string,
) {
await page.context().addCookies([
{
name: "stock-manager-locale",
value: locale,
url: baseURL ?? "http://127.0.0.1:3100",
},
])
}
async function signInAsAdmin(page: Page, baseURL?: string) {
await setLocaleCookie(page, "en", baseURL)
await page.goto("/login")
await page.getByLabel("Username").fill("admin")
await page.getByLabel("Password").fill("admin-password")
await page.getByRole("button", { name: "Sign In" }).click()
await expect(page).toHaveURL("/")
}
test.describe("inventory items localization", () => {
test("renders item list and new form UI copy in Spanish", async ({
baseURL,
page,
}) => {
await signInAsAdmin(page, baseURL)
await setLocaleCookie(page, "es", baseURL)
await page.goto("/inventory/items")
await expect(page.locator("html")).toHaveAttribute("lang", "es")
await expect(page.getByRole("heading", { name: "Artículos" })).toBeVisible()
await expect(
page.getByRole("link", { name: /Agregar artículo/ }),
).toBeVisible()
await expect(page.getByText("No se encontraron artículos.")).toBeVisible()
await page.goto("/inventory/items/new")
await expect(
page.getByRole("heading", { name: "Nuevo artículo" }),
).toBeVisible()
await expect(page.getByLabel("Nombre")).toBeVisible()
await expect(page.getByPlaceholder("Nombre del artículo")).toBeVisible()
await expect(page.getByLabel("Categoría")).toBeVisible()
await expect(page.locator("select#categoryId")).toContainText(
"Selecciona una categoría",
)
await expect(page.getByLabel("Stock")).toBeVisible()
await expect(
page.getByRole("button", { name: "Crear artículo" }),
).toBeVisible()
})
})