import { expect, test } from '@playwright/test'; // S-11 (Flow 3): a zorgprofessional logs in via mock DigiD, submits a registration, then withdraws // it ("trek aanvraag in") from the self-service portal. The withdrawal goes portal → BFF (owner- // scoped by the DigiD token's bsn) → domain, which cancels the running workflow (ADR-0014); the page // then confirms the registration is ingetrokken. test('DigiD submit → trek aanvraag in → self-service confirms ingetrokken', async ({ page }) => { // Visiting the guarded page redirects to the Keycloak (mock DigiD) login. await page.goto('/'); await page.locator('#username').fill('jan-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(); // The BFF accepted it and the page shows the confirmation with the reference. await expect(page.getByText(/ontvangen/i)).toBeVisible(); // Withdraw it. The confirmation of withdrawal appears only after the decide POST completes (204), // so awaiting the "ingetrokken" text also proves the request landed — no premature navigation. await page.getByRole('button', { name: /trek aanvraag in/i }).click(); await expect(page.getByText(/is ingetrokken/i)).toBeVisible(); });