diff --git a/webapp/src/components/GeneratedQuestionsList.js b/webapp/src/components/GeneratedQuestionsList.js index 9d0d6322..68ee5d0c 100644 --- a/webapp/src/components/GeneratedQuestionsList.js +++ b/webapp/src/components/GeneratedQuestionsList.js @@ -76,4 +76,8 @@ const GeneratedQuestionsList = ({setError}) => { ); }; +GeneratedQuestionsList.propTypes = { + setError: PropTypes.func.isRequired, +}; + export default GeneratedQuestionsList; diff --git a/webapp/src/components/Login.test.js b/webapp/src/components/Login.test.js index 6d789bf6..22213ee9 100644 --- a/webapp/src/components/Login.test.js +++ b/webapp/src/components/Login.test.js @@ -123,11 +123,9 @@ describe('Login Component', () => { fireEvent.click(usersListTab); }); - await waitFor(() => { - tabTexts.forEach(async (tabText) => { - const elements = await screen.findAllByText(new RegExp(tabText, 'i')); - expect(elements.length).toBeGreaterThan(0); - }); + await waitFor(async () => { + await Promise.all(tabTexts.map(tabText => screen.findAllByText(new RegExp(tabText, 'i')))) + .then(elementsArray => elementsArray.forEach(elements => expect(elements.length).toBeGreaterThan(0))); }); } diff --git a/webapp/src/components/RankingList.js b/webapp/src/components/RankingList.js index 299f5852..1db8d890 100644 --- a/webapp/src/components/RankingList.js +++ b/webapp/src/components/RankingList.js @@ -99,4 +99,9 @@ const RankingList = ({setError}) => { ); }; + +RankingList.propTypes = { + setError: PropTypes.func.isRequired, +}; + export default RankingList; diff --git a/webapp/src/components/RankingList.test.js b/webapp/src/components/RankingList.test.js index e0260cfa..8c7e6b9a 100644 --- a/webapp/src/components/RankingList.test.js +++ b/webapp/src/components/RankingList.test.js @@ -292,31 +292,28 @@ describe('RankingList', () => { }); // fin tests correctos - describe('failing requests', () => { - test('should display an error message when the request fails', async () => { - let errorShown = ""; - await act(async () => { - render( {errorShown=errorMsg}} />); - }); + test('should display an error message when the request fails', async () => { + let errorShown = ""; + await act(async () => { + render( {errorShown=errorMsg}} />); + }); - // simulate a failed request - mockAxios.onPost('http://localhost:8000/obtainRank').reply(500, { error: 'Internal Server Error' }); + // simulate a failed request + mockAxios.onPost('http://localhost:8000/obtainRank').reply(500, { error: 'Internal Server Error' }); - // Check if the table headers are in the document - expect(screen.queryByText("Ranking")).toBeInTheDocument(); - expect(screen.getByText(/Nombre de Usuario/i)).toBeInTheDocument(); - expect(screen.queryAllByText(/Porcentaje de Aciertos/i)).not.toHaveLength(0); - expect(screen.getByText(/Preguntas Correctas/i)).toBeInTheDocument(); - expect(screen.getByText(/Preguntas Falladas/i)).toBeInTheDocument(); - expect(screen.getByText(/Número de Partidas/i)).toBeInTheDocument(); + // Check if the table headers are in the document + expect(screen.queryByText("Ranking")).toBeInTheDocument(); + expect(screen.getByText(/Nombre de Usuario/i)).toBeInTheDocument(); + expect(screen.queryAllByText(/Porcentaje de Aciertos/i)).not.toHaveLength(0); + expect(screen.getByText(/Preguntas Correctas/i)).toBeInTheDocument(); + expect(screen.getByText(/Preguntas Falladas/i)).toBeInTheDocument(); + expect(screen.getByText(/Número de Partidas/i)).toBeInTheDocument(); - // and no users rows are shown - const rows = await screen.findAllByRole('row'); - expect(rows.length).toBe(1); - - expect(errorShown).toBe("Error obteniendo el ranking del usuario: TypeError: Cannot read properties of undefined (reading 'status')"); - }); + // and no users rows are shown + const rows = await screen.findAllByRole('row'); + expect(rows.length).toBe(1); - }); // fin tests fallidos + expect(errorShown).toBe("Error obteniendo el ranking del usuario: TypeError: Cannot read properties of undefined (reading 'status')"); + }); }); diff --git a/webapp/src/components/UsersList.js b/webapp/src/components/UsersList.js index fac64076..446e04dc 100644 --- a/webapp/src/components/UsersList.js +++ b/webapp/src/components/UsersList.js @@ -80,4 +80,8 @@ const UsersList = ({ setError }) => { ); }; +UsersList.propTypes = { + setError: PropTypes.func.isRequired, +}; + export default UsersList; \ No newline at end of file