generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from Arquisoft/front-end-lucia
Front end lucia
- Loading branch information
Showing
10 changed files
with
231 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
webapp/src/components/HistoricalData/HistoricalView.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { initReactI18next } from 'react-i18next'; | ||
import i18en from 'i18next'; | ||
|
||
i18en.use(initReactI18next).init({ | ||
resources: {}, | ||
lng: 'en', | ||
interpolation:{ | ||
escapeValue: false, | ||
} | ||
}); | ||
global.i18en = i18en; | ||
|
||
describe('Historical View component', () => { | ||
it('renders Game Record Buttons', () => { | ||
/*render(<MemoryRouter><GameMenu /></MemoryRouter>); | ||
const text = screen.getByText(i18en.t('gameMenu.title')); | ||
expect(text).toBeInTheDocument();*/ | ||
}); | ||
it('clicking Game Record Buttons Record Lists are displayed', () => { | ||
/*render(<MemoryRouter><GameMenu /></MemoryRouter>); | ||
const text = screen.getByText(i18en.t('gameMenu.title')); | ||
expect(text).toBeInTheDocument();*/ | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export default function RecordList({record}){ | ||
return ( | ||
<> | ||
{record.questions.map((question, index) => ( | ||
<li key={index}> | ||
<p>{question.question}</p> | ||
<ul> | ||
{question.answers.map((answer, answerIndex) => ( | ||
<li key={answerIndex}> | ||
{answer} | ||
{question.answerGiven === answer && " 👈 "} | ||
{question.correctAnswer === answer && " ✅ "} | ||
</li> | ||
))} | ||
</ul> | ||
</li> | ||
))} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { render, screen ,fireEvent } from '@testing-library/react'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import i18en from 'i18next'; | ||
import QuestionView from './QuestionView'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { act } from 'react-dom/test-utils'; | ||
import {queryHelpers, buildQueries} from '@testing-library/react' | ||
|
||
jest.mock('./QuestionGenerator', () => require('./mocks/QuestionGenerator')); | ||
|
||
i18en.use(initReactI18next).init({ | ||
resources: {}, | ||
lng: 'en', | ||
interpolation:{ | ||
escapeValue: false, | ||
} | ||
}); | ||
global.i18en = i18en; | ||
|
||
describe('Question View component', () => { | ||
it('renders a question',async () => { | ||
act(() => { | ||
render(<MemoryRouter><QuestionView /></MemoryRouter>); | ||
|
||
}); | ||
const text = screen.getByText('Please Wait a bit...'); | ||
expect(text).toBeInTheDocument(); | ||
|
||
// Wait for questions to load | ||
await waitFor(() => expect(getByText('Mocked Question 1')).toBeInTheDocument()); | ||
const tituloH2 = screen.getByRole('heading', { level: 2 }); | ||
expect(tituloH2).toBeInTheDocument(); | ||
}); | ||
/* | ||
it('renders a question',async () => { | ||
act(() => { | ||
const { getByText } = render(<MemoryRouter><QuestionView /></MemoryRouter>); | ||
}); | ||
//h2 con la pregunta | ||
const tituloH2 = screen.getByRole('heading', { level: 2 }); | ||
// Verifica si el elemento h2 está presente en el documento | ||
expect(tituloH2).toBeInTheDocument(); | ||
});*/ | ||
/* | ||
it('render a question and 4 buttons for answers', () => { | ||
act(() => { | ||
render(<MemoryRouter><QuestionView /></MemoryRouter>); | ||
}); | ||
// Busca todos los botones por su rol | ||
const botones = screen.getAllByRole('button'); | ||
// Verifica si hay exactamente 4 botones | ||
expect(botones.length).toBe(4); | ||
}); | ||
it('shows colors to reveal correct answer', () => { | ||
act(() => { | ||
render(<MemoryRouter><QuestionView /></MemoryRouter>); | ||
fireEvent.click(queryHelpers.queryByAttribute('data-value', 'true'));//clicamos en la respuesta correcta | ||
}); | ||
// Clic en un botón de respuesta con data-value=true | ||
const correctAnswerButton = queryHelpers.queryByAttribute('data-value', 'true'); | ||
// Verificar que el botón tenga el color esperado | ||
expect(correctAnswerButton).toHaveStyle('background-color: #6EF26E'); | ||
}); | ||
it('shows colors to reveal false answer', () => { | ||
act(() => { | ||
render(<MemoryRouter><QuestionView /></MemoryRouter>); | ||
const falseAnswerButtons = (dataValue)=> queryHelpers.queryAllByAttribute('data-value', dataValue)('false'); | ||
fireEvent.click(falseAnswerButtons.get(0)); | ||
}); | ||
// Obtener el botón de respuesta falso por su atributo data-value | ||
const falseAnswerButton = queryHelpers.queryAllByAttribute('data-value', 'false').get(0); | ||
// Verificar que el botón tenga el color esperado | ||
expect(falseAnswerButton).toHaveStyle('background-color:#FF6666'); | ||
});*/ | ||
}); |
20 changes: 20 additions & 0 deletions
20
webapp/src/components/questionView/mocks/QuestionGenerator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export default class QuestionGenerator { | ||
async generateQuestions() { | ||
return [ | ||
{ | ||
getQuestion: () => 'Mocked Question 1', | ||
getAnswers: () => ['Mocked Answer 1', 'Mocked Answer 2','Mocked Answer 3', 'Mocked Answer 4'], | ||
getCorrectAnswer: () => 'Mocked Answer 1' | ||
}, | ||
{ | ||
getQuestion: () => 'Mocked Question 2', | ||
getAnswers: () => ['Mocked Answer 1', 'Mocked Answer 2','Mocked Answer 3', 'Mocked Answer 4'], | ||
getCorrectAnswer: () => 'Mocked Answer 4' | ||
},{ | ||
getQuestion: () => 'Mocked Question 3', | ||
getAnswers: () => ['Mocked Answer 1', 'Mocked Answer 2','Mocked Answer 3', 'Mocked Answer 4'], | ||
getCorrectAnswer: () => 'Mocked Answer 2' | ||
} | ||
]; | ||
} | ||
} |
Oops, something went wrong.