Gebruikerslijst: verlopen uitnodiging tonen, Beheerder mag uitnodiging intrekken, neutrale tekst bij ongeldige link
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { renderApp, mockAuthenticated } from '@/test/utils';
|
||||
import { server } from '@/mocks/server';
|
||||
import { API_BASE } from '@/features/auth/mocks/fixtures';
|
||||
import { API_BASE, makeAuthResponse, mockUser } from '@/features/auth/mocks/fixtures';
|
||||
import { getMockUsers } from '@/features/users/mocks/handlers';
|
||||
import { _resetSetupStatusCache } from '@/router';
|
||||
|
||||
@@ -57,6 +57,63 @@ describe('UsersPage', () => {
|
||||
expect(screen.getByTestId(`user-copy-link-${pendingUser.id}`)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('lets the Owner delete a pending invitation', async () => {
|
||||
mockAuthenticated();
|
||||
renderApp('/users');
|
||||
|
||||
await screen.findByTestId('users-table');
|
||||
const pendingUser = getMockUsers().find((u) => u.invitationPending)!;
|
||||
await userEvent.click(screen.getByTestId(`user-actions-${pendingUser.id}`));
|
||||
|
||||
expect(screen.getByTestId(`user-delete-${pendingUser.id}`)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('lets an Administrator withdraw a pending invitation for a User, but not delete accounts', async () => {
|
||||
server.use(
|
||||
http.post(`${API_BASE}/api/v1/auth/refresh`, () =>
|
||||
HttpResponse.json(makeAuthResponse({ user: { ...mockUser, role: 'Administrator', name: 'Test Admin' } })),
|
||||
),
|
||||
);
|
||||
renderApp('/users');
|
||||
|
||||
await screen.findByTestId('users-table');
|
||||
const pendingUser = getMockUsers().find((u) => u.invitationPending)!;
|
||||
await userEvent.click(screen.getByTestId(`user-actions-${pendingUser.id}`));
|
||||
expect(screen.getByTestId(`user-delete-${pendingUser.id}`)).toBeInTheDocument();
|
||||
await userEvent.keyboard('{Escape}');
|
||||
|
||||
const account = getMockUsers().find((u) => !u.invitationPending && u.role === 'Administrator')!;
|
||||
expect(screen.queryByTestId(`user-delete-${account.id}`)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('lists an expired invitation as expired, removable, without a copy-link action', async () => {
|
||||
mockAuthenticated();
|
||||
server.use(
|
||||
http.get(USERS_URL, () =>
|
||||
HttpResponse.json([
|
||||
{
|
||||
id: '44444444-4444-4444-4444-444444444444',
|
||||
email: 'late@example.com',
|
||||
name: 'late@example.com',
|
||||
role: 'User',
|
||||
isActive: true,
|
||||
createdAt: '2026-01-01T00:00:00.000Z',
|
||||
invitationPending: true,
|
||||
invitationExpired: true,
|
||||
inviteLink: null,
|
||||
},
|
||||
]),
|
||||
),
|
||||
);
|
||||
renderApp('/users');
|
||||
|
||||
const row = await screen.findByTestId('user-row-44444444-4444-4444-4444-444444444444');
|
||||
expect(within(row).getByText('Invitation expired')).toBeInTheDocument();
|
||||
await userEvent.click(screen.getByTestId('user-actions-44444444-4444-4444-4444-444444444444'));
|
||||
expect(screen.getByTestId('user-delete-44444444-4444-4444-4444-444444444444')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('user-copy-link-44444444-4444-4444-4444-444444444444')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows an error message when the API fails', async () => {
|
||||
mockAuthenticated();
|
||||
server.use(http.get(USERS_URL, () => HttpResponse.json({}, { status: 500 })));
|
||||
|
||||
Reference in New Issue
Block a user