From c8da895ba42a8dd20b072118652139670325d5ad Mon Sep 17 00:00:00 2001 From: baraganio Date: Mon, 22 Apr 2024 14:25:45 +0200 Subject: [PATCH 1/3] Test por defecto (se crea pero no comrpueba nada) --- .../creationservice/creation-service.test.js | 25 +++++++++++++++++++ .../retrieveservice/retrieve-service.test.js | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/questions/creationservice/creation-service.test.js b/questions/creationservice/creation-service.test.js index e69de29b..f59cf619 100644 --- a/questions/creationservice/creation-service.test.js +++ b/questions/creationservice/creation-service.test.js @@ -0,0 +1,25 @@ +const request = require('supertest'); +const { MongoMemoryServer } = require('mongodb-memory-server'); + +let mongoServer; +let app; + +beforeAll(async () => { + mongoServer = await MongoMemoryServer.create(); + const mongoUri = mongoServer.getUri(); + process.env.MONGODB_URI = mongoUri; + app = require('./createquestion-service'); +}); + +afterAll(async () => { + app.close(); + await mongoServer.stop(); +}); + +describe('Retrieve Service', () => { + it('should add a new user on GET /createquestion', async () => { + + const response = await request(app).get('/createquestion'); + expect(response.status).toBe(200); + }); +}); \ No newline at end of file diff --git a/questions/retrieveservice/retrieve-service.test.js b/questions/retrieveservice/retrieve-service.test.js index e69de29b..74bbccab 100644 --- a/questions/retrieveservice/retrieve-service.test.js +++ b/questions/retrieveservice/retrieve-service.test.js @@ -0,0 +1,25 @@ +const request = require('supertest'); +const { MongoMemoryServer } = require('mongodb-memory-server'); + +let mongoServer; +let app; + +beforeAll(async () => { + mongoServer = await MongoMemoryServer.create(); + const mongoUri = mongoServer.getUri(); + process.env.MONGODB_URI = mongoUri; + app = require('./retrieve-service'); +}); + +afterAll(async () => { + app.close(); + await mongoServer.stop(); +}); + +describe('Retrieve Service', () => { + it('should add a new user on GET /getquestionshistory', async () => { + + const response = await request(app).get('/getquestionshistory'); + expect(response.status).toBe(200); + }); +}); \ No newline at end of file From ea0daa44902f6c679a4a2f3564e9132a4a45383c Mon Sep 17 00:00:00 2001 From: baraganio Date: Mon, 22 Apr 2024 14:30:23 +0200 Subject: [PATCH 2/3] Cambiadno un import mal escrito --- questions/creationservice/creation-service.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/questions/creationservice/creation-service.test.js b/questions/creationservice/creation-service.test.js index f59cf619..17b67e37 100644 --- a/questions/creationservice/creation-service.test.js +++ b/questions/creationservice/creation-service.test.js @@ -8,7 +8,7 @@ beforeAll(async () => { mongoServer = await MongoMemoryServer.create(); const mongoUri = mongoServer.getUri(); process.env.MONGODB_URI = mongoUri; - app = require('./createquestion-service'); + app = require('./creation-service'); }); afterAll(async () => { From 392bf3d76a95d32a823cb8673537f1d653629033 Mon Sep 17 00:00:00 2001 From: baraganio Date: Mon, 22 Apr 2024 14:37:43 +0200 Subject: [PATCH 3/3] Arreglando fallo test mainpage --- webapp/src/components/MainPage.test.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/webapp/src/components/MainPage.test.js b/webapp/src/components/MainPage.test.js index 68dc9eca..ec268dc4 100644 --- a/webapp/src/components/MainPage.test.js +++ b/webapp/src/components/MainPage.test.js @@ -21,9 +21,6 @@ describe('MainPage component', () => { const element1 = screen.getByText(/¡Bienvenido a/); const element2 = screen.getByText(/WIQ 2024!/); const newGameButton = screen.getByRole('button', { name: 'Nuevo juego' }); - const historicalQuestionsButton = screen.getByRole('button', { name: 'Historial de preguntas' }); - const historialUserDataButton = screen.getByRole('button', { name: 'Historial de usuario' }); - const registerUsersButton = screen.getByRole('button', { name: 'Usuarios registrados' }); // Verifica si el elemento se encuentra en el DOM expect(element1).toBeInTheDocument(); @@ -32,9 +29,6 @@ describe('MainPage component', () => { // Simulate user input await act(async () => { fireEvent.click(newGameButton); - fireEvent.click(historicalQuestionsButton); - fireEvent.click(historialUserDataButton); - fireEvent.click(registerUsersButton); }); }); });