feat(frontend): i18n shared state components + UsersAdminPage + CHANGELOG

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Knacky
2026-06-21 23:56:47 +02:00
parent ad0a3f5cac
commit 2931e4aaf9
8 changed files with 125 additions and 69 deletions

View File

@@ -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();
});
});