Skip to content

Commit

Permalink
[backend] Remove unnecessary codes
Browse files Browse the repository at this point in the history
  • Loading branch information
lim396 committed Feb 8, 2024
1 parent 7e940c9 commit e9d417b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 23 deletions.
3 changes: 0 additions & 3 deletions backend/src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion backend/src/room/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
22 changes: 4 additions & 18 deletions backend/test/chat-gateway.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] };
Expand Down Expand Up @@ -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<void[]>;
Expand All @@ -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<void[]>;
Expand All @@ -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);
Expand All @@ -1269,6 +1266,7 @@ describe('ChatGateway and ChatController (e2e)', () => {
});
});
});

describe('Notification that owner has left the room (delete-room)', () => {
let room;
let ctx14: Promise<void[]>;
Expand Down Expand Up @@ -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);
});
});
});

Expand Down
1 change: 0 additions & 1 deletion backend/test/room.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit e9d417b

Please sign in to comment.