mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Correction socket
This commit is contained in:
parent
c9b76df2cd
commit
9286fe6b9c
2 changed files with 20 additions and 10 deletions
|
|
@ -10,14 +10,15 @@ describe('StudentWaitPage Component', () => {
|
|||
{ id: '1', name: 'User1', answers: new Array<Answer>() },
|
||||
{ id: '2', name: 'User2', answers: new Array<Answer>() },
|
||||
{ id: '3', name: 'User3', answers: new Array<Answer>() },
|
||||
];
|
||||
];
|
||||
|
||||
const mockProps = {
|
||||
const mockProps = {
|
||||
students: mockUsers,
|
||||
launchQuiz: jest.fn(),
|
||||
roomName: 'Test Room',
|
||||
setQuizMode: jest.fn(),
|
||||
};
|
||||
setIsRoomSelectionVisible: jest.fn()
|
||||
};
|
||||
|
||||
test('renders StudentWaitPage with correct content', () => {
|
||||
render(<StudentWaitPage {...mockProps} />);
|
||||
|
|
@ -28,16 +29,15 @@ describe('StudentWaitPage Component', () => {
|
|||
expect(launchButton).toBeInTheDocument();
|
||||
|
||||
mockUsers.forEach((user) => {
|
||||
expect(screen.getByText(user.name)).toBeInTheDocument();
|
||||
expect(screen.getByText(user.name)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('clicking on "Lancer" button opens LaunchQuizDialog', () => {
|
||||
test('clicking on "Lancer" button opens LaunchQuizDialog', () => {
|
||||
render(<StudentWaitPage {...mockProps} />);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /Lancer/i }));
|
||||
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ const ManageRoom: React.FC = () => {
|
|||
setConnectingError(errorMessage);
|
||||
console.error('Erreur création salle:', errorMessage);
|
||||
});
|
||||
|
||||
|
||||
socket.on('user-joined', (student: StudentType) => {
|
||||
console.log(`Student joined: name = ${student.name}, id = ${student.id}`);
|
||||
|
||||
|
|
@ -201,6 +201,16 @@ const ManageRoom: React.FC = () => {
|
|||
webSocketService.launchStudentModeQuiz(roomName, quizQuestions);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('join-failure', (message) => {
|
||||
setConnectingError(message);
|
||||
setSocket(null);
|
||||
});
|
||||
|
||||
socket.on('user-disconnected', (userId: string) => {
|
||||
console.log(`Student left: id = ${userId}`);
|
||||
setStudents((prevUsers) => prevUsers.filter((user) => user.id !== userId));
|
||||
});
|
||||
};
|
||||
|
||||
if (rooms.length === 0) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue