import { describe, it, expect } from 'vitest' import { fr } from '@/i18n/fr' import { en } from '@/i18n/en' import { pickLocaleLabel } from '@/i18n/pickLocaleLabel' // The pdf.* keys left the app dicts with Step 6: the engine owns them // (@faunosteo/pdf defaultPdfLabels, parity tested there). const REQUIRED = [ 'severity.mild', 'severity.moderate', 'severity.severe', 'severity.aria', 'home.import.error_invalid_pdf', 'home.import.error_no_attachment', 'home.import.error_generic', 'home.import.error_attachment_stripped', 'home.import.archive_ok', 'home.import.complete', 'home.import.degraded', 'home.import.snapshot_reason.unsupported_envelope', 'home.import.snapshot_reason.schema', 'home.import.snapshot_reason.caps', 'home.import.snapshot_reason.integrity', 'home.import.snapshot_reason.sheet_mismatch', 'sheet.status.draft', 'sheet.loading', 'vertebra.range_note', ] const PLACEHOLDERS: Record = { 'home.import.error_incompatible_version': '{version}', 'home.import.migrated': '{count}', 'home.import.rebased': '{count}', 'home.import.snapshot_rejected': '{reason}', 'editor.draft_rebased': '{count}', 'vertebra.extend_to': '{max}', } describe.each([ ['fr', fr], ['en', en], ])('i18n keys (%s)', (_name, dict) => { it.each(REQUIRED)('has %s', (key) => { expect(dict[key]).toBeTruthy() }) it.each(Object.entries(PLACEHOLDERS))('%s carries %s', (key, ph) => { expect(dict[key]).toContain(ph) }) }) describe('pickLocaleLabel', () => { it('returns the active locale label', () => { expect(pickLocaleLabel('f', 'e', 'fr')).toBe('f') expect(pickLocaleLabel('f', 'e', 'en')).toBe('e') }) it('falls back to the other language when empty', () => { expect(pickLocaleLabel('', 'e', 'fr')).toBe('e') expect(pickLocaleLabel('f', '', 'en')).toBe('f') }) it('returns the fallback when both are empty', () => { expect(pickLocaleLabel('', '', 'fr', 'x')).toBe('x') expect(pickLocaleLabel(undefined, undefined, 'en', 'x')).toBe('x') }) })