From 04c9619394f7fcf7072d4087320ad5ab1aa63f31 Mon Sep 17 00:00:00 2001 From: Mister-Mario Date: Sun, 28 Apr 2024 02:54:38 +0200 Subject: [PATCH 1/2] Small tweaks --- .../ForgetPassword/RestorePassword.js | 2 +- .../components/ranking/RankingRetriever.js | 63 ------------------- 2 files changed, 1 insertion(+), 64 deletions(-) diff --git a/webapp/src/components/ForgetPassword/RestorePassword.js b/webapp/src/components/ForgetPassword/RestorePassword.js index 1ac505e..1516b65 100644 --- a/webapp/src/components/ForgetPassword/RestorePassword.js +++ b/webapp/src/components/ForgetPassword/RestorePassword.js @@ -48,7 +48,7 @@ export default function RestorePassword({
{t(passwordStrengthText)}
diff --git a/webapp/src/components/ranking/RankingRetriever.js b/webapp/src/components/ranking/RankingRetriever.js index 03ebcd6..bcbd81c 100644 --- a/webapp/src/components/ranking/RankingRetriever.js +++ b/webapp/src/components/ranking/RankingRetriever.js @@ -14,65 +14,9 @@ class RankingRetriever{ const receivedTopTenRanking = await response.data; return receivedTopTenRanking; } catch (error) { - console.log(error) throw new Error(error); } - /* - return { - "usersCompetitiveStats": [ - { - "_id": "user", - "totalPoints": 1000, - "totalCompetitiveGames": 4 - }, - { - "_id": "user2", - "totalPoints": 900, - "totalCompetitiveGames": 2 - }, - { - "_id": "user3", - "totalPoints": 800, - "totalCompetitiveGames": 3 - }, - { - "_id": "user4", - "totalPoints": 700, - "totalCompetitiveGames": 5 - }, - { - "_id": "user5", - "totalPoints": 600, - "totalCompetitiveGames": 6 - }, - { - "_id": "user6", - "totalPoints": 500, - "totalCompetitiveGames": 7 - }, - { - "_id": "user7", - "totalPoints": 400, - "totalCompetitiveGames": 8 - }, - { - "_id": "user8", - "totalPoints": 300, - "totalCompetitiveGames": 9 - }, - { - "_id": "user9", - "totalPoints": 200, - "totalCompetitiveGames": 10 - }, - { - "_id": "user10", - "totalPoints": 100, - "totalCompetitiveGames": 11 - } - ] - }*/ } async getUser(user, token){ @@ -81,16 +25,9 @@ class RankingRetriever{ const receivedMyRanking = await response.data; return receivedMyRanking.userCompetitiveStats; } catch (error) { - console.log(error) throw new Error(error); } - /* - return { - "_id": "myUser", - "totalPoints": 250, - "totalCompetitiveGames": 1 - };*/ } From 7ff4147954d9147c1b16db77fd9d7df93d7fbe97 Mon Sep 17 00:00:00 2001 From: Mister-Mario Date: Sun, 28 Apr 2024 02:59:30 +0200 Subject: [PATCH 2/2] Added tests for the randomize button --- .../GameConfigurator/GameConfigurator.test.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/webapp/src/components/GameConfigurator/GameConfigurator.test.js b/webapp/src/components/GameConfigurator/GameConfigurator.test.js index 273b93c..5fc45be 100644 --- a/webapp/src/components/GameConfigurator/GameConfigurator.test.js +++ b/webapp/src/components/GameConfigurator/GameConfigurator.test.js @@ -48,4 +48,25 @@ it('renders option to play Competitive game', () => { expect(text).toBeInTheDocument(); }); +it('should set random values for type and number of questions when randomize button is clicked', () => { + const { getByText, getByRole } = render(); + + // Encuentra el botón de randomize + const randomizeButton = getByText('gameConfigurator.randomize'); + + // Simula el clic en el botón de randomize + fireEvent.click(randomizeButton); + + // Verifica que el tipo de pregunta sea uno de los valores esperados + const select = getByRole('combobox'); // Localiza el campo de selección + const validOptions = ['ALL', 'POPULATION', 'CAPITAL', 'LANGUAGE', 'SIZE', 'HEAD_OF_GOVERMENT']; + expect(validOptions).toContain(select.value); // Verifica que el valor esté en las opciones válidas + + // Verifica que el número de preguntas esté entre 1 y 20 + const numberInput = getByRole('spinbutton'); // Localiza el spinner + const numQuestions = parseInt(numberInput.value, 10); + expect(numQuestions).toBeGreaterThanOrEqual(1); + expect(numQuestions).toBeLessThanOrEqual(20); +}); + });