From 7e28b8ce6d63b6652cc35e6aa066fd72caef4fa6 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 23 Oct 2026 02:18:39 +0000 Subject: [PATCH] test(i18n): the first load of a language's strings gets more than a second on a busy runner --- client/tests/unit/i18n/TranslationContext.test.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/tests/unit/i18n/TranslationContext.test.tsx b/client/tests/unit/i18n/TranslationContext.test.tsx index c76b80803..48382eb1e 100644 --- a/client/tests/unit/i18n/TranslationContext.test.tsx +++ b/client/tests/unit/i18n/TranslationContext.test.tsx @@ -25,6 +25,10 @@ function HtmlProbe({ tKey, params }: { tKey: string; params?: Record{tHtml(tKey, params)}; } +// A language's string table is built from its files the first time it is asked +// for; on a busy runner that can take longer than waitFor's default second. +const FIRST_LOAD = { timeout: 5000 }; + function withLanguage(language: string) { seedStore(useSettingsStore, { settings: { language } }); } @@ -73,14 +77,14 @@ describe('TranslationProvider', () => { render(); expect(screen.getByTestId('language').textContent).toBe('de'); - await waitFor(() => expect(screen.getByTestId('value').textContent).toBe('Speichern')); + await waitFor(() => expect(screen.getByTestId('value').textContent).toBe('Speichern'), FIRST_LOAD); expect(screen.getByTestId('locale').textContent).toBe('de-DE'); }); it('FE-COMP-I18NCTX-006: falls back to the English string for a key a locale is missing', async () => { withLanguage('de'); render(); - await waitFor(() => expect(screen.getByTestId('value').textContent).toBe('does.not.exist')); + await waitFor(() => expect(screen.getByTestId('value').textContent).toBe('does.not.exist'), FIRST_LOAD); }); it('FE-COMP-I18NCTX-007: writes lang and ltr direction onto the html element', () => { @@ -97,7 +101,7 @@ describe('TranslationProvider', () => { expect(document.documentElement.lang).toBe('ar'); expect(document.documentElement.dir).toBe('rtl'); - await waitFor(() => expect(screen.getByTestId('value').textContent).not.toBe('Save')); + await waitFor(() => expect(screen.getByTestId('value').textContent).not.toBe('Save'), FIRST_LOAD); }); it('FE-COMP-I18NCTX-009: keeps the English table for an unknown language code', () => { @@ -147,7 +151,7 @@ describe('TranslationProvider', () => { // English strings until the Russian chunk arrives, read with the English // rule: 21 is "other" there, while Russian's rule would pick English's .one. expect(screen.getByTestId('value').textContent).toBe('21 places'); - await waitFor(() => expect(screen.getByTestId('value').textContent).toBe('21 место')); + await waitFor(() => expect(screen.getByTestId('value').textContent).toBe('21 место'), FIRST_LOAD); }); it('FE-COMP-I18NCTX-012: the default context outside a provider echoes the key', () => {