test(portal-self-service): explain a refused or unscannable diploma upload (refs #192)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
not
2026-10-02 09:30:05 +02:00
co-authored by Claude Opus 5.5
parent 30a4028342
commit 47710c1977
@@ -1,5 +1,6 @@
import { signal } from '@angular/core';
import { fireEvent, render, screen } from '@testing-library/angular';
import { HttpErrorResponse } from '@angular/common/http';
import { of, throwError } from 'rxjs';
import { AuthService } from 'auth';
import { BffApiV1Service } from 'api-client';
@@ -142,6 +143,28 @@ describe('RegistrationPage', () => {
expect(screen.getByRole('button', { name: /documenten aanleveren/i })).toBeTruthy();
});
// S-29 (#192): the domain refuses an infected or non-PDF file (422 + reason) or cannot scan it (503);
// the citizen is told which, so they know whether to pick another file or simply retry.
it.each([
[422, { reason: 'infected' }, /virus/i],
[422, { reason: 'not-a-pdf' }, /geen PDF/i],
[503, null, /tijdelijk/i],
])('explains a refused diploma upload (%i %o)', async (status, error, message) => {
const { providers: p } = providers(
vi.fn().mockReturnValue(of({ registrationId: 'reg-9', status: 'Ingediend' })),
vi.fn().mockReturnValue(of(undefined)),
vi.fn().mockReturnValue(throwError(() => new HttpErrorResponse({ status, error }))),
);
await render(RegistrationPage, { providers: p });
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')).textContent).toMatch(message);
});
it('surfaces a withdraw failure and keeps the action available', async () => {
const { providers: p } = providers(
vi.fn().mockReturnValue(of({ registrationId: 'reg-9', status: 'Ingediend' })),