Admin-teksten en merklogo: Weergavenaam, Wachtwoord wijzigen, Eerste account aanmaken, logo per thema
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,28 @@ describe('InviteUserDialog', () => {
|
||||
expect(await screen.findByTestId('form-error-banner')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the specific conflict message instead of a generic error', async () => {
|
||||
server.use(
|
||||
http.post(`${API_BASE}/api/v1/Users/invite`, () =>
|
||||
HttpResponse.json(
|
||||
{ status: 409, title: 'Conflict', detail: 'Er staat al een openstaande uitnodiging voor dit e-mailadres.' },
|
||||
{ status: 409 },
|
||||
),
|
||||
),
|
||||
);
|
||||
await openDialog();
|
||||
|
||||
await userEvent.type(screen.getByTestId('invite-dialog-email'), 'dup@example.com');
|
||||
await userEvent.click(screen.getByTestId('invite-dialog-role'));
|
||||
const opts = await screen.findAllByRole('option');
|
||||
await userEvent.click(opts.find((o) => o.textContent === 'User')!);
|
||||
await userEvent.click(screen.getByTestId('invite-dialog-submit'));
|
||||
|
||||
expect(await screen.findByTestId('form-error-banner')).toHaveTextContent(
|
||||
'Er staat al een openstaande uitnodiging voor dit e-mailadres.',
|
||||
);
|
||||
});
|
||||
|
||||
it('resets to step 1 when dialog is closed and reopened', async () => {
|
||||
await openDialog();
|
||||
await userEvent.type(screen.getByTestId('invite-dialog-email'), 'test@example.com');
|
||||
|
||||
@@ -24,7 +24,7 @@ import { FormErrorBanner } from '@/components/ui/FormErrorBanner';
|
||||
import { FieldError } from '@/components/ui/FieldError';
|
||||
import { useInviteUser } from '@/features/users/services/useUsers';
|
||||
import { inviteUserSchema, type InviteUserFormData } from '@/features/users/schemas/users';
|
||||
import { NetworkError } from '@/lib/api-client';
|
||||
import { NetworkError, ProblemDetailsError } from '@/lib/api-client';
|
||||
|
||||
interface InviteUserDialogProps {
|
||||
open: boolean;
|
||||
@@ -40,6 +40,9 @@ export function InviteUserDialog({ open, onOpenChange }: InviteUserDialogProps)
|
||||
onError: (err) => {
|
||||
if (err instanceof NetworkError) {
|
||||
setServerError(t('errors.network'));
|
||||
} else if (err instanceof ProblemDetailsError && err.status === 409 && err.problem.detail) {
|
||||
// The server words the conflict (user exists / open invitation exists) in Dutch.
|
||||
setServerError(err.problem.detail);
|
||||
} else {
|
||||
setServerError(t('errors.generic'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user