diff --git a/frontend-modern/src/components/__tests__/AppBootstrapStatus.test.tsx b/frontend-modern/src/components/__tests__/AppBootstrapStatus.test.tsx index 128ad1b91..8e536f2af 100644 --- a/frontend-modern/src/components/__tests__/AppBootstrapStatus.test.tsx +++ b/frontend-modern/src/components/__tests__/AppBootstrapStatus.test.tsx @@ -34,4 +34,24 @@ describe('AppBootstrapStatus', () => { fireEvent.click(retry); expect(onRetry).toHaveBeenCalledOnce(); }); + + it('cancels a completed bootstrap timer and gives a fresh attempt its full waiting period', async () => { + vi.useFakeTimers(); + const first = render(() => ); + await vi.advanceTimersByTimeAsync(APP_BOOTSTRAP_SLOW_DELAY_MS - 1); + expect(screen.queryByRole('button', { name: 'Retry connection' })).toBeNull(); + + first.unmount(); + expect(vi.getTimerCount()).toBe(0); + + render(() => ); + await vi.advanceTimersByTimeAsync(1); + expect(screen.getByRole('status')).toHaveTextContent( + 'Checking your session and preparing the workspace.', + ); + expect(screen.queryByRole('button', { name: 'Retry connection' })).toBeNull(); + + await vi.advanceTimersByTimeAsync(APP_BOOTSTRAP_SLOW_DELAY_MS - 1); + expect(screen.getByRole('button', { name: 'Retry connection' })).toBeVisible(); + }); });