From d354fe507aa4522ef9f14b8a224e6243182f396a Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Mon, 20 Jul 2026 12:14:36 +0200 Subject: [PATCH] test(portal): self-service uploads a chosen diploma file (refs #103) RED: after submitting, the citizen picks a PDF and uploads it; the component base64- encodes it client-side and posts { contentBase64, fileName, contentType } keyed by the reference, then confirms. Replaces the S-10a stub button. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../app/registration/registration-page.spec.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/self-service/src/app/registration/registration-page.spec.ts b/apps/self-service/src/app/registration/registration-page.spec.ts index f17ff06..8e8cff9 100644 --- a/apps/self-service/src/app/registration/registration-page.spec.ts +++ b/apps/self-service/src/app/registration/registration-page.spec.ts @@ -83,21 +83,29 @@ describe('RegistrationPage', () => { expect(await screen.findByText(/ingetrokken/i)).toBeTruthy(); }); - it('offers to provide documents after submitting, and doing so confirms', async () => { + // A small PDF file the citizen "uploads"; the component base64-encodes it client-side. + const diploma = () => new File([new Uint8Array([1, 2, 3])], 'diploma.pdf', { type: 'application/pdf' }); + + it('uploads a chosen diploma after submitting, and doing so confirms', async () => { const { provideDocuments, providers: p } = providers(); await render(RegistrationPage, { providers: p }); fireEvent.click(screen.getByRole('button', { name: /indienen/i })); await screen.findByText(/ontvangen/i); + // Choose the file, then upload it. + fireEvent.change(screen.getByLabelText(/diploma/i), { target: { files: [diploma()] } }); fireEvent.click(await screen.findByRole('button', { name: /documenten aanleveren/i })); - // The provide-documents call is keyed by the reference the submit returned, and the page confirms. - expect(provideDocuments).toHaveBeenCalledWith('reg-9'); + // The upload is keyed by the reference and carries the base64 file + its name; the page confirms. expect(await screen.findByText(/documenten.*aangeleverd/i)).toBeTruthy(); + expect(provideDocuments).toHaveBeenCalledWith( + 'reg-9', + expect.objectContaining({ fileName: 'diploma.pdf', contentType: 'application/pdf', contentBase64: expect.any(String) }), + ); }); - it('surfaces a provide-documents failure and keeps the action available', async () => { + it('surfaces a diploma-upload failure and keeps the action available', async () => { const { providers: p } = providers( vi.fn().mockReturnValue(of({ registrationId: 'reg-9', status: 'Ingediend' })), vi.fn().mockReturnValue(of(undefined)), @@ -107,6 +115,7 @@ describe('RegistrationPage', () => { fireEvent.click(screen.getByRole('button', { name: /indienen/i })); await screen.findByText(/ontvangen/i); + fireEvent.change(screen.getByLabelText(/diploma/i), { target: { files: [diploma()] } }); fireEvent.click(await screen.findByRole('button', { name: /documenten aanleveren/i })); expect(await screen.findByRole('alert')).toBeTruthy();