|
|
|
|
@ -35,6 +35,7 @@ import { |
|
|
|
|
fetchMessages, |
|
|
|
|
deleteVisitor, |
|
|
|
|
makeAgentUnavailable, |
|
|
|
|
sendAgentMessage, |
|
|
|
|
} from '../../../data/livechat/rooms'; |
|
|
|
|
import { saveTags } from '../../../data/livechat/tags'; |
|
|
|
|
import type { DummyResponse } from '../../../data/livechat/utils'; |
|
|
|
|
@ -341,6 +342,77 @@ describe('LIVECHAT - rooms', () => { |
|
|
|
|
expect(body.rooms.some((room: IOmnichannelRoom) => !!room.closedAt)).to.be.true; |
|
|
|
|
expect(body.rooms.some((room: IOmnichannelRoom) => room.open)).to.be.true; |
|
|
|
|
}); |
|
|
|
|
it('should return queued rooms when `queued` param is passed', async () => { |
|
|
|
|
await updateSetting('Livechat_Routing_Method', 'Manual_Selection'); |
|
|
|
|
const visitor = await createVisitor(); |
|
|
|
|
const room = await createLivechatRoom(visitor.token); |
|
|
|
|
|
|
|
|
|
const { body } = await request.get(api('livechat/rooms')).query({ queued: true }).set(credentials).expect(200); |
|
|
|
|
|
|
|
|
|
expect(body.rooms.every((room: IOmnichannelRoom) => room.open)).to.be.true; |
|
|
|
|
expect(body.rooms.every((room: IOmnichannelRoom) => !room.servedBy)).to.be.true; |
|
|
|
|
expect(body.rooms.find((froom: IOmnichannelRoom) => froom._id === room._id)).to.be.not.undefined; |
|
|
|
|
}); |
|
|
|
|
it('should return queued rooms when `queued` and `open` params are passed', async () => { |
|
|
|
|
const visitor = await createVisitor(); |
|
|
|
|
const room = await createLivechatRoom(visitor.token); |
|
|
|
|
|
|
|
|
|
const { body } = await request.get(api('livechat/rooms')).query({ queued: true, open: true }).set(credentials).expect(200); |
|
|
|
|
|
|
|
|
|
expect(body.rooms.every((room: IOmnichannelRoom) => room.open)).to.be.true; |
|
|
|
|
expect(body.rooms.every((room: IOmnichannelRoom) => !room.servedBy)).to.be.true; |
|
|
|
|
expect(body.rooms.find((froom: IOmnichannelRoom) => froom._id === room._id)).to.be.not.undefined; |
|
|
|
|
}); |
|
|
|
|
it('should return open rooms when `open` is param is passed. Open rooms should not include queued conversations', async () => { |
|
|
|
|
const visitor = await createVisitor(); |
|
|
|
|
const room = await createLivechatRoom(visitor.token); |
|
|
|
|
|
|
|
|
|
const { room: room2 } = await startANewLivechatRoomAndTakeIt(); |
|
|
|
|
|
|
|
|
|
const { body } = await request.get(api('livechat/rooms')).query({ open: true }).set(credentials).expect(200); |
|
|
|
|
|
|
|
|
|
expect(body.rooms.every((room: IOmnichannelRoom) => room.open)).to.be.true; |
|
|
|
|
expect(body.rooms.find((froom: IOmnichannelRoom) => froom._id === room2._id)).to.be.not.undefined; |
|
|
|
|
expect(body.rooms.find((froom: IOmnichannelRoom) => froom._id === room._id)).to.be.undefined; |
|
|
|
|
|
|
|
|
|
await updateSetting('Livechat_Routing_Method', 'Auto_Selection'); |
|
|
|
|
}); |
|
|
|
|
(IS_EE ? describe : describe.skip)('Queued and OnHold chats', () => { |
|
|
|
|
before(async () => { |
|
|
|
|
await updateSetting('Livechat_allow_manual_on_hold', true); |
|
|
|
|
await updateSetting('Livechat_Routing_Method', 'Manual_Selection'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
after(async () => { |
|
|
|
|
await updateSetting('Livechat_Routing_Method', 'Auto_Selection'); |
|
|
|
|
await updateSetting('Livechat_allow_manual_on_hold', false); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should not return on hold rooms along with queued rooms when `queued` is true and `onHold` is true', async () => { |
|
|
|
|
const { room } = await startANewLivechatRoomAndTakeIt(); |
|
|
|
|
await sendAgentMessage(room._id); |
|
|
|
|
const response = await request |
|
|
|
|
.post(api('livechat/room.onHold')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
roomId: room._id, |
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
expect(response.body.success).to.be.true; |
|
|
|
|
|
|
|
|
|
const visitor = await createVisitor(); |
|
|
|
|
const room2 = await createLivechatRoom(visitor.token); |
|
|
|
|
|
|
|
|
|
const { body } = await request.get(api('livechat/rooms')).query({ queued: true, onhold: true }).set(credentials).expect(200); |
|
|
|
|
|
|
|
|
|
expect(body.rooms.every((room: IOmnichannelRoom) => room.open)).to.be.true; |
|
|
|
|
expect(body.rooms.every((room: IOmnichannelRoom) => !room.servedBy)).to.be.true; |
|
|
|
|
expect(body.rooms.every((room: IOmnichannelRoom) => !room.onHold)).to.be.true; |
|
|
|
|
expect(body.rooms.find((froom: IOmnichannelRoom) => froom._id === room._id)).to.be.undefined; |
|
|
|
|
expect(body.rooms.find((froom: IOmnichannelRoom) => froom._id === room2._id)).to.be.not.undefined; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
(IS_EE ? it : it.skip)('should return only rooms with the given department', async () => { |
|
|
|
|
const { department } = await createDepartmentWithAnOnlineAgent(); |
|
|
|
|
|
|
|
|
|
|