From 121977f79f50fd67f5d9e1001e92268e83b375fc Mon Sep 17 00:00:00 2001 From: UO289659 Date: Mon, 1 Apr 2024 10:42:51 +0200 Subject: [PATCH 1/2] Corregido error gateway --- gatewayservice/gateway-service.js | 6 +++++- webapp/src/components/Statistics.test.js | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 9a402c6c..6c552919 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -65,6 +65,10 @@ app.get('/statistics', async (req, res) => { const questionResponse = await axios.get(statisticssServiceUrl+'/statistics', { params: req.query, }); + } catch (error) { + res.status(error.response.status).json({ error: error.response.data.error }); + } + }); app.get('/questions', async (req, res) => { try { @@ -111,4 +115,4 @@ const server = app.listen(port, () => { console.log(`Gateway Service listening at http://localhost:${port}`); }); -module.exports = server +module.exports = server; diff --git a/webapp/src/components/Statistics.test.js b/webapp/src/components/Statistics.test.js index 46de694f..c93218e0 100644 --- a/webapp/src/components/Statistics.test.js +++ b/webapp/src/components/Statistics.test.js @@ -59,7 +59,6 @@ const dataRows = tableRows.slice(1); // Ignorar la primera fila que son los enca dataRows.forEach(row => { const cells = row.querySelectorAll('td'); // Obtener todas las celdas de la fila expect(cells.length).toBe(3); // Verificar que hay exactamente 3 celdas por fila - // Puedes hacer más verificaciones aquí si es necesario, por ejemplo: expect(cells[0]).toHaveTextContent('10'); // Verificar que la primera celda contiene el número de partidas jugadas expect(cells[1]).toHaveTextContent('7'); // Verificar que la segunda celda contiene el número de preguntas acertadas expect(cells[2]).toHaveTextContent('3'); // Verificar que la tercera celda contiene el número de preguntas falladas From ab6d02ccdcc6b6cb1a3b2d9eb5809c4072c1c149 Mon Sep 17 00:00:00 2001 From: UO289659 Date: Mon, 1 Apr 2024 17:07:32 +0200 Subject: [PATCH 2/2] Arreglo otro fallo gateway. --- gatewayservice/gateway-service.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 6c552919..45942814 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -65,10 +65,11 @@ app.get('/statistics', async (req, res) => { const questionResponse = await axios.get(statisticssServiceUrl+'/statistics', { params: req.query, }); - } catch (error) { - res.status(error.response.status).json({ error: error.response.data.error }); - } - }); + res.json(questionResponse.data); + } catch (error) { + res.status(error.response.status).json({ error: error.response.data.error }); + } +}); app.get('/questions', async (req, res) => { try {