Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #420

Merged
merged 84 commits into from
Apr 29, 2024
Merged

Dev #420

Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
e77cd55
Mejorando coverage componentes
uo287627 Apr 25, 2024
4451c05
Quito unused import
uo287627 Apr 25, 2024
0ac9dd0
Corrección nombre setError en componentes
uo287627 Apr 25, 2024
c97d2e0
Casos negativos modificados
uo287627 Apr 25, 2024
364a94d
Corregido casos negativos
uo287627 Apr 25, 2024
376a471
Corrigiendo caso negativo de test UserList y RankingList
uo287627 Apr 25, 2024
28d9c62
Corrigiendo formato cadena esperada
uo287627 Apr 25, 2024
a462625
Detalle menor
uo287627 Apr 25, 2024
1f8ff36
Merge remote-tracking branch 'origin/dev' into sergio
uo287627 Apr 26, 2024
6f86804
Mejorando tests Login
uo287627 Apr 26, 2024
cfedb0e
Añado configuración mockAxios
uo287627 Apr 26, 2024
2e8cb94
Faltaba importar "act"
uo287627 Apr 26, 2024
b41f1a9
Faltaba import "fireEvent"
uo287627 Apr 26, 2024
b282b61
Faltaba un import y colocar un "act"
uo287627 Apr 26, 2024
12acc97
Corregido prop de Login
uo287627 Apr 26, 2024
9144565
Reorganizando pruebas
uo287627 Apr 26, 2024
dc53960
Intento corregir test
uo287627 Apr 26, 2024
24bfe8b
Corrijo test
uo287627 Apr 26, 2024
39828ce
Cambio test login
uo287627 Apr 26, 2024
dfd7dd1
Probando tests
uo287627 Apr 26, 2024
0ae5f39
Probando
uo287627 Apr 26, 2024
832457f
Merge pull request #415 from Arquisoft/laura
uo277310 Apr 26, 2024
4d21180
Merge pull request #417 from Arquisoft/laura
uo277310 Apr 27, 2024
5cca184
Merge remote-tracking branch 'origin/dev' into sergio
uo287627 Apr 28, 2024
833f88c
Intentando corregir test login
uo287627 Apr 28, 2024
fdbff7b
Comprobando presencia elementos en login
uo287627 Apr 28, 2024
2c1cc4f
Comprobando si está saltando un error
uo287627 Apr 28, 2024
8f57012
Corrigiendo fallo retorno mockAxios en Login Test
uo287627 Apr 28, 2024
ac55f14
Depurando error inesperado
uo287627 Apr 28, 2024
72aa54a
Corrigiendo formato respuesta
uo287627 Apr 28, 2024
1953410
Formateando respuesta /login
uo287627 Apr 28, 2024
c093ad3
Más formateo
uo287627 Apr 28, 2024
efdf813
Probando
uo287627 Apr 28, 2024
7ba0c8d
Intento corregir
uo287627 Apr 28, 2024
10cb0f0
Sigo
uo287627 Apr 28, 2024
6bfc46f
Depuracion
uo287627 Apr 28, 2024
03c056a
Más depuración
uo287627 Apr 28, 2024
2c38508
Sigo intentándolo
uo287627 Apr 28, 2024
cd9c15b
Intento corregir
uo287627 Apr 28, 2024
6c1b214
Sigo
uo287627 Apr 28, 2024
ab71fca
Otra forma de hacer mock
uo287627 Apr 28, 2024
f455726
Pruebas
uo287627 Apr 28, 2024
8b8809e
Sigo probando
uo287627 Apr 28, 2024
1649f96
probando
uo287627 Apr 28, 2024
d469ebc
Más intentos
uo287627 Apr 28, 2024
d024293
Otro intento
uo287627 Apr 28, 2024
b6b0183
Creo que ya está
uo287627 Apr 28, 2024
121c673
Corregidos detalles menores Login.test.js
uo287627 Apr 28, 2024
d074528
Ya está
uo287627 Apr 28, 2024
5e9363a
Correcciones menores
uo287627 Apr 28, 2024
a048301
Último detalle
uo287627 Apr 28, 2024
ed73462
Ahora sí
uo287627 Apr 28, 2024
bc79039
Ampliando tests Login
uo287627 Apr 28, 2024
9978b6c
Refactorizando código
uo287627 Apr 28, 2024
bc8290d
Sigo refactorizando
uo287627 Apr 28, 2024
50c7c9a
Refactorizando más
uo287627 Apr 28, 2024
174c293
Error ínfimo
uo287627 Apr 28, 2024
50b2d30
Refactorizando más
uo287627 Apr 28, 2024
f815e39
Corrigiendo una función auxiliar
uo287627 Apr 28, 2024
40edf3e
Intento arreglar nuevas issues
uo287627 Apr 28, 2024
afb4913
Imports que faltaban
uo287627 Apr 28, 2024
7f37703
Sigo reparando las issues
uo287627 Apr 28, 2024
9de0abd
Corrigiendo las props
uo287627 Apr 28, 2024
c9d7146
Corrigiendo fallo
uo287627 Apr 28, 2024
8bc47b8
Terminando de corregir los tests
uo287627 Apr 28, 2024
3bdbe84
faltaban comillas
uo287627 Apr 28, 2024
525cf5c
Detalle selección encabezados tabs despues de login
uo287627 Apr 28, 2024
69b1053
Definitivo
uo287627 Apr 28, 2024
49ba828
Intentando refactorizar codigo
uo287627 Apr 28, 2024
cf622cf
Faltaba definir la variable, la pongo directamente
uo287627 Apr 28, 2024
35e7349
Vuelta a como estaba antes
uo287627 Apr 28, 2024
7e185db
Se me coló este detalle
uo287627 Apr 28, 2024
edaefe9
Resolviendo issues
uo287627 Apr 28, 2024
dec55fd
A ver si esta solución sirve
uo287627 Apr 28, 2024
df27148
Subiendo coverage del nuevo código
uo287627 Apr 28, 2024
7452a5c
Faltaba renderizarlo
uo287627 Apr 28, 2024
369e714
Añadida asincronía
uo287627 Apr 28, 2024
306096f
Faltaba un import
uo287627 Apr 28, 2024
7cd0e81
Corregidas comillas
uo287627 Apr 28, 2024
b1d8927
Acabando
uo287627 Apr 28, 2024
5f773c4
errata
uo287627 Apr 28, 2024
39dc4be
Detalle
uo287627 Apr 28, 2024
5c739c3
Conflicto nombres
uo287627 Apr 28, 2024
c7bdd4e
Merge pull request #414 from Arquisoft/sergio
uo277310 Apr 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ampliando tests Login
uo287627 committed Apr 28, 2024
commit bc790399b1d2985e96995d7caafb8d1e1cffa1a0
4 changes: 2 additions & 2 deletions webapp/src/components/Login.js
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@ const Login = ({ setLogged }) => {
setLogged();
setLoading(true);

// Envía todos los nombres de usuario en una sola solicitud
await axios.post(`${apiEndpoint}/createUserRank`, { username });
// Envía todos los nombres de usuario en una sola solicitud
await axios.post(`${apiEndpoint}/createUserRank`, { username });

setLoading(false);
setOpenSnackbar(true);
71 changes: 69 additions & 2 deletions webapp/src/components/Login.test.js
Original file line number Diff line number Diff line change
@@ -127,6 +127,73 @@ describe('Login Component', () => {
});
});

describe('sucessful login cases trying to access to: userList, questionList, recordList, rankingList, settings', () => {
beforeEach(async () => {
const setLogged = jest.fn();

// Mock para la petición POST de login exitosa
axios.post.mockResolvedValueOnce({
data: {
createdAt: new Date().toISOString()
}
});

// Mock para la petición GET de obtener todos los usuarios
axios.get.mockResolvedValueOnce({
data: [] // Puedes ajustar esto según lo que necesites en tu test
});

// Mock para la petición POST de createUserRank exitosa
axios.post.mockResolvedValueOnce({
data: {} // Puedes ajustar esto según lo que necesites en tu test
});

await act(async () => {
render(<Login setLogged={setLogged}/>);
});

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const loginButton = screen.getByRole('button', { name: /Iniciar sesión/i });

await act(async () => {
fireEvent.change(usernameInput, { target: { value: 'admin' } });
fireEvent.change(passwordInput, { target: { value: 'testPassword' } });

fireEvent.click(loginButton);
});
});

test('from login try to access to usersList', async () => {
const usersListTab = screen.getByText(/Historial de Usuarios/i);
await act(async () => {
fireEvent.click(usersListTab);
});
await waitFor(() => {
expect(screen.getByText(/Nombre de Usuario/i)).toBeInTheDocument();
expect(screen.getByText(/Fecha de Registro/i)).toBeInTheDocument();
});
});
/*
test('from login try to access to generatedQuestionsList', async () => {

});

test('from login try to access to recordList', async () => {

});

test('from login try to access to rankingList', async () => {

});

test('from login try to access to gameSettings', async () => {

});
*/
});


test('login fails on post /login and error is handled ', async () => {
const setLogged = jest.fn();

@@ -224,8 +291,8 @@ describe('Login Component', () => {

await waitFor(() => {
expect(setLogged).toHaveBeenCalled(); // se ha loggeado pero no se ha creado el ranking del usuario
expect(screen.getByText(/Internal Server Error/i)).toBeInTheDocument();
expect(screen.queryByText(/Comenzar a jugar/i)).not.toBeInTheDocument();
expect(screen.getByText(/Espere, estamos cargando sus datos.../i)).toBeInTheDocument(); // se queda esperando cargando
expect(screen.queryByText(/Comenzar a jugar/i)).not.toBeInTheDocument(); // no te deja jugar
});
});
});