From ac5c2445ef84f3f651a654c5449a4bd0ef22574f Mon Sep 17 00:00:00 2001 From: Santiago21112001 Date: Mon, 29 Apr 2024 01:06:52 +0200 Subject: [PATCH 1/3] coverage wikiQuery --- questionservice/wikiUtils/wikiQuery.test.js | 33 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/questionservice/wikiUtils/wikiQuery.test.js b/questionservice/wikiUtils/wikiQuery.test.js index 6723b30..9c02ee1 100644 --- a/questionservice/wikiUtils/wikiQuery.test.js +++ b/questionservice/wikiUtils/wikiQuery.test.js @@ -20,7 +20,6 @@ describe("WikiQuery", () => { { questionLabel: { value: "¿Cuál es la capital de Francia?1" }, answerLabel: { value: "París1" } }, { questionLabel: { value: "¿Cuál es la capital de Francia?2" }, answerLabel: { value: "París2" } }, { questionLabel: { value: "¿Cuál es la capital de Francia?3" }, answerLabel: { value: "París3" } } - // Agrega más elementos según necesites para tu prueba ]; // Configurar wikiCall para retornar datos simulados @@ -53,6 +52,36 @@ describe("WikiQuery", () => { // Verifica que la cantidad de preguntas y sus formatos sean los esperados expect(questions).toHaveLength(mockResults.length); - + + }); + + it("debería obtener preguntas correctamente si la plantilla tiene year:true", async () => { + const mockResults = [ + { questionLabel: { value: "¿Cuándo terminó la guerra test1?" }, answerLabel: { value: "http1900" } }, + { questionLabel: { value: "¿Cuándo terminó la guerra test2?" }, answerLabel: { value: "1901" } }, + { questionLabel: { value: "¿Cuándo terminó la guerra test3?" }, answerLabel: { value: "1901" } }, + { questionLabel: { value: "¿Cuándo terminó la guerra test4?" }, answerLabel: { value: "1903" } } + ]; + wikiCall.mockResolvedValue(mockResults); + const template = { + questionVariable: "?q", + answerVariable: "?a", + question: "¿Cuándo terminó la guerra __x__?", + questionCategory: "Historia", + year: true + }; + const limitValue = 5; + const backupAnswers = [{itemLabel: "gato"}, {itemLabel: "gato2"}] + await WikiQuery.getQuestions(template, limitValue, backupAnswers); + expect(wikiCall).toHaveBeenCalledWith(expect.stringMatching(/SELECT DISTINCT\s+\?questionLabel\s+\(YEAR\(\?answer\) AS \?answerLabel\)\s+WHERE/gm)); + + }); + + it('should return a list of 100 objects with a property "itemLabel"', async () => { + const expectedResults = [{ itemLabel: 'Cat' }, { itemLabel: 'Dog' }, /* más resultados aquí */]; + wikiCall.mockResolvedValue(expectedResults); + const results = await WikiQuery.getBackupAnswers(); + expect(wikiCall).toHaveBeenCalledTimes(1); + expect(results).toEqual(expectedResults); }); }); From c6a04ff4e46850f85c6250dcbdb86d3cf25108e2 Mon Sep 17 00:00:00 2001 From: Zohaib Akhtar Kausar Date: Mon, 29 Apr 2024 01:22:35 +0200 Subject: [PATCH 2/3] Quitando codigo duplicado --- questionservice/wikiUtils/wikiQuery.test.js | 30 --------------------- 1 file changed, 30 deletions(-) diff --git a/questionservice/wikiUtils/wikiQuery.test.js b/questionservice/wikiUtils/wikiQuery.test.js index 9c02ee1..4d048fc 100644 --- a/questionservice/wikiUtils/wikiQuery.test.js +++ b/questionservice/wikiUtils/wikiQuery.test.js @@ -54,34 +54,4 @@ describe("WikiQuery", () => { expect(questions).toHaveLength(mockResults.length); }); - - it("debería obtener preguntas correctamente si la plantilla tiene year:true", async () => { - const mockResults = [ - { questionLabel: { value: "¿Cuándo terminó la guerra test1?" }, answerLabel: { value: "http1900" } }, - { questionLabel: { value: "¿Cuándo terminó la guerra test2?" }, answerLabel: { value: "1901" } }, - { questionLabel: { value: "¿Cuándo terminó la guerra test3?" }, answerLabel: { value: "1901" } }, - { questionLabel: { value: "¿Cuándo terminó la guerra test4?" }, answerLabel: { value: "1903" } } - ]; - wikiCall.mockResolvedValue(mockResults); - const template = { - questionVariable: "?q", - answerVariable: "?a", - question: "¿Cuándo terminó la guerra __x__?", - questionCategory: "Historia", - year: true - }; - const limitValue = 5; - const backupAnswers = [{itemLabel: "gato"}, {itemLabel: "gato2"}] - await WikiQuery.getQuestions(template, limitValue, backupAnswers); - expect(wikiCall).toHaveBeenCalledWith(expect.stringMatching(/SELECT DISTINCT\s+\?questionLabel\s+\(YEAR\(\?answer\) AS \?answerLabel\)\s+WHERE/gm)); - - }); - - it('should return a list of 100 objects with a property "itemLabel"', async () => { - const expectedResults = [{ itemLabel: 'Cat' }, { itemLabel: 'Dog' }, /* más resultados aquí */]; - wikiCall.mockResolvedValue(expectedResults); - const results = await WikiQuery.getBackupAnswers(); - expect(wikiCall).toHaveBeenCalledTimes(1); - expect(results).toEqual(expectedResults); - }); }); From 8fff131c474500ce86ea6268e635ea0588564bbf Mon Sep 17 00:00:00 2001 From: Zohaib Akhtar Kausar Date: Mon, 29 Apr 2024 01:43:08 +0200 Subject: [PATCH 3/3] =?UTF-8?q?A=C3=B1adido=20aboutUs=20a=20navbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/src/components/Navbar.css | 2 +- webapp/src/components/Navbar.js | 77 ++++++++++++++++------------ webapp/src/components/Navbar.test.js | 1 + 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/webapp/src/components/Navbar.css b/webapp/src/components/Navbar.css index 7e2a173..4d8dc9b 100644 --- a/webapp/src/components/Navbar.css +++ b/webapp/src/components/Navbar.css @@ -36,7 +36,7 @@ .nav-menu { display: grid; - grid-template-columns: repeat(6, auto); + grid-template-columns: repeat(8, auto); grid-gap: 10px; list-style: none; width: 60vw; diff --git a/webapp/src/components/Navbar.js b/webapp/src/components/Navbar.js index 041c195..b75c887 100644 --- a/webapp/src/components/Navbar.js +++ b/webapp/src/components/Navbar.js @@ -20,43 +20,52 @@ function Navbar() { }, []); const NavLinks = ({ isLoggedIn }) => ( -
    -
  • - Inicio -
  • - {isLoggedIn ? ( - <> -
  • - Jugar -
  • -
  • - Historial -
  • -
  • - Ranking -
  • -
  • - Salir -
  • - - ) : ( - <> -
  • - Registrarse -
  • -
  • - Entrar -
  • - - )} -
+
    +
  • + Inicio +
  • +
  • + About us +
  • + {isLoggedIn ? ( + <> +
  • + Jugar +
  • +
  • + Historial +
  • +
  • + Ranking +
  • +
  • + Salir +
  • + + ) : ( + <> +
  • + Registrarse +
  • +
  • + Entrar +
  • + + )} +
); return ( -