diff --git a/webapp/src/components/tests/AddUser.test.js b/webapp/src/components/tests/AddUser.test.js
index 49cf88b..2994019 100644
--- a/webapp/src/components/tests/AddUser.test.js
+++ b/webapp/src/components/tests/AddUser.test.js
@@ -57,44 +57,60 @@ describe('AddUser component', () => {
});
});
-
-
-
-
- // it('should display error message for short password', async () => {
+ // it('should show error of password too short', async () => {
// render();
+ // const mockAxios = new MockAdapter(axios);
+ // const mockedUsernames = ['existingUser'];
+ // mockAxios.onGet(`http://localhost:8000/getUsernames`).reply(200, { usernames: mockedUsernames });
+
// const usernameInput = screen.getByLabelText(/Usuario/i);
// const passwordInput = screen.getByLabelText(/Contraseña/i);
- // const createUserButton = screen.getByRole('button', { name: /Crear/i });
+ // const addUserButton = screen.getByRole('button', { name: /Crear/i });
- // fireEvent.change(usernameInput, { target: { value: 'newusername' } });
- // fireEvent.change(passwordInput, { target: { value: 'err' } });
+ // // Mock the axios.post request to simulate a successful response
+ // mockAxios.onPost('http://localhost:8000/adduser').reply(200);
- // fireEvent.click(createUserButton);
+ // // Simulate user input
+ // fireEvent.change(usernameInput, { target: { value: 'testUser' } });
+ // fireEvent.change(passwordInput, { target: { value: 'sh' } });
- // expect(await screen.findByText(/Error: Credenciales incorrectas. La contraseña debe contener al menos 8 caracteres/i)).toBeInTheDocument();
+ // // Trigger the add user button click
+ // fireEvent.click(addUserButton);
+
+ // // Wait for the Snackbar to be open
+ // await waitFor(() => {
+ // expect(screen.getByText(/Error: Credenciales incorrectas. La contraseña debe contener al menos 8 caracteres/i)).toBeInTheDocument();
+ // });
// });
+ // it('should show error of repeated user', async () => {
+ // render();
- // it('should display error message for repeated username', async () => {
// const mockAxios = new MockAdapter(axios);
// const mockedUsernames = ['existingUser'];
// mockAxios.onGet(`http://localhost:8000/getUsernames`).reply(200, { usernames: mockedUsernames });
- // render();
-
// const usernameInput = screen.getByLabelText(/Usuario/i);
// const passwordInput = screen.getByLabelText(/Contraseña/i);
- // const createUserButton = screen.getByRole('button', { name: /Crear/i });
+ // const addUserButton = screen.getByRole('button', { name: /Crear/i });
+ // // Mock the axios.post request to simulate a successful response
+ // mockAxios.onPost('http://localhost:8000/adduser').reply(200);
+
+ // // Simulate user input
// fireEvent.change(usernameInput, { target: { value: 'existingUser' } });
- // fireEvent.change(passwordInput, { target: { value: 'short123456' } });
+ // fireEvent.change(passwordInput, { target: { value: 'passwordCorrect' } });
- // fireEvent.click(createUserButton);
+ // // Trigger the add user button click
+ // fireEvent.click(addUserButton);
- // expect(await screen.findByText(/Usuario creado correctamente/i)).toBeInTheDocument();
+ // // Wait for the Snackbar to be open
+ // await waitFor(() => {
+ // expect(screen.getByText(/Error: Credenciales incorrectas. El nombre de usuario esta en uso/i)).toBeInTheDocument();
+ // });
// });
-
+
+
});