feat(i18n): localize inventory assets UI

This commit is contained in:
2026-06-13 17:07:51 +02:00
parent c67e86c91b
commit 3d6b13dc1c
10 changed files with 367 additions and 38 deletions
+72
View File
@@ -0,0 +1,72 @@
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 assets localization", () => {
test("renders asset list and new form UI/status copy in Spanish", async ({
baseURL,
page,
}) => {
await signInAsAdmin(page, baseURL)
await setLocaleCookie(page, "es", baseURL)
await page.goto("/inventory/assets")
await expect(page.locator("html")).toHaveAttribute("lang", "es")
await expect(page.getByRole("heading", { name: "Activos" })).toBeVisible()
await expect(
page.getByRole("link", { name: /Agregar activo/ }),
).toBeVisible()
await expect(page.getByText("No se encontraron activos.")).toBeVisible()
await page.goto("/inventory/assets/new")
await expect(
page.getByRole("heading", { name: "Nuevo activo" }),
).toBeVisible()
await expect(page.getByLabel("Artículo")).toBeVisible()
await expect(page.locator("select#itemId")).toContainText(
"Selecciona un artículo",
)
await expect(page.getByLabel("Número de serie")).toBeVisible()
await expect(page.getByPlaceholder("Número de serie")).toBeVisible()
await expect(page.getByLabel("Remito")).toBeVisible()
await expect(page.getByPlaceholder("Remito")).toBeVisible()
await expect(page.getByLabel("Estado")).toBeVisible()
await expect(page.locator("select#status")).toContainText("Disponible")
await expect(page.locator("select#status")).toContainText("Asignado")
await expect(page.locator("option[value='AVAILABLE']")).toHaveText(
"Disponible",
)
await expect(page.locator("option[value='ASSIGNED']")).toHaveText(
"Asignado",
)
await expect(
page.getByRole("button", { name: "Crear activo" }),
).toBeVisible()
await expect(
page.getByRole("button", { name: /Eliminar activo/i }),
).toHaveCount(0)
})
})