test(portal-behandel): the werkbak must show a new registration without a reload (refs #162)

A registration only reaches the Beoordelen task after the citizen supplies its
documents, so it lands in an already-open werkbak asynchronously — today a
behandelaar has to reload to see it.

Component spec: one interval passes and the werkbak has re-read itself, the new
row is on screen, and the loading state has not flashed over the rows being
read. Fails with "expected vi.fn() to be called 2 times, but got 1 times".
Two guards go with it — a failing background poll must not replace the list
with the load-failure alert, and the refresh must stop when the page is
destroyed.

E2E: the happy path now waits for the werkbak row WITHOUT reloading the page.
The removed `staff.reload()` is the assertion.

Refs the accepted mechanism in #163 (ADR-0032, landing with the implementation).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
not
2026-09-04 10:45:17 +02:00
co-authored by Claude Opus 5
parent d0fb2b3e8c
commit cd3faaf638
3 changed files with 78 additions and 11 deletions
+7 -10
View File
@@ -82,17 +82,14 @@ test('DigiD submit → public INGEDIEND → documenten → behandelaar goedkeurt
await expect(staff.getByRole('heading', { name: /Werkbak/i })).toBeVisible();
// The registration reaches the Beoordelen user task only after its documents are provided (above), so
// it appears in the werkbak asynchronously — reload until this reference's row shows up. Target the
// decide button by reference (not a generic "Goedkeuren"): the shared verify stack holds other open
// tasks, so a positional match could act on someone else's registration.
// The registration reaches the Beoordelen user task only after its documents are provided (above),
// so it appears in the werkbak asynchronously. Since S-26 (#162) the werkbak refreshes itself, so
// this waits on the row WITHOUT reloading the page — the reload here is what the slice removes, and
// its absence is the live-refresh assertion. Target the decide button by reference (not a generic
// "Goedkeuren"): the shared verify stack holds other open tasks, so a positional match could act on
// someone else's registration.
const goedkeuren = staff.getByRole('button', { name: `Goedkeuren ${reference}` });
await expect
.poll(async () => {
await staff.reload();
return goedkeuren.count();
}, { timeout: 30_000, intervals: [1_000, 2_000, 3_000, 5_000] })
.toBeGreaterThan(0);
await expect(goedkeuren).toBeVisible({ timeout: 30_000 });
// Click and wait for the decide POST to finish (204) BEFORE leaving the page. `click()` only
// dispatches the request; navigating away immediately cancels it in flight (nginx logs a 499) and