Skip to content

Commit

Permalink
Fixed test according to changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AbelMH1 committed May 2, 2024
1 parent 537da03 commit b3090a3
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions webapp/src/components/AddUser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ describe('AddUser component', () => {
it('should add user successfully', async () => {
render(<AddUser />);

const nameInput = screen.getByLabelText(/Nombre/);
const surnameInput = screen.getByLabelText(/Apellidos/i);
const usernameInput = screen.getByLabelText(/Usuario/i);
const passwordInput = screen.getAllByLabelText(/Contraseña/i)[0];
const confirmPasswordInput = screen.getByLabelText(/Repetir contraseña/i);
Expand All @@ -25,8 +23,6 @@ describe('AddUser component', () => {
mockAxios.onPost('http://localhost:8000/adduser').reply(200);

// Simulate user input
fireEvent.change(nameInput, { target: { value: 'testUsera' } });
fireEvent.change(surnameInput, { target: { value: 'testUsera' } });
fireEvent.change(usernameInput, { target: { value: 'testUsera' } });
fireEvent.change(passwordInput, { target: { value: 'testPassw' } });
fireEvent.change(confirmPasswordInput, { target: { value: 'testPassw' } });
Expand Down Expand Up @@ -65,8 +61,6 @@ describe('AddUser component', () => {
render(<AddUser />);

// Simulate user input
fireEvent.change(screen.getByLabelText(/Nombre/), { target: { value: 'userForTest' } });
fireEvent.change(screen.getByLabelText(/Apellidos/i), { target: { value: 'userForTest' } });
fireEvent.change(screen.getByLabelText(/Usuario/i), { target: { value: 'userForTest' } });
fireEvent.change(screen.getAllByLabelText(/Contraseña/i)[0], { target: { value: 'testPassword2' } });
fireEvent.change(screen.getByLabelText(/Repetir contraseña/i), { target: { value: 'password' } });
Expand All @@ -87,8 +81,6 @@ describe('AddUser component', () => {
mockAxios.onPost('http://localhost:8000/adduser').reply(500, { error: 'Internal Server Error' });

// Simulate user input
fireEvent.change(screen.getByLabelText(/Nombre/), { target: { value: 'a' } });
fireEvent.change(screen.getByLabelText(/Apellidos/i), { target: { value: 'a' } });
fireEvent.change(screen.getByLabelText(/Usuario/i), { target: { value: 'a' } });
fireEvent.change(screen.getAllByLabelText(/Contraseña/i)[0], { target: { value: 'testPassword2' } });
fireEvent.change(screen.getByLabelText(/Repetir contraseña/i), { target: { value: 'testPassword2' } });
Expand All @@ -98,7 +90,7 @@ describe('AddUser component', () => {

// Wait for the error Snackbar to be open
await waitFor(() => {
expect(screen.getByText(/Error: Internal Server Error/i)).toBeInTheDocument();
expect(screen.getByText(/Usuario ya registrado./i)).toBeInTheDocument();
});
});
});

0 comments on commit b3090a3

Please sign in to comment.