Skip to content

Commit 901ba0c

Browse files
authored
chore(tests): fix flaky livechat test (RocketChat#37470)
1 parent caa3005 commit 901ba0c

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,10 +2624,10 @@ describe('LIVECHAT - rooms', () => {
26242624
room = await createLivechatRoom(visitor.token);
26252625
});
26262626
after(async () => {
2627-
await updateSetting('Livechat_Routing_Method', 'Auto_Selection');
2628-
26292627
await deleteVisitor(visitor._id);
26302628
await closeOmnichannelRoom(room._id);
2629+
2630+
await updateSetting('Livechat_Routing_Method', 'Auto_Selection');
26312631
});
26322632
it('should not allow users to update room info without serving the chat or having "save-others-livechat-room-info" permission', async () => {
26332633
await request

apps/meteor/tests/end-to-end/api/livechat/01-agents.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -530,30 +530,31 @@ describe('LIVECHAT - Agents', () => {
530530
room = await createLivechatRoom(visitor.token);
531531
});
532532
after(async () => {
533-
await deleteVisitor(visitor.token);
534533
await closeOmnichannelRoom(room._id);
534+
await deleteVisitor(visitor.token);
535535
});
536536
it('should fail when token in url params is not valid', async () => {
537537
await request.get(api(`livechat/agent.next/invalid-token`)).expect(400);
538538
});
539539
it('should return success when visitor with token has an open room', async () => {
540540
await request.get(api(`livechat/agent.next/${visitor.token}`)).expect(200);
541541
});
542-
describe('with manual selection', () => {
543-
before(async () => {
544-
await updateSetting('Livechat_Routing_Method', 'Manual_Selection');
545-
});
546-
after(async () => {
547-
await updateSetting('Livechat_Routing_Method', 'Auto_Selection');
548-
});
549-
it('should fail if theres no open room for visitor and algo is manual selection', async () => {
550-
const visitor = await createVisitor();
551542

552-
await request.get(api(`livechat/agent.next/${visitor.token}`)).expect(400);
553-
});
543+
// TODO: test cases when algo is Auto_Selection
544+
});
545+
546+
describe('livechat/agent.next/:token - with manual selection', () => {
547+
before(async () => {
548+
await updateSetting('Livechat_Routing_Method', 'Manual_Selection');
549+
});
550+
after(async () => {
551+
await updateSetting('Livechat_Routing_Method', 'Auto_Selection');
554552
});
553+
it('should fail if theres no open room for visitor and algo is manual selection', async () => {
554+
const visitor = await createVisitor();
555555

556-
// TODO: test cases when algo is Auto_Selection
556+
await request.get(api(`livechat/agent.next/${visitor.token}`)).expect(400);
557+
});
557558
});
558559

559560
describe('livechat/agent.status', () => {

0 commit comments

Comments
 (0)