Adding test to EditorQuiz

This commit is contained in:
Ana-Lucia Munteanu 2025-04-02 15:45:59 -04:00
parent 36d0755105
commit 9b8b0ad0ec
2 changed files with 22 additions and 0 deletions

View file

@ -60,3 +60,21 @@ describe('QuizForm Component', () => {
});
});
test('template-select is present', async () => {
render(
<MemoryRouter initialEntries={['/teacher/editor-quiz']}>
<QuizForm />
</MemoryRouter>
);
expect(screen.queryByText('Modèles de questions')).toBeInTheDocument();
const templateButton = screen.getByTestId('template-select');
fireEvent.mouseDown(templateButton);
await waitFor(() => {
const vraiFauxTemplate = screen.queryAllByText(/Vrai\/Faux/i);
expect(vraiFauxTemplate.length).toBeGreaterThan(0);
});
});

View file

@ -276,6 +276,10 @@ const QuizForm: React.FC = () => {
displayEmpty
onChange={(e) => handleSelectChange(e.target.value, templates.find(t => t.value === e.target.value)?.label || '')}
style={{ width: '210px' }}
inputProps={{
'data-testid': 'template-select'
}}
>
<MenuItem value="" disabled>Modèles de questions</MenuItem>
{templates.map((template, index) => (