From bb90295d263bb02b969d83e5ba8c67f5ba50e1ed Mon Sep 17 00:00:00 2001 From: DEV-bot Date: Mon, 2 Mar 2026 02:46:44 +0000 Subject: [PATCH] test(i18n): harden shared loader locale normalization coverage (#257) --- frontend/tests/lobby-loader.parity.test.ts | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/frontend/tests/lobby-loader.parity.test.ts b/frontend/tests/lobby-loader.parity.test.ts index c04d0a1..896c1a0 100644 --- a/frontend/tests/lobby-loader.parity.test.ts +++ b/frontend/tests/lobby-loader.parity.test.ts @@ -1,10 +1,36 @@ import { describe, expect, it } from 'vitest'; -import { collectLocaleParityIssues, LOBBY_I18N_CATALOG, SUPPORTED_LOCALES } from '../shared/i18n/lobby-loader'; +import { + collectLocaleParityIssues, + LOBBY_I18N_CATALOG, + normalizeLocale, + SUPPORTED_LOCALES, + translateCatalogPath, +} from '../shared/i18n/lobby-loader'; describe('shared lobby i18n loader parity', () => { it('keeps da/en translation parity in shared keyspace', () => { const issues = collectLocaleParityIssues(LOBBY_I18N_CATALOG, SUPPORTED_LOCALES); expect(issues).toEqual([]); }); + + it('normalizes browser-style locale tags to supported keyspace locales', () => { + expect(normalizeLocale('da-DK')).toBe('da'); + expect(normalizeLocale('en-US')).toBe('en'); + expect(normalizeLocale('fr-FR')).toBe('en'); + }); + + it('resolves shared frontend ui keys with fallback-safe behavior', () => { + expect( + translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record, 'host.start_round', 'da-DK'), + ).toBe('Start runde'); + + expect( + translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record, 'app.language_label', 'en-US'), + ).toBe('Language'); + + expect( + translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record, 'host.non_existing_key', 'da'), + ).toBe('host.non_existing_key'); + }); });