feat(i18n): localize admin users UI surfaces

This commit is contained in:
2026-06-15 16:01:19 +02:00
parent 0cbbe60299
commit 73552dbb05
13 changed files with 593 additions and 58 deletions
+35
View File
@@ -0,0 +1,35 @@
import { describe, expect, it } from "vitest"
import { formatUserRole } from "@/app/(dashboard)/admin/users/_components/user.copy"
describe("user copy helpers", () => {
const roleCopy = {
ADMIN: "Administrador",
MANAGER: "Gerente",
STAFF: "Personal",
VIEWER: "Visor",
}
const fallbackCopy = {
unknownRole: "Rol desconocido",
}
it("formats known role values with localized display labels", () => {
expect(formatUserRole("ADMIN", roleCopy, fallbackCopy)).toBe(
"Administrador",
)
expect(formatUserRole("STAFF", roleCopy, fallbackCopy)).toBe("Personal")
})
it("falls back for unknown role values without exposing the raw enum value", () => {
expect(formatUserRole("UNKNOWN_ROLE", roleCopy, fallbackCopy)).toBe(
"Rol desconocido",
)
})
it("falls back for null role values", () => {
expect(
formatUserRole(null as unknown as string, roleCopy, fallbackCopy),
).toBe("Rol desconocido")
})
})