feat(frontend): i18n shared state components + UsersAdminPage + CHANGELOG
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,7 @@ describe('Toast', () => {
|
||||
expect(toast).toHaveTextContent('Session expirée');
|
||||
expect(toast).toHaveAttribute('data-kind', 'error');
|
||||
|
||||
await user.click(screen.getByRole('button', { name: /dismiss/i }));
|
||||
await user.click(screen.getByRole('button', { name: /fermer/i }));
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByTestId('toast')).toBeNull();
|
||||
});
|
||||
|
||||
@@ -56,15 +56,15 @@ describe('UsersAdminPage', () => {
|
||||
|
||||
await screen.findByText('alice');
|
||||
|
||||
await user.type(screen.getByLabelText(/^username/i), 'dan');
|
||||
await user.type(screen.getByLabelText(/^password/i), 'sup3rs4fe!');
|
||||
await user.type(screen.getByLabelText(/^nom d'utilisateur/i), 'dan');
|
||||
await user.type(screen.getByLabelText(/^mot de passe/i), 'sup3rs4fe!');
|
||||
// role default is 'redteam'; switch to 'soc' to match newUser
|
||||
await user.selectOptions(screen.getByLabelText(/^role/i), 'soc');
|
||||
await user.selectOptions(screen.getByTestId('new-role-select'), 'soc');
|
||||
|
||||
// After POST, hooks invalidate and the list refetches → return the new list
|
||||
mock.onGet('/users').reply(200, [...USERS, newUser]);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: /^create$/i }));
|
||||
await user.click(screen.getByRole('button', { name: /^créer$/i }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(postSpy).toHaveBeenCalledWith({
|
||||
@@ -85,12 +85,12 @@ describe('UsersAdminPage', () => {
|
||||
// The "Reset password" button for bob lives in bob's row.
|
||||
const bobRow = screen.getByText('bob').closest('tr');
|
||||
expect(bobRow).not.toBeNull();
|
||||
await user.click(within(bobRow as HTMLElement).getByRole('button', { name: /reset password/i }));
|
||||
await user.click(within(bobRow as HTMLElement).getByRole('button', { name: /réinitialiser le mot de passe/i }));
|
||||
|
||||
// The reset form for bob (and bob only) must appear.
|
||||
expect(await screen.findByLabelText(/new password for bob/i)).toBeInTheDocument();
|
||||
expect(screen.queryByLabelText(/new password for carol/i)).toBeNull();
|
||||
expect(screen.queryByLabelText(/new password for alice/i)).toBeNull();
|
||||
expect(await screen.findByLabelText(/nouveau mot de passe pour bob/i)).toBeInTheDocument();
|
||||
expect(screen.queryByLabelText(/nouveau mot de passe pour carol/i)).toBeNull();
|
||||
expect(screen.queryByLabelText(/nouveau mot de passe pour alice/i)).toBeNull();
|
||||
});
|
||||
|
||||
it('disables the delete button on the current user own row', async () => {
|
||||
@@ -100,7 +100,7 @@ describe('UsersAdminPage', () => {
|
||||
const aliceRow = screen.getByText('alice').closest('tr') as HTMLElement;
|
||||
const bobRow = screen.getByText('bob').closest('tr') as HTMLElement;
|
||||
|
||||
expect(within(aliceRow).getByRole('button', { name: /delete/i })).toBeDisabled();
|
||||
expect(within(bobRow).getByRole('button', { name: /delete/i })).toBeEnabled();
|
||||
expect(within(aliceRow).getByRole('button', { name: /supprimer/i })).toBeDisabled();
|
||||
expect(within(bobRow).getByRole('button', { name: /supprimer/i })).toBeEnabled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,13 +22,13 @@ describe('ErrorState', () => {
|
||||
const onRetry = vi.fn();
|
||||
render(<ErrorState message="Boom" onRetry={onRetry} />);
|
||||
expect(screen.getByTestId('error-state')).toHaveTextContent('Boom');
|
||||
await userEvent.click(screen.getByRole('button', { name: /retry/i }));
|
||||
await userEvent.click(screen.getByRole('button', { name: /réessayer/i }));
|
||||
expect(onRetry).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('omits retry button when no handler given', () => {
|
||||
render(<ErrorState message="Boom" />);
|
||||
expect(screen.queryByRole('button', { name: /retry/i })).toBeNull();
|
||||
expect(screen.queryByRole('button', { name: /réessayer/i })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user