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'));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { renderApp, mockAuthenticated, mockGuest } from '@/test/utils';
|
||||
import { server } from '@/mocks/server';
|
||||
import { API_BASE } from '@/features/auth/mocks/fixtures';
|
||||
import { _resetSetupStatusCache } from '@/router';
|
||||
import i18n from '@/i18n/config';
|
||||
|
||||
beforeEach(() => {
|
||||
_resetSetupStatusCache();
|
||||
@@ -22,6 +23,23 @@ describe('ProfilePage', () => {
|
||||
expect(screen.getByTestId('profile-role-badge')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('titles the password card with what it does, not "Security"', async () => {
|
||||
mockAuthenticated();
|
||||
renderApp('/profile');
|
||||
|
||||
const title = await screen.findByTestId('profile-security-title', {}, { timeout: 10000 });
|
||||
expect(title).toHaveTextContent(i18n.t('profile.securityTitle'));
|
||||
expect(title).not.toHaveTextContent('Security');
|
||||
expect(i18n.t('profile.securityTitle', { lng: 'nl' })).toBe('Wachtwoord wijzigen');
|
||||
});
|
||||
|
||||
it('labels the name field "Weergavenaam" in Dutch', () => {
|
||||
expect(i18n.t('profile.name', { lng: 'nl' })).toBe('Weergavenaam');
|
||||
expect(i18n.t('inviteComplete.nameLabel', { lng: 'nl' })).toBe('Weergavenaam');
|
||||
expect(i18n.t('setup.nameLabel', { lng: 'nl' })).toBe('Weergavenaam');
|
||||
expect(i18n.t('setup.title', { lng: 'nl' })).toBe('Eerste account aanmaken');
|
||||
});
|
||||
|
||||
it('pre-fills name and email from authenticated user', async () => {
|
||||
mockAuthenticated();
|
||||
renderApp('/profile');
|
||||
|
||||
@@ -265,7 +265,9 @@ export function ProfilePage() {
|
||||
{/* Security card */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Security</CardTitle>
|
||||
<CardTitle className="text-base" data-testid="profile-security-title">
|
||||
{t('profile.securityTitle')}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Button
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { renderWithProviders } from '@/test/utils';
|
||||
import { DeleteUserDialog } from '@/features/users/components/DeleteUserDialog';
|
||||
import type { UserListItem } from '@/features/users/services/types';
|
||||
|
||||
function userItem(overrides: Partial<UserListItem>): UserListItem {
|
||||
return {
|
||||
id: '22222222-2222-2222-2222-222222222222',
|
||||
email: 'info@x.nl',
|
||||
name: 'Bryan',
|
||||
role: 'User',
|
||||
isActive: true,
|
||||
createdAt: '2026-01-01T00:00:00Z',
|
||||
invitationPending: false,
|
||||
inviteLink: null,
|
||||
...overrides,
|
||||
} as UserListItem;
|
||||
}
|
||||
|
||||
function renderDialog(user: UserListItem) {
|
||||
return renderWithProviders(
|
||||
<DeleteUserDialog user={user} open onOpenChange={vi.fn()} onConfirm={vi.fn()} isPending={false} />,
|
||||
);
|
||||
}
|
||||
|
||||
describe('DeleteUserDialog', () => {
|
||||
it('names the person and their e-mail address', async () => {
|
||||
renderDialog(userItem({}));
|
||||
expect(await screen.findByTestId('delete-user-dialog')).toHaveTextContent('Bryan (info@x.nl)');
|
||||
});
|
||||
|
||||
it('does not repeat the address when the account has no display name', async () => {
|
||||
renderDialog(userItem({ name: 'info@x.nl' }));
|
||||
const text = (await screen.findByTestId('delete-user-dialog')).textContent ?? '';
|
||||
expect(text).toContain('info@x.nl');
|
||||
expect(text).not.toContain('info@x.nl (info@x.nl)');
|
||||
});
|
||||
});
|
||||
@@ -28,6 +28,9 @@ export function DeleteUserDialog({
|
||||
const { t } = useTranslation();
|
||||
if (!user) return null;
|
||||
|
||||
// Accounts without a display name come back with the e-mail address as their name; "a@b (a@b)" is noise.
|
||||
const hasName = user.name.trim() !== '' && user.name.toLowerCase() !== user.email.toLowerCase();
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-md" data-testid="delete-user-dialog">
|
||||
@@ -36,7 +39,9 @@ export function DeleteUserDialog({
|
||||
<DialogDescription>
|
||||
{user.invitationPending
|
||||
? t('users.delete.descriptionPending', { email: user.email })
|
||||
: t('users.delete.description', { name: user.name, email: user.email })}
|
||||
: hasName
|
||||
? t('users.delete.description', { name: user.name, email: user.email })
|
||||
: t('users.delete.descriptionNoName', { email: user.email })}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter className="gap-2">
|
||||
|
||||
Reference in New Issue
Block a user