test(portal-behandel): a refresh must clear a stale load failure (refs #162)
If the first read fails the werkbak shows its error until the behandelaar reloads — the very thing this slice removes. Fails with "expected <p utrecht-paragraph …> to be null". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -145,6 +145,30 @@ describe('WerkbakPage', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('clears a load failure once a refresh succeeds', async () => {
|
||||||
|
// Without this the werkbak stays stuck on the error until the behandelaar reloads — the very
|
||||||
|
// thing this slice removes. A recovered read must put the rows back.
|
||||||
|
vi.useFakeTimers();
|
||||||
|
try {
|
||||||
|
const getBehandelWerkbak = vi
|
||||||
|
.fn()
|
||||||
|
.mockReturnValueOnce(throwError(() => new Error('503')))
|
||||||
|
.mockReturnValue(of(sample));
|
||||||
|
const { providers } = setup({ getBehandelWerkbak });
|
||||||
|
const { detectChanges } = await render(WerkbakPage, { providers });
|
||||||
|
|
||||||
|
expect(screen.getByText(/kon de werkbak niet laden/i)).toBeTruthy();
|
||||||
|
|
||||||
|
vi.advanceTimersByTime(WERKBAK_REFRESH_MS);
|
||||||
|
detectChanges();
|
||||||
|
|
||||||
|
expect(screen.queryByText(/kon de werkbak niet laden/i)).toBeNull();
|
||||||
|
expect(screen.getByText('reg-1')).toBeTruthy();
|
||||||
|
} finally {
|
||||||
|
vi.useRealTimers();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('shows an empty state when the werkbak has no items', async () => {
|
it('shows an empty state when the werkbak has no items', async () => {
|
||||||
const { providers } = setup({ getBehandelWerkbak: vi.fn().mockReturnValue(of([])) });
|
const { providers } = setup({ getBehandelWerkbak: vi.fn().mockReturnValue(of([])) });
|
||||||
await render(WerkbakPage, { providers });
|
await render(WerkbakPage, { providers });
|
||||||
|
|||||||
Reference in New Issue
Block a user