From 347bd65e4b2e77b38a051bab03dac755885c19dc Mon Sep 17 00:00:00 2001 From: Liliana Date: Tue, 30 Apr 2024 12:54:48 +0200 Subject: [PATCH 01/14] extra validations to user registration --- webapp/src/components/AddUser.js | 2 ++ webapp/src/components/AddUser.test.js | 19 +++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/webapp/src/components/AddUser.js b/webapp/src/components/AddUser.js index 4c51c6e7..42cd2294 100644 --- a/webapp/src/components/AddUser.js +++ b/webapp/src/components/AddUser.js @@ -20,6 +20,8 @@ const AddUser = () => { const addUser = async () => { if (name.trim() === '' || surname.trim() === '' || username.trim() === '' || password.trim() === '' || confirmPassword.trim() === '') { setError('Todos los campos deben de estar rellenos.'); + } else if (password.length < 8){ + setError('Las contraseñas deben contener más de 8 caracteres.'); } else if(password !== confirmPassword){ setError('Las contraseñas no coinciden.'); } else { diff --git a/webapp/src/components/AddUser.test.js b/webapp/src/components/AddUser.test.js index a0e56e4e..d43e1ad2 100644 --- a/webapp/src/components/AddUser.test.js +++ b/webapp/src/components/AddUser.test.js @@ -28,24 +28,23 @@ describe('AddUser component', () => { fireEvent.change(nameInput, { target: { value: 'testUsera' } }); fireEvent.change(surnameInput, { target: { value: 'testUsera' } }); fireEvent.change(usernameInput, { target: { value: 'testUsera' } }); - fireEvent.change(passwordInput, { target: { value: 'testPassword' } }); - fireEvent.change(confirmPasswordInput, { target: { value: 'testPassword' } }); + fireEvent.change(passwordInput, { target: { value: 'testP' } }); + fireEvent.change(confirmPasswordInput, { target: { value: 'testP' } }); - // Trigger the add user button click + // Probamos a poner una contraseña corta fireEvent.click(addUserButton); - - // Wait for the Snackbar to be open await waitFor(() => { - expect(screen.getByText(/Usuario añadido correctamente/i)).toBeInTheDocument(); + expect(screen.getByText(/Las contraseñas deben contener más de 8 caracteres./i)).toBeInTheDocument(); }); - /* + //Modificamos la contraseña para que contenga al menos de 8 caracteres + fireEvent.change(passwordInput, { target: { value: 'testPassw' } }); + fireEvent.change(confirmPasswordInput, { target: { value: 'testPassw' } }); fireEvent.click(addUserButton); - // Wait for the Snackbar to be open await waitFor(() => { - expect(screen.getByText(/Usuario ya registrado./i)).toBeInTheDocument(); + expect(screen.getByText(/Usuario añadido correctamente/i)).toBeInTheDocument(); }); - */ + }); it('try to add user but not introduce name', async () => { From 858f3550974f6ba58024b120d253b8e0e97b9d61 Mon Sep 17 00:00:00 2001 From: Liliana Date: Tue, 30 Apr 2024 13:17:02 +0200 Subject: [PATCH 02/14] show info at the end of correct and incorrect questions (commented code to be displayed) --- webapp/src/components/game/Calculator.js | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/game/Calculator.js b/webapp/src/components/game/Calculator.js index 3b582cf5..745cab81 100644 --- a/webapp/src/components/game/Calculator.js +++ b/webapp/src/components/game/Calculator.js @@ -17,6 +17,10 @@ let answeredQuestions = []; let savedGame = false; +let numQuestionsCorrect = 0; +let numQuestionsIncorrect = 0; +let showInfoOfQuestions = false; + const Calculator = () => { //let questionIndex = -1 @@ -38,6 +42,9 @@ const Calculator = () => { setTotalTime(totalTime + progress/10) console.log("Despues", totalTime) + //showInfoOfQuestions = true; + //await esperar(5000); + gameStore(); return 0; @@ -127,7 +134,6 @@ const Calculator = () => { } - //CAMBIAR ESTO EN FUNCIÓN DE CÓMO QUERAMOS QUE SEA EL JUEGO const handleOptionClick = async (selectedAnswer) => { load = false; const numberAnswer = questions[questionIndex].options.indexOf(questions[questionIndex].correctAnswer); @@ -136,7 +142,6 @@ const Calculator = () => { console.log(numberAnswer) console.log(choiceNumber) - //console.log(numberAnswer) const botonCorrecta = document.getElementById('option-' + numberAnswer); let botonIncorrecta = null; botonCorrecta.style.backgroundColor = 'green'; @@ -145,10 +150,12 @@ const Calculator = () => { ansIndex: indexAnswers*/ storeQuestion(questions[questionIndex].q, questions[questionIndex].options, [choiceNumber, numberAnswer]); if (selectedAnswer !== questions[questionIndex].correctAnswer) { + numQuestionsIncorrect += 1; botonIncorrecta = document.getElementById('option-' + questions[questionIndex].options.indexOf(selectedAnswer)); botonIncorrecta.style.backgroundColor = 'red'; } else { points += 100; + numQuestionsCorrect += 1; } generateQuestion(); @@ -184,7 +191,6 @@ const Calculator = () => {
- {questions[questionIndex].q} @@ -203,6 +209,22 @@ const Calculator = () => { ) )}
+ + + +
+ + {showInfoOfQuestions? +
+ + Resultados + +

Número de preguntas correctas: {numQuestionsCorrect}

+

Número de preguntas incorrectas: {numQuestionsIncorrect}

+
: + <> + }; +
Date: Tue, 30 Apr 2024 13:40:48 +0200 Subject: [PATCH 03/14] updated help --- webapp/src/help/Help.jsx | 76 ++++++++++++++++++++++++------------ webapp/src/help/Help.test.js | 17 ++++---- 2 files changed, 61 insertions(+), 32 deletions(-) diff --git a/webapp/src/help/Help.jsx b/webapp/src/help/Help.jsx index d5930aa6..092aa333 100644 --- a/webapp/src/help/Help.jsx +++ b/webapp/src/help/Help.jsx @@ -2,33 +2,59 @@ import { Nav } from "../components/nav/Nav"; import { Footer } from "../components/footer/Footer"; function Help(){ - return (<> -