Skip to content

Commit

Permalink
Cambio de codigo comentado pero sigue sin funcionar correctamente
Browse files Browse the repository at this point in the history
  • Loading branch information
uo276026 committed Apr 28, 2024
1 parent 07d8fa7 commit 81137f6
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions webapp/src/components/tests/AddUser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(<AddUser />);

// 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(<AddUser />);

// 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(<AddUser />);

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



});

0 comments on commit 81137f6

Please sign in to comment.