From 19345650c95cfb643d27177194737c7ff48eca90 Mon Sep 17 00:00:00 2001 From: uo289689 Date: Sun, 28 Apr 2024 21:23:01 +0200 Subject: [PATCH 1/2] Fixing errors --- webapp/e2e/steps/theCallange.steps.js | 22 +++------------------- webapp/src/pages/Statistics.js | 10 +++++----- webapp/src/pages/games/TheChallengeGame.js | 2 +- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/webapp/e2e/steps/theCallange.steps.js b/webapp/e2e/steps/theCallange.steps.js index 8b3d7d59..609fd412 100644 --- a/webapp/e2e/steps/theCallange.steps.js +++ b/webapp/e2e/steps/theCallange.steps.js @@ -86,15 +86,7 @@ defineFeature(feature, test => { }); then('The button turns green', async () => { - /*const answerButton = await page.$x('(//*[@data-testid="answer"])[1]'); - const textoBoton1 = await page.evaluate(button => button.innerText, answerButton[0]); - const textoBoton2 = await page.evaluate(button => button.innerText, answerButton[1]); - if(textoBoton1 === "Madrid") { - await expect(textoBoton1).toMatch(/Madrid/i); - } else { - await expect(textoBoton2).toMatch(/Madrid/i); - }*/ - await expect(page).toMatchElement("button", { style: { color: 'green' } }); + await expect(page).toMatchElement("button", { style: { color: 'rgb(51, 153, 102);' } }); }); }) @@ -119,16 +111,8 @@ defineFeature(feature, test => { }); then('The button turns red', async () => { - /*const answerButton = await page.$x('(//*[@data-testid="answer"])[2]'); - const textoBoton1 = await page.evaluate(button => button.innerText, answerButton[0]); - const textoBoton2 = await page.evaluate(button => button.innerText, answerButton[1]); - if(textoBoton1 !== "Madrid") { - await expect(textoBoton1).not.toMatch(/Madrid/i); - } else { - await expect(textoBoton2).toMatch(/Madrid/i); - }*/ - await expect(page).toMatchElement("button", { style: { color: 'red' } }); - await expect(page).toMatchElement("button", { style: { color: 'green' } }); + await expect(page).toMatchElement("button", { style: { color: 'rgb(153, 0, 0);' } }); + await expect(page).toMatchElement("button", { style: { color: 'rgb(51, 153, 102);' } }); }); }) diff --git a/webapp/src/pages/Statistics.js b/webapp/src/pages/Statistics.js index 83b6b14c..c9d24380 100644 --- a/webapp/src/pages/Statistics.js +++ b/webapp/src/pages/Statistics.js @@ -41,8 +41,8 @@ const Statistics = () => { useEffect(() => { const fetchQuestionsRecord = async () => { try { - const response = await axios.get(`${apiEndpoint}/questionsRecord/${username}/${selectedMode}`, { - username: username, + const response = await axios.get(`${apiEndpoint}/questionsRecord/${user}/${selectedMode}`, { + username: user, gameMode: selectedMode }); setQuestionsRecord(response.data); @@ -236,14 +236,14 @@ const Statistics = () => { - {question.correctAnswer === question.response ? : } + {question.correctAnswer === question.response ? : } {question.question} {question.options.map((option, optionIndex) => ( { diff --git a/webapp/src/pages/games/TheChallengeGame.js b/webapp/src/pages/games/TheChallengeGame.js index d9c9c440..5397347f 100644 --- a/webapp/src/pages/games/TheChallengeGame.js +++ b/webapp/src/pages/games/TheChallengeGame.js @@ -381,7 +381,7 @@ const TheChallengeGame = () => { From f8eec9b430224b95758276d16418532e0882d249 Mon Sep 17 00:00:00 2001 From: uo289689 Date: Sun, 28 Apr 2024 21:31:11 +0200 Subject: [PATCH 2/2] Fixed error --- webapp/src/pages/Statistics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/pages/Statistics.js b/webapp/src/pages/Statistics.js index c9d24380..632e5202 100644 --- a/webapp/src/pages/Statistics.js +++ b/webapp/src/pages/Statistics.js @@ -52,7 +52,7 @@ const Statistics = () => { }; fetchQuestionsRecord(); - }, [username, selectedMode]); + }, [user, selectedMode]); const totalPages = Math.ceil(questionsRecord.length / itemsPerPage);