Skip to content

Commit

Permalink
Adaptada interfaz al español
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289432 committed Apr 25, 2024
1 parent f384bf4 commit 4ccab80
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion webapp/e2e/steps/home.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defineFeature(feature, test => {
when('I navigate to the Home page', async () => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button', { text: 'Login' })
await expect(page).toClick('button', { text: 'Iniciar Sesión' })

await expect(page).toClick('a[href="/"]', { text: 'WIQ 5A' });
await page.waitForNavigation();
Expand Down
4 changes: 2 additions & 2 deletions webapp/e2e/steps/login.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ defineFeature(feature, test => {
when('I enter valid username and password', async () => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button', { text: 'Login' })
await expect(page).toClick('button', { text: 'Iniciar Sesión' })
});

then('A confirmation message should be shown in the screen', async () => {
await expect(page).toMatchElement("div", { text: "Hello "+username+"!" });
await expect(page).toMatchElement("div", { text: "¡Buenas, "+username+"!" });
});
})

Expand Down
4 changes: 2 additions & 2 deletions webapp/e2e/steps/register-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ defineFeature(feature, test => {
when('I fill the data in the form and press submit', async () => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button', { text: 'Add User' })
await expect(page).toClick('button', { text: 'Crear' })
});

then('A confirmation message should be shown in the screen', async () => {
await expect(page).toMatchElement("div", { text: "User added successfully" });
await expect(page).toMatchElement("div", { text: "Usuario creado correctamente" });
});
})

Expand Down
10 changes: 5 additions & 5 deletions webapp/src/components/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ const AddUser = () => {
return (
<Container component="main" maxWidth="xs" sx={{ marginTop: 4 }}>
<Typography component="h1" variant="h5">
Add User
Registrar Usuario
</Typography>
<TextField
name="username"
margin="normal"
fullWidth
label="Username"
label="Usuario"
value={username}
onChange={(e) => setUsername(e.target.value)}
/>
<TextField
name="password"
margin="normal"
fullWidth
label="Password"
label="Contraseña"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<Button variant="contained" color="primary" onClick={addUser}>
Add User
Crear
</Button>
<Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="User added successfully" />
<Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="Usuario creado correctamente" />
{error && (
<Snackbar open={!!error} autoHideDuration={6000} onClose={() => setError('')} message={`Error: ${error}`} />
)}
Expand Down
8 changes: 4 additions & 4 deletions webapp/src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Login = ({isLogged, setIsLogged, username, setUsername}) => {
name="username"
margin="normal"
fullWidth
label="Username"
label="Usuario"
value={username}

onChange={(e) => setUsername(e.target.value)}
Expand All @@ -62,15 +62,15 @@ const Login = ({isLogged, setIsLogged, username, setUsername}) => {
name="password"
margin="normal"
fullWidth
label="Password"
label="Contraseña"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<Button variant="contained" color="primary" onClick={loginUser}>
Login
Iniciar Sesión
</Button>
<Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="Login successful" />
<Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="Iniciada sesión exitosamente" />
{error && (
<Snackbar open={!!error} autoHideDuration={6000} onClose={() => setError('')} message={`Error: ${error}`} />
)}
Expand Down
14 changes: 7 additions & 7 deletions webapp/src/components/tests/AddUser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ describe('AddUser component', () => {
it('should add user successfully', async () => {
render(<AddUser />);

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const addUserButton = screen.getByRole('button', { name: /Add User/i });
const usernameInput = screen.getByLabelText(/Usuario/i);
const passwordInput = screen.getByLabelText(/Contraseña/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);
Expand All @@ -30,16 +30,16 @@ describe('AddUser component', () => {

// Wait for the Snackbar to be open
await waitFor(() => {
expect(screen.getByText(/User added successfully/i)).toBeInTheDocument();
expect(screen.getByText(/Usuario creado correctamente/i)).toBeInTheDocument();
});
});

it('should handle error when adding user', async () => {
render(<AddUser />);

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const addUserButton = screen.getByRole('button', { name: /Add User/i });
const usernameInput = screen.getByLabelText(/Usuario/i);
const passwordInput = screen.getByLabelText(/Contraseña/i);
const addUserButton = screen.getByRole('button', { name: /Crear/i });

// Mock the axios.post request to simulate an error response
mockAxios.onPost('http://localhost:8000/adduser').reply(500, { error: 'Internal Server Error' });
Expand Down
20 changes: 10 additions & 10 deletions webapp/src/components/tests/Login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ describe('Login component', () => {
it('should render correctly', async () => {
render(<Login isLogged={false} setIsLogged={jest.fn()} username={''} setUsername={jest.fn()}/>);

expect(screen.getByLabelText(/Username/i)).toBeInTheDocument();
expect(screen.getByLabelText(/Password/i)).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Login/i })).toBeInTheDocument();
expect(screen.getByLabelText(/Usuario/i)).toBeInTheDocument();
expect(screen.getByLabelText(/Contraseña/i)).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Iniciar Sesión/i })).toBeInTheDocument();
})

it('should log in successfully', async () => {
render(<Login isLogged={false} setIsLogged={jest.fn()} username={'testUser'} setUsername={jest.fn()}/>);

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const loginButton = screen.getByRole('button', { name: /Login/i });
const usernameInput = screen.getByLabelText(/Usuario/i);
const passwordInput = screen.getByLabelText(/Contraseña/i);
const loginButton = screen.getByRole('button', { name: /Iniciar Sesión/i });

// Mock the axios.post request to simulate a successful response
mockAxios.onPost('http://localhost:8000/login').reply(200, { createdAt: '2024-01-01T12:34:56Z' });
Expand All @@ -38,7 +38,7 @@ describe('Login component', () => {
});

// Verify that the user information is displayed
expect(screen.getByText(/Login successful/i)).toBeInTheDocument();
expect(screen.getByText(/Iniciada sesión exitosamente/i)).toBeInTheDocument();
//expect(screen.getByText(/Your account was created on 1\/1\/2024/i)).toBeInTheDocument();
});

Expand All @@ -53,9 +53,9 @@ describe('Login component', () => {
it('should handle error when logging in', async () => {
render(<Login isLogged={false} setIsLogged={jest.fn()} username={'testUer'} setUsername={jest.fn()}/>);

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const loginButton = screen.getByRole('button', { name: /Login/i });
const usernameInput = screen.getByLabelText(/Usuario/i);
const passwordInput = screen.getByLabelText(/Contraseña/i);
const loginButton = screen.getByRole('button', { name: /Iniciar Sesión/i });


mockAxios.onPost('http://localhost:8000/login').reply(401, { error: 'Unauthorized' });
Expand Down

0 comments on commit 4ccab80

Please sign in to comment.