import { expect, test } from '@playwright/test'; // S-26: a zorgprofessional submits, then reloads the self-service portal. On load the portal asks the // BFF for the caller's current open registration (owner-scoped by the DigiD token's bsn) and restores // the submitted view — so a refresh no longer strands the in-flight registration and its actions. test('DigiD submit → reload → self-service restores the existing registration', async ({ page }) => { await page.goto('/'); // Its own DigiD user (like every self-service spec): on the shared verify stack, resume-on-load // (S-26) restores any open registration for the bsn, so each spec uses a dedicated citizen that no // other spec or verify-* check touches. This one in particular leaves an open registration. await page.locator('#username').fill('sanne-burger'); await page.locator('#password').fill('test123'); await page.locator('#kc-login').click(); await expect(page.getByRole('heading', { name: /Zelfservice/i })).toBeVisible(); await page.getByRole('button', { name: /indienen/i }).click(); const confirmation = page.getByText(/ontvangen/i); await expect(confirmation).toBeVisible(); const reference = (await confirmation.textContent())?.match(/Referentie:\s*([0-9a-fA-F-]+)/)?.[1]; expect(reference, 'the confirmation shows a registration reference').toBeTruthy(); // Reload: the component's in-memory submitted state is gone, but the DigiD session persists and the // portal resumes from the BFF instead of dropping back to the blank submit form. await page.reload(); await expect(page.getByText(/ontvangen/i)).toBeVisible(); // The same reference the citizen saw before the reload is restored... await expect(page.getByText(new RegExp(reference!))).toBeVisible(); // ...and its actions are reachable again (e.g. "trek aanvraag in"). await expect(page.getByRole('button', { name: /trek aanvraag in/i })).toBeVisible(); });