diff --git a/webapp/src/components/HistoricalData.js b/webapp/src/components/HistoricalData.js index c07669f0..6045c211 100644 --- a/webapp/src/components/HistoricalData.js +++ b/webapp/src/components/HistoricalData.js @@ -62,13 +62,22 @@ const HistoricalData = () => { - {paginatedData.map((row, rowIndex) => ( + {/* {paginatedData.map((row, rowIndex) => ( {row.map((cell, cellIndex) => ( {cell} ))} - ))} + ))} */} + {paginatedData.map((row, rowIndex) => ( + + {row[0]} + {row[1]} + {row[2]} + {row[3]} + {row[4]} + + ))} diff --git a/webapp/src/components/HistoricalData.test.js b/webapp/src/components/HistoricalData.test.js new file mode 100644 index 00000000..d5fdf64d --- /dev/null +++ b/webapp/src/components/HistoricalData.test.js @@ -0,0 +1,44 @@ +import React from 'react'; +import { render, screen, waitFor } from '@testing-library/react'; +import axios from 'axios'; +import MockAdapter from 'axios-mock-adapter'; +import HistoricalData from './HistoricalData'; +import { BrowserRouter as Router } from 'react-router-dom'; + +const mockAxios = new MockAdapter(axios); + +describe('HistoricalData component', () => { + beforeEach(() => { + mockAxios.reset(); + }); + + it('muestra la página con el histórico de preguntas generadas', async () => { + + const question1 = ['¿Cual es la capital de Venezuela?', 'Caracas', 'Doha', 'Barcelona', 'Nasáu']; + const question2 = ['¿Cual es la capital de Francia?', 'París', 'Londres', 'Madrid', 'Roma']; + const mockUsers = [question1, question2]; + mockAxios.onGet("http://localhost:8000/getquestionshistory").reply(200, mockUsers); + + render( + + ); + + await waitFor(() => { + + expect(screen.getByText('¿Cual es la capital de Venezuela?')).toBeInTheDocument(); + expect(screen.getByText('Caracas')).toBeInTheDocument(); + expect(screen.getByText('Doha')).toBeInTheDocument(); + expect(screen.getByText('Barcelona')).toBeInTheDocument(); + expect(screen.getByText('Nasáu')).toBeInTheDocument(); + + expect(screen.getByText('¿Cual es la capital de Francia?')).toBeInTheDocument(); + expect(screen.getByText('París')).toBeInTheDocument(); + expect(screen.getByText('Londres')).toBeInTheDocument(); + expect(screen.getByText('Madrid')).toBeInTheDocument(); + expect(screen.getByText('Roma')).toBeInTheDocument(); + + }); + }); +}); + + diff --git a/webapp/src/components/RegisteredUsers.js b/webapp/src/components/RegisteredUsers.js index ed4347da..bc2b6347 100644 --- a/webapp/src/components/RegisteredUsers.js +++ b/webapp/src/components/RegisteredUsers.js @@ -41,13 +41,20 @@ const RegisteredUsers = () => { - {registeredUsers.map((row, rowIndex) => ( + {/* {registeredUsers.map((row, rowIndex) => ( {row.map((cell, cellIndex) => ( {cell} ))} + ))} */} + {registeredUsers.map((row, rowIndex) => ( + + {row[0]} + {row[1]} + ))} + diff --git a/webapp/src/components/RegisteredUsers.test.js b/webapp/src/components/RegisteredUsers.test.js new file mode 100644 index 00000000..76e49bde --- /dev/null +++ b/webapp/src/components/RegisteredUsers.test.js @@ -0,0 +1,32 @@ +import React from 'react'; +import { render, screen, waitFor } from '@testing-library/react'; +import axios from 'axios'; +import MockAdapter from 'axios-mock-adapter'; +import {BrowserRouter as Router} from "react-router-dom"; +import RegisteredUsers from './RegisteredUsers'; + +const mockAxios = new MockAdapter(axios); + +describe('Registered Users component', () => { + beforeEach(() => { + mockAxios.reset(); + }); + + it('muestra todos los usuarios registrados', async () => { + const user1 = ['pablo', '4/23/2024']; + const mockUsers = [user1]; + mockAxios.onGet("http://localhost:8000/getregisteredusers").reply(200, mockUsers); + + render( + + + ); + + await waitFor(() => { + + expect(screen.getByText('pablo')).toBeInTheDocument(); + expect(screen.getByText('4/23/2024')).toBeInTheDocument(); + }); + + }); +}); \ No newline at end of file