diff --git a/backend/src/chat/chat.service.ts b/backend/src/chat/chat.service.ts index a8162fd2..809b0092 100644 --- a/backend/src/chat/chat.service.ts +++ b/backend/src/chat/chat.service.ts @@ -140,9 +140,6 @@ export class ChatService { event.userIds.forEach((userId) => this.removeUserFromRoom(event.roomId, userId), ); - - // TODO: delete room - // this.server.socketsLeave(roomId.toString()); } sendToRoom(roomId: number, event: string, data: any) { diff --git a/backend/src/room/room.service.ts b/backend/src/room/room.service.ts index 5efb433f..8a764757 100644 --- a/backend/src/room/room.service.ts +++ b/backend/src/room/room.service.ts @@ -327,7 +327,6 @@ export class RoomService { }, }, }); - // TODO: If owner leaves the room, the room should be deleted or a new owner should be assigned if (deletedUserOnRoom.role === Role.OWNER) { await this.removeRoom(roomId); } diff --git a/backend/test/chat-gateway.e2e-spec.ts b/backend/test/chat-gateway.e2e-spec.ts index 3c1cb356..ed02da8d 100644 --- a/backend/test/chat-gateway.e2e-spec.ts +++ b/backend/test/chat-gateway.e2e-spec.ts @@ -1149,6 +1149,7 @@ describe('ChatGateway and ChatController (e2e)', () => { }); }); }); + describe('Notification that deleted a room', () => { const setupRoom = async (createRoomDto: CreateRoomDto) => { const dto = { ...createRoomDto, userIds: [user2.id] }; @@ -1182,15 +1183,14 @@ describe('ChatGateway and ChatController (e2e)', () => { afterAll(async () => { await app.deleteRoom(_publicRoom.id, user1.accessToken); }); - it('is sent when user1 deletes the public room', async () => { await app.deleteRoom(_publicRoom.id, user1.accessToken).expect(204); }); - it('should be received by all users', async () => { await ctx11; }); }); + describe('Notification that deleted a protected room', () => { let _protectedRoom; let ctx12: Promise; @@ -1215,17 +1215,16 @@ describe('ChatGateway and ChatController (e2e)', () => { afterAll(async () => { await app.deleteRoom(_protectedRoom.id, user1.accessToken); }); - it('is sent when user1 deletes the protected room', async () => { await app .deleteRoom(_protectedRoom.id, user1.accessToken) .expect(204); }); - it('should be received by all users', async () => { await ctx12; }); }); + describe('Notification that deleted a private room', () => { let _privateRoom; let ctx13: Promise; @@ -1250,14 +1249,12 @@ describe('ChatGateway and ChatController (e2e)', () => { afterAll(async () => { await app.deleteRoom(_privateRoom.id, user1.accessToken); }); - it('is sent when user1 deletes the private room', async () => { await app.deleteRoom(_privateRoom.id, user1.accessToken).expect(204); }); it('should be received by room members', async () => { await ctx13; }); - it('should not be received by non-members', (done) => { const mockDeleteRoomEventListener = jest.fn(); ws3.on('delete-room', mockDeleteRoomEventListener); @@ -1269,6 +1266,7 @@ describe('ChatGateway and ChatController (e2e)', () => { }); }); }); + describe('Notification that owner has left the room (delete-room)', () => { let room; let ctx14: Promise; @@ -1299,24 +1297,12 @@ describe('ChatGateway and ChatController (e2e)', () => { afterAll(async () => { await app.deleteRoom(room.id, user1.accessToken); }); - it('is sent when owner(user1) leaves the public room', async () => { await app.leaveRoom(room.id, user1.accessToken).expect(204); }); - it('should be received by all users', async () => { await ctx14; }); - - it('should not be received by non-members', (done) => { - const mockKickEventListener = jest.fn(); - ws3.on('delete-room', mockKickEventListener); - setTimeout(() => { - expect(mockKickEventListener).not.toBeCalled(); - ws3.off('delete-room'); - done(); - }, waitTime); - }); }); }); diff --git a/backend/test/room.e2e-spec.ts b/backend/test/room.e2e-spec.ts index 9e7482f7..c293d51b 100644 --- a/backend/test/room.e2e-spec.ts +++ b/backend/test/room.e2e-spec.ts @@ -966,7 +966,6 @@ describe('RoomController (e2e)', () => { describe('owner', () => { beforeAll(setupRooms); afterAll(teardownRooms); - // TODO: What if owner leaves the room? test('should leave public room (204 No Content)', async () => { await app.leaveRoom(_publicRoom.id, owner.accessToken).expect(204); });