mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Compare commits
No commits in common. "81c530eac6bc4084c68681f1e31559bfd6cc6745" and "c9b76df2cd489b392d3bd127a1d069a20539002c" have entirely different histories.
81c530eac6
...
c9b76df2cd
3 changed files with 13 additions and 20 deletions
|
|
@ -10,15 +10,14 @@ 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} />);
|
||||
|
|
@ -29,15 +28,16 @@ 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,16 +201,6 @@ 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) {
|
||||
|
|
@ -243,6 +233,7 @@ const ManageRoom: React.FC = () => {
|
|||
console.log(`Listening for user-joined in room ${roomName}`);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
socket.on('user-joined', (_student: StudentType) => {
|
||||
console.log("📢 Nouvel étudiant ajouté:", _student);
|
||||
if (quizMode === 'teacher') {
|
||||
webSocketService.nextQuestion(roomName, currentQuestion);
|
||||
} else if (quizMode === 'student') {
|
||||
|
|
|
|||
|
|
@ -254,6 +254,8 @@ describe('Rooms', () => {
|
|||
|
||||
it('should return false if room does not exist', async () => {
|
||||
const title = 'Nonexistent Room';
|
||||
const userId = '12345';
|
||||
|
||||
// Mock the database response
|
||||
collection.findOne.mockResolvedValue(null);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue