Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

24.9 KB
Raw Blame
import { afterEach, describe, expect, it } from 'vitest';
import {
  ALERTS_OVERVIEW_ALLOWED_IDENTICAL_TRANSLATIONS,
  ALERTS_OVERVIEW_NON_TRANSLATABLE_TOKENS,
  COMMERCIAL_PRICING_HANDOFF_ALLOWED_IDENTICAL_TRANSLATIONS,
  COMMERCIAL_PRICING_HANDOFF_NON_TRANSLATABLE_TOKENS,
  DEFAULT_LOCALE,
  FIRST_SESSION_MONITORING_ALLOWED_IDENTICAL_TRANSLATIONS,
  FIRST_SESSION_MONITORING_NON_TRANSLATABLE_TOKENS,
  FIRST_LOCALIZATION_LOCALES,
  LOCALIZATION_FOUNDATION,
  LOCALIZED_ALERTS_OVERVIEW_JOURNEY_KEYS,
  LOCALIZED_COMMERCIAL_PRICING_HANDOFF_KEYS,
  LOCALIZED_FIRST_SESSION_MONITORING_JOURNEY_KEYS,
  LOCALIZED_SETTINGS_GENERAL_JOURNEY_KEYS,
  NEVER_TRANSLATE_COPY_RULES,
  NEXT_LOCALIZATION_LOCALES,
  SETTINGS_GENERAL_ALLOWED_IDENTICAL_TRANSLATIONS,
  SETTINGS_GENERAL_NON_TRANSLATABLE_TOKENS,
  SUPPORTED_LOCALE_REGISTRY,
  SUPPORTED_LOCALES,
  detectBrowserLocale,
  getActiveLocale,
  getInitialLocalePreference,
  getLocaleFallbackChain,
  getStoredLocalePreference,
  normalizeLocale,
  setActiveLocale,
  setLocalePreference,
  t,
  type I18nMessageKey,
} from '@/i18n';
import { I18N_MESSAGES } from '@/i18n/catalogs';
import { STORAGE_KEYS } from '@/utils/localStorage';

describe('i18n foundation', () => {
  afterEach(() => {
    localStorage.removeItem(STORAGE_KEYS.LOCALE_PREFERENCE);
    setActiveLocale(DEFAULT_LOCALE);
  });

  it('normalizes supported locales and regional aliases', () => {
    expect(normalizeLocale('de-DE')).toBe('de');
    expect(normalizeLocale('es_MX')).toBe('es');
    expect(normalizeLocale('es_MX_traditional')).toBe('es');
    expect(normalizeLocale('fr-FR')).toBe('fr');
    expect(normalizeLocale('fr_CA')).toBe('fr');
    expect(normalizeLocale('pt-BR')).toBe('en');
    expect(normalizeLocale(undefined)).toBe('en');
  });

  it('sets and reads the active locale through the normalized locale contract', () => {
    expect(setActiveLocale('es-ES')).toBe('es');
    expect(getActiveLocale()).toBe('es');
    expect(t('settings.shell.navigationTitle')).toBe('Ajustes');
  });

  it('describes first-source agent installation and optional coverage accurately in each locale', () => {
    const expected = {
      en: {
        installer: 'Run the installer',
        supported: 'only where supported',
        standalone: 'standalone host',
        availability: 'where available',
      },
      de: {
        installer: 'Fuehren Sie den Installer',
        supported: 'nur verfuegbar',
        standalone: 'eigenstaendigen Rechner',
        availability: 'sofern verfuegbar',
      },
      es: {
        installer: 'Ejecuta el instalador',
        supported: 'dependen de la compatibilidad',
        standalone: 'equipo independiente',
        availability: 'cuando estén disponibles',
      },
      fr: {
        installer: "Exécutez l'installateur",
        supported: 'que là où ils sont pris en charge',
        standalone: 'hôte autonome',
        availability: 'si elles sont disponibles',
      },
    } as const;

    for (const locale of ['en', 'de', 'es', 'fr'] as const) {
      const messages = I18N_MESSAGES[locale];
      expect(messages['setup.completion.sourceOptions.agent.description']).toContain(
        expected[locale].installer,
      );
      expect(messages['setup.completion.sourceOptions.agent.description']).toContain(
        expected[locale].supported,
      );
      expect(messages['setup.completion.nextStep.detail.empty']).toContain(
        expected[locale].standalone,
      );
      expect(messages['setup.completion.nextStep.summary.empty']).toContain('Agent');
      expect(messages['setup.completion.nextStep.detail.api']).toContain(
        expected[locale].availability,
      );
      expect(messages['setup.completion.sourceOptions.both.description']).toContain(
        expected[locale].availability,
      );
    }
  });

  it('detects initial locale from stored preference before browser language', () => {
    localStorage.setItem(STORAGE_KEYS.LOCALE_PREFERENCE, 'es-MX');

    expect(getStoredLocalePreference(localStorage)).toBe('es');
    expect(
      getInitialLocalePreference({
        storage: localStorage,
        browserLocales: ['de-DE'],
      }),
    ).toBe('es');
  });

  it('uses the first supported browser locale when no preference is stored', () => {
    localStorage.removeItem(STORAGE_KEYS.LOCALE_PREFERENCE);

    expect(detectBrowserLocale(['pt-BR', 'es-ES', 'de-DE'])).toBe('es');
    expect(detectBrowserLocale(['ja-JP', 'fr-CA', 'de-DE'])).toBe('fr');
    expect(
      getInitialLocalePreference({
        storage: localStorage,
        browserLocales: ['pt-BR', 'de-AT'],
      }),
    ).toBe('de');
  });

  it('persists explicit locale preferences separately from in-memory locale changes', () => {
    expect(setLocalePreference('de-DE', localStorage)).toBe('de');
    expect(getActiveLocale()).toBe('de');
    expect(localStorage.getItem(STORAGE_KEYS.LOCALE_PREFERENCE)).toBe('de');

    expect(setActiveLocale('es')).toBe('es');
    expect(localStorage.getItem(STORAGE_KEYS.LOCALE_PREFERENCE)).toBe('de');
  });

  it('falls back to the English catalog for unsupported locales and interpolates params', () => {
    expect(getLocaleFallbackChain('de-DE')).toEqual(['de', 'en']);
    expect(getLocaleFallbackChain('fr-FR')).toEqual(['fr', 'en']);
    expect(getLocaleFallbackChain('pt-BR')).toEqual(['en']);
    expect(t('settings.shell.searchEmpty', { query: 'alerts' }, 'pt-BR')).toBe(
      'No settings found for "alerts"',
    );
  });

  it('keeps every supported locale complete against the English key set', () => {
    const englishKeys = Object.keys(I18N_MESSAGES.en).sort() as I18nMessageKey[];

    for (const locale of SUPPORTED_LOCALES) {
      expect(Object.keys(I18N_MESSAGES[locale]).sort()).toEqual(englishKeys);
    }
  });

  it('localizes the alert snooze lifecycle across every supported locale', () => {
    expect(t('alerts.overview.action.snooze', undefined, 'en')).toBe('Snooze');
    expect(t('alerts.overview.action.snooze', undefined, 'de')).toBe('Zurueckstellen');
    expect(t('alerts.overview.action.snooze', undefined, 'es')).toBe('Posponer');
    expect(t('alerts.overview.action.resume', undefined, 'de')).toBe('Fortsetzen');
    expect(t('alerts.overview.action.resume', undefined, 'es')).toBe('Reanudar');
    expect(t('alerts.overview.action.snooze', undefined, 'fr')).toBe('Reporter');
    expect(t('alerts.overview.action.resume', undefined, 'fr')).toBe('Reprendre');
    for (const locale of SUPPORTED_LOCALES) {
      expect(t('alerts.overview.snooze.description', undefined, locale)).toBeTruthy();
      expect(t('alerts.timeline.event.alertSnoozed', undefined, locale)).toBeTruthy();
      expect(t('alerts.timeline.event.alertUnsnoozed', undefined, locale)).toBeTruthy();
    }
  });

  it('localizes the alert overview summary, row disclosure and paused-delivery banner', () => {
    expect(t('alerts.overview.summary.critical', { count: 2 }, 'en')).toBe('2 critical');
    expect(t('alerts.overview.summary.warning', { count: 3 }, 'de')).toBe('3 Warnung');
    expect(t('alerts.overview.action.moreActions', undefined, 'es')).toBe('Más');
    expect(t('alerts.delivery.paused.title', undefined, 'de')).toBe(
      'Benachrichtigungen sind pausiert',
    );
    const pausedKeys = [
      'alerts.delivery.paused.title',
      'alerts.delivery.paused.action',
      'alerts.delivery.paused.setupLink',
      'alerts.delivery.paused.reason.detectionOff',
      'alerts.delivery.paused.reason.snoozed',
      'alerts.delivery.paused.reason.notActivated',
      'alerts.delivery.paused.consequence.destinations',
      'alerts.delivery.paused.consequence.destinationsDetectionOff',
      'alerts.delivery.paused.consequence.overview',
      'alerts.delivery.paused.consequence.overviewDetectionOff',
      'alerts.overview.action.moreActions',
      'alerts.overview.action.lessActions',
    ] as const;
    for (const key of pausedKeys) {
      const english = t(key, undefined, 'en');
      for (const locale of SUPPORTED_LOCALES) {
        expect(t(key, undefined, locale)).toBeTruthy();
        if (locale !== 'en') expect(t(key, undefined, locale)).not.toBe(english);
      }
    }
  });

  it('localizes alert group correlation labels across every supported locale', () => {
    expect(t('alerts.overview.group.linkedSignal', { count: 1 }, 'en')).toBe('+1 linked signal');
    expect(t('alerts.overview.group.linkedSignal', { count: 1 }, 'de')).toBe(
      '+1 verknuepftes Signal',
    );
    expect(t('alerts.overview.group.linkedSignal', { count: 1 }, 'es')).toBe('+1 senal vinculada');
    expect(t('alerts.overview.group.linkedSignal', { count: 1 }, 'fr')).toBe('+1 signal lié');
    for (const locale of SUPPORTED_LOCALES) {
      expect(t('alerts.overview.group.linkedSignals', { count: 2 }, locale)).toBeTruthy();
      expect(t('alerts.overview.group.acknowledge', { count: 3 }, locale)).toBeTruthy();
      expect(t('alerts.overview.synthesis.title.supported', undefined, locale)).toBeTruthy();
      expect(t('alerts.overview.synthesis.title.observationSet', undefined, locale)).toBeTruthy();
      expect(
        t('alerts.overview.synthesis.failure.applicationResponse', undefined, locale),
      ).toBeTruthy();
      expect(t('alerts.overview.synthesis.review', undefined, locale)).toBeTruthy();
    }
  });

  it('captures the first and next localization waves without enabling unsupported locales', () => {
    expect(FIRST_LOCALIZATION_LOCALES).toEqual(['de', 'es', 'fr']);
    expect(NEXT_LOCALIZATION_LOCALES).toEqual(['pt-BR', 'ja', 'zh-Hans', 'ko']);
    expect(SUPPORTED_LOCALES).toEqual(['en', 'de', 'es', 'fr']);
    expect(SUPPORTED_LOCALE_REGISTRY.fr).toMatchObject({
      label: 'Français',
      englishLabel: 'French',
      fallbackLocale: 'en',
      rolloutStage: 'first-wave',
    });
    expect(SUPPORTED_LOCALE_REGISTRY.de).toMatchObject({
      label: 'Deutsch',
      englishLabel: 'German',
      fallbackLocale: 'en',
      rolloutStage: 'first-wave',
    });
  });

  it('documents the frontend localization architecture and non-translation boundaries', () => {
    expect(LOCALIZATION_FOUNDATION).toMatchObject({
      ownerLayer: 'frontend-modern/src/i18n',
      defaultLocale: 'en',
      firstWaveLocales: ['de', 'es', 'fr'],
    });
    expect(NEVER_TRANSLATE_COPY_RULES.join(' ')).toContain('environment variable names');
    expect(NEVER_TRANSLATE_COPY_RULES.join(' ')).toContain('Resource names');
    expect(SETTINGS_GENERAL_NON_TRANSLATABLE_TOKENS).toEqual(
      expect.arrayContaining([
        'Pulse',
        'Proxmox VE',
        'Docker / Podman',
        'API',
        'CPU',
        'IP',
        'JSON',
        'PULSE_TELEMETRY',
        'PVE_POLLING_INTERVAL',
        'PULSE_DISABLE_DOCKER_UPDATE_ACTIONS',
        '"Update"',
      ]),
    );
    expect(FIRST_SESSION_MONITORING_NON_TRANSLATABLE_TOKENS).toEqual(
      expect.arrayContaining([
        'Pulse',
        'Pulse Agent',
        'API',
        'URL',
        'Docker',
        'Kubernetes',
        'Proxmox',
        'TrueNAS',
        'VMware',
        'PBS',
        'PMG',
        '.bootstrap_token',
        'sudo pulse bootstrap-token',
        'docker exec',
        'pct exec',
      ]),
    );
    expect(ALERTS_OVERVIEW_NON_TRANSLATABLE_TOKENS).toEqual(
      expect.arrayContaining([
        'Pulse',
        'Pulse Assistant',
        'Pulse Alerts',
        'Pro',
        'API',
        'alertIdentifier',
        'alertType',
        'resourceId',
        'resourceName',
        'node',
        'systemctl',
      ]),
    );
    expect(COMMERCIAL_PRICING_HANDOFF_NON_TRANSLATABLE_TOKENS).toEqual(
      expect.arrayContaining(['Pulse', 'Pulse Account']),
    );
  });

  it('requires explicit first-wave translations for the migrated settings general journey', () => {
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      const allowedIdenticalKeys: ReadonlySet<I18nMessageKey> = new Set(
        (SETTINGS_GENERAL_ALLOWED_IDENTICAL_TRANSLATIONS[locale] ??
          []) as readonly I18nMessageKey[],
      );
      for (const key of LOCALIZED_SETTINGS_GENERAL_JOURNEY_KEYS) {
        expect(I18N_MESSAGES[locale][key], `${locale}:${key}`).toBeTruthy();
        if (!allowedIdenticalKeys.has(key)) {
          expect(I18N_MESSAGES[locale][key], `${locale}:${key}`).not.toBe(I18N_MESSAGES.en[key]);
        }
      }
    }
  });

  it('keeps machine-facing identifiers unchanged in first-wave settings general catalog copy', () => {
    const telemetryPrivacyTerms = {
      de: ['Lebenszyklus', 'Ergebniszahlen', 'URLs', 'Pfade', 'Browser-Ereignisse'],
      es: ['ciclo de vida', 'resultados', 'URLs', 'rutas', 'eventos del navegador'],
      fr: ['cycle de vie', 'résultats', 'URL', 'chemins', 'événements bruts du navigateur'],
    } as const;

    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      const telemetryDescription = I18N_MESSAGES[locale]['settings.general.telemetry.description'];

      expect(I18N_MESSAGES[locale]['settings.general.language.description']).toContain('API');
      expect(telemetryDescription).toContain('Pulse');
      expect(telemetryDescription).toContain('IP');
      expect(telemetryDescription).toContain('90');
      expect(telemetryDescription).not.toMatch(/anonymous/i);
      for (const term of telemetryPrivacyTerms[locale]) {
        expect(telemetryDescription, `${locale}:${term}`).toContain(term);
      }
      expect(I18N_MESSAGES[locale]['settings.general.telemetry.copyJson']).toContain('JSON');
      expect(
        t(
          'settings.general.monitoringCadence.envLocked',
          {
            envVar: 'PVE_POLLING_INTERVAL',
          },
          locale,
        ),
      ).toContain('PVE_POLLING_INTERVAL');
    }
  });

  it('requires explicit first-wave translations for the migrated first-session monitoring journey', () => {
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      const allowedIdenticalKeys: ReadonlySet<I18nMessageKey> = new Set([
        ...((SETTINGS_GENERAL_ALLOWED_IDENTICAL_TRANSLATIONS[locale] ??
          []) as readonly I18nMessageKey[]),
        ...((FIRST_SESSION_MONITORING_ALLOWED_IDENTICAL_TRANSLATIONS[locale] ??
          []) as readonly I18nMessageKey[]),
      ]);
      for (const key of LOCALIZED_FIRST_SESSION_MONITORING_JOURNEY_KEYS) {
        expect(I18N_MESSAGES[locale][key], `${locale}:${key}`).toBeTruthy();
        if (!allowedIdenticalKeys.has(key)) {
          expect(I18N_MESSAGES[locale][key], `${locale}:${key}`).not.toBe(I18N_MESSAGES.en[key]);
        }
      }
    }
  });

  it('keeps the setup completion Pro activation pointer in the localized first-session journey', () => {
    expect(LOCALIZED_FIRST_SESSION_MONITORING_JOURNEY_KEYS).toEqual(
      expect.arrayContaining([
        'setup.completion.proActivation.action',
        'setup.completion.proActivation.description',
        'setup.completion.proActivation.title',
      ]),
    );
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      expect(I18N_MESSAGES[locale]['setup.completion.proActivation.title']).toContain('Pulse Pro');
      expect(I18N_MESSAGES[locale]['setup.completion.proActivation.description']).toContain(
        'Pulse Pro',
      );
    }
  });

  it('keeps machine-facing identifiers unchanged in first-session monitoring catalog copy', () => {
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      const telemetryNotice = I18N_MESSAGES[locale]['setup.welcome.telemetryNotice.description'];
      const deploymentChoice = I18N_MESSAGES[locale]['setup.welcome.deploymentHint.choose'];
      const genericTokenHelp = I18N_MESSAGES[locale]['setup.welcome.tokenHelp.generic'];

      const setupTelemetryChoice = I18N_MESSAGES[locale]['setup.security.telemetry.description'];

      expect(telemetryNotice).toContain('Pulse');
      expect(telemetryNotice).toContain('IP');
      expect(telemetryNotice).not.toContain('PULSE_TELEMETRY');
      expect(telemetryNotice).not.toMatch(/anonymous/i);
      expect(setupTelemetryChoice).toContain('IP');
      expect(setupTelemetryChoice).not.toMatch(/anonymous/i);
      // Both setup surfaces say what the summary is for before what it holds,
      // and neither tells the reader how to turn it off: the toggle is the
      // control, and the how-to-disable copy lives in Full details and Settings.
      const purposeWording = { de: 'Prioritaet', es: 'prioridad', fr: 'priorité' } as const;
      expect(setupTelemetryChoice).toContain(purposeWording[locale]);
      expect(telemetryNotice).not.toMatch(/ausschalten|desactivarl|désactiver/i);
      // Every locale states what the summary is never used for, because
      // "sold to someone" is the fear that turns a default-on switch off.
      const neverSold = { de: 'verkauft', es: 'se vende', fr: 'jamais vendu' } as const;
      expect(telemetryNotice).toContain(neverSold[locale]);
      expect(setupTelemetryChoice).toContain(neverSold[locale]);
      expect(I18N_MESSAGES[locale]['settings.general.telemetry.description']).toContain(
        neverSold[locale],
      );
      expect(deploymentChoice).toContain('Pulse');
      expect(deploymentChoice).not.toContain('Docker');
      expect(deploymentChoice).not.toContain('LXC');
      expect(genericTokenHelp).toContain('Pulse');
      expect(genericTokenHelp).toContain('API');
      expect(I18N_MESSAGES[locale]['setup.welcome.deploymentHint.dockerUnnamed']).toContain(
        '<pulse-container>',
      );
      expect(I18N_MESSAGES[locale]['setup.welcome.deploymentHint.lxc']).toContain('Proxmox');
      expect(I18N_MESSAGES[locale]['setup.welcome.error.snapshotPaste']).toContain(
        '.bootstrap_token',
      );
      expect(I18N_MESSAGES[locale]['setup.completion.download.content']).toContain('URL:');
      expect(
        I18N_MESSAGES[locale]['setup.completion.sourceOptions.platformApi.description'],
      ).toContain('Proxmox');
      expect(
        I18N_MESSAGES[locale]['setup.completion.sourceOptions.platformApi.description'],
      ).toContain('TrueNAS');
      expect(I18N_MESSAGES[locale]['setup.completion.sourceOptions.agent.description']).toContain(
        'Docker',
      );
      expect(I18N_MESSAGES[locale]['setup.security.nextScreen.itemApiToken']).toContain('API');
    }
  });

  it('requires explicit first-wave translations for the migrated alerts overview journey', () => {
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      const allowedIdenticalKeys: ReadonlySet<I18nMessageKey> = new Set([
        ...((SETTINGS_GENERAL_ALLOWED_IDENTICAL_TRANSLATIONS[locale] ??
          []) as readonly I18nMessageKey[]),
        ...((FIRST_SESSION_MONITORING_ALLOWED_IDENTICAL_TRANSLATIONS[locale] ??
          []) as readonly I18nMessageKey[]),
        ...((ALERTS_OVERVIEW_ALLOWED_IDENTICAL_TRANSLATIONS[locale] ??
          []) as readonly I18nMessageKey[]),
      ]);
      for (const key of LOCALIZED_ALERTS_OVERVIEW_JOURNEY_KEYS) {
        expect(I18N_MESSAGES[locale][key], `${locale}:${key}`).toBeTruthy();
        if (!allowedIdenticalKeys.has(key)) {
          expect(I18N_MESSAGES[locale][key], `${locale}:${key}`).not.toBe(I18N_MESSAGES.en[key]);
        }
      }
    }
  });

  it('keeps unconfirmed alert truth distinct from a localized all-clear', () => {
    for (const locale of SUPPORTED_LOCALES) {
      const pendingTitle = I18N_MESSAGES[locale]['alerts.overview.hydration.pending.title'];
      const unavailableTitle = I18N_MESSAGES[locale]['alerts.overview.hydration.unavailable.title'];
      const retry = I18N_MESSAGES[locale]['alerts.overview.hydration.retry'];

      expect(pendingTitle).toBeTruthy();
      expect(unavailableTitle).toBeTruthy();
      expect(retry).toBeTruthy();
      expect(pendingTitle).not.toBe(I18N_MESSAGES[locale]['alerts.overview.empty.title']);
      expect(unavailableTitle).not.toBe(I18N_MESSAGES[locale]['alerts.overview.empty.title']);
      expect(I18N_MESSAGES[locale]['alerts.overview.hydration.pending.description']).toContain(
        'Pulse',
      );
      expect(I18N_MESSAGES[locale]['alerts.overview.hydration.unavailable.description']).toContain(
        'Pulse',
      );
    }
  });

  // Switching delivery off stores the same pending state as a fresh install,
  // so the paused banner may say delivery is off but never that it was never on.
  it('describes pending notification delivery as off, not as never turned on', () => {
    expect(I18N_MESSAGES.en['alerts.delivery.paused.reason.notActivated']).toBe(
      'Notification delivery is turned off.',
    );
    for (const locale of ['en', 'de', 'es'] as const) {
      expect(I18N_MESSAGES[locale]['alerts.delivery.paused.reason.notActivated']).not.toMatch(
        /yet|noch nicht|aún no/i,
      );
    }
  });

  it('keeps external notification delivery distinct from alert detection', () => {
    // The delivery switch has one name in every state, so an off switch is
    // never labelled with a word that reads as its opposite.
    expect(I18N_MESSAGES.en['alerts.activation.switchLabel']).toBe('Send notifications');
    for (const locale of ['en', 'de', 'es', 'fr'] as const) {
      expect(I18N_MESSAGES[locale]['alerts.activation.switchLabel']).not.toMatch(
        /paus|enabled|aktiviert|activad|activé/i,
      );
    }
    expect(I18N_MESSAGES.en['alerts.activation.toast.deactivated']).toContain(
      'keep detecting and showing active alerts',
    );

    expect(I18N_MESSAGES.de['alerts.activation.switchLabel']).toBe('Benachrichtigungen senden');
    expect(I18N_MESSAGES.de['alerts.activation.toast.deactivated']).toContain('weiterhin');

    expect(I18N_MESSAGES.es['alerts.activation.switchLabel']).toBe('Enviar notificaciones');
    expect(I18N_MESSAGES.es['alerts.activation.toast.deactivated']).toContain('seguira');

    expect(I18N_MESSAGES.fr['alerts.activation.switchLabel']).toBe('Envoyer les notifications');
    expect(I18N_MESSAGES.fr['alerts.activation.toast.deactivated']).toContain('continuera');
  });

  // The Schedule page sets how alerts are delivered; maintenance windows are a
  // separate per-resource feature, so no locale may title it as maintenance.
  it('titles the alerts Schedule page for delivery, not maintenance', () => {
    expect(I18N_MESSAGES.en['alerts.page.schedule.title']).toBe('Delivery Schedule');
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      expect(I18N_MESSAGES[locale]['alerts.page.schedule.title']).not.toMatch(
        /maintenance|wartung|mantenimiento|entretien/i,
      );
    }
  });

  // The setup message names the environment variable an operator must remove;
  // a translated name would point at a variable that does not exist.
  it('keeps PULSE_TELEMETRY untranslated in the setup lock message', () => {
    for (const locale of ['en', ...FIRST_LOCALIZATION_LOCALES] as const) {
      // Removing the variable restores the default (on), so the copy must
      // name the value that turns statistics off.
      expect(I18N_MESSAGES[locale]['setup.security.error.telemetryLockedOn']).toContain(
        'PULSE_TELEMETRY=false',
      );
    }
  });

  it('keeps Patrol and placeholders intact in alert investigate copy', () => {
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      expect(I18N_MESSAGES[locale]['alerts.investigate.label']).toContain('Patrol');
      expect(I18N_MESSAGES[locale]['alerts.investigate.title']).toContain('Patrol');
      // History rows name each Investigate button after its alert, resource
      // and start time; every locale must keep all three placeholders.
      for (const key of [
        'alerts.investigate.iconLabel',
        'alerts.investigate.iconLabelAt',
      ] as const) {
        expect(I18N_MESSAGES[locale][key]).toContain('Patrol');
        expect(I18N_MESSAGES[locale][key]).toContain('{alertType}');
        expect(I18N_MESSAGES[locale][key]).toContain('{resourceName}');
      }
      expect(I18N_MESSAGES[locale]['alerts.investigate.iconLabelAt']).toContain('{startedAt}');
      expect(t('alerts.investigate.triggered', { resourceName: 'db-vm-01' }, locale)).toContain(
        'db-vm-01',
      );
    }
  });

  it('requires explicit first-wave translations for the migrated commercial pricing handoff', () => {
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      const allowedIdenticalKeys: ReadonlySet<I18nMessageKey> = new Set([
        ...((COMMERCIAL_PRICING_HANDOFF_ALLOWED_IDENTICAL_TRANSLATIONS[locale] ??
          []) as readonly I18nMessageKey[]),
      ]);
      for (const key of LOCALIZED_COMMERCIAL_PRICING_HANDOFF_KEYS) {
        expect(I18N_MESSAGES[locale][key], `${locale}:${key}`).toBeTruthy();
        if (!allowedIdenticalKeys.has(key)) {
          expect(I18N_MESSAGES[locale][key], `${locale}:${key}`).not.toBe(I18N_MESSAGES.en[key]);
        }
      }
    }
  });

  it('keeps Pulse Account untranslated in commercial pricing handoff copy', () => {
    for (const locale of FIRST_LOCALIZATION_LOCALES) {
      expect(I18N_MESSAGES[locale]['pricing.handoff.title.pulseAccount']).toContain(
        'Pulse Account',
      );
      expect(I18N_MESSAGES[locale]['pricing.handoff.link.pulseAccount']).toContain('Pulse Account');
    }
  });

  it('localizes setup preview copy action names in every supported catalog', () => {
    for (const locale of SUPPORTED_LOCALES) {
      expect(I18N_MESSAGES[locale]['setup.completion.action.copyPassword']).toBeTruthy();
      expect(I18N_MESSAGES[locale]['setup.completion.action.copyAdminToken']).toBeTruthy();
    }
  });
});