From b3e2e9fa258bf9bf1437fd44a8afcfdac66e3cff Mon Sep 17 00:00:00 2001 From: brooklyn! Date: Wed, 23 Sep 2026 17:31:52 -0500 Subject: [PATCH] test(desktop): unmounting I18nProvider cancels a pending locale retry The bounded startup locale retry (#96177's second half) already landed on main; this pins its cleanup path, which had no coverage: once the provider unmounts, the scheduled retry is cleared instead of polling /api/config for a tree nobody renders. Adapted from the unmount case in #96213. Co-authored-by: 686f6c61 --- apps/desktop/src/i18n/context.test.tsx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apps/desktop/src/i18n/context.test.tsx b/apps/desktop/src/i18n/context.test.tsx index 4748c4b0c8..2b24ca31e5 100644 --- a/apps/desktop/src/i18n/context.test.tsx +++ b/apps/desktop/src/i18n/context.test.tsx @@ -257,6 +257,31 @@ describe('I18nProvider', () => { vi.useRealTimers() }) + it('stops retrying once the provider unmounts mid-retry', async () => { + vi.useFakeTimers() + const getConfig = vi.fn().mockRejectedValue(new Error('backend not ready yet')) + + const view = render( + + + + ) + + await act(async () => {}) + expect(getConfig).toHaveBeenCalledTimes(1) + + // A retry is now scheduled; unmounting must cancel it, not keep polling a + // backend nobody is listening for. + view.unmount() + + await act(async () => { + vi.advanceTimersByTime(60_000) + }) + expect(getConfig).toHaveBeenCalledTimes(1) + + vi.useRealTimers() + }) + it('a late startup read never overrides a language the user picked mid-retry', async () => { vi.useFakeTimers()