mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-10 02:25:56 +00:00
test(web): guard bootstrap timer cleanup across attempts
Slow-start recovery is advertised to preview users. Pin cleanup when the loading fallback unmounts and ensure a later attempt does not inherit the previous warning deadline. This guards existing UX without changing product behaviour; 34 focused bootstrap, connection badge and runtime tests pass. Change-source: pulse-maintainer
This commit is contained in:
@@ -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(() => <AppBootstrapStatus />);
|
||||
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(() => <AppBootstrapStatus />);
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user