@@ -4,11 +4,12 @@ import { IS_EE } from '../config/constants';
44import { createAuxContext } from '../fixtures/createAuxContext' ;
55import { Users } from '../fixtures/userStates' ;
66import { HomeOmnichannel } from '../page-objects' ;
7+ import { setSettingValueById } from '../utils' ;
78import { createAgent , makeAgentAvailable } from '../utils/omnichannel/agents' ;
89import { addAgentToDepartment , createDepartment } from '../utils/omnichannel/departments' ;
910import { createManager } from '../utils/omnichannel/managers' ;
1011import { createMonitor } from '../utils/omnichannel/monitors' ;
11- import { createConversation } from '../utils/omnichannel/rooms' ;
12+ import { createConversation , waitForInquiryToBeTaken } from '../utils/omnichannel/rooms' ;
1213import { createOrUpdateUnit } from '../utils/omnichannel/units' ;
1314import { expect , test } from '../utils/test' ;
1415
@@ -28,6 +29,14 @@ test.describe('OC - Chat transfers [Monitor role]', () => {
2829
2930 let poOmnichannel : HomeOmnichannel ;
3031
32+ test . beforeAll ( async ( { api } ) => {
33+ const responses = await Promise . all ( [
34+ setSettingValueById ( api , 'Livechat_waiting_queue' , true ) ,
35+ setSettingValueById ( api , 'Omnichannel_queue_delay_timeout' , 1 ) ,
36+ ] ) ;
37+ responses . forEach ( ( res ) => expect ( res . status ( ) ) . toBe ( 200 ) ) ;
38+ } ) ;
39+
3140 // Create agents
3241 test . beforeAll ( async ( { api } ) => {
3342 agents = await Promise . all ( [ createAgent ( api , 'user1' ) , createAgent ( api , 'user2' ) , createAgent ( api , 'rocketchat.internal.admin.test' ) ] ) ;
@@ -59,19 +68,25 @@ test.describe('OC - Chat transfers [Monitor role]', () => {
5968 test . beforeAll ( async ( { api } ) => {
6069 const [ departmentA ] = departments . map ( ( { data } ) => data ) ;
6170
62- const conversationA = await createConversation ( api , {
63- agentId : `user1` ,
64- departmentId : departmentA . _id ,
65- } ) ;
66- const conversationB = await createConversation ( api , {
67- agentId : `user1` ,
68- departmentId : departmentA . _id ,
69- } ) ;
70- const conversationC = await createConversation ( api , {
71- agentId : `user1` ,
72- departmentId : departmentA . _id ,
73- } ) ;
74- conversations = [ conversationA , conversationB , conversationC ] ;
71+ conversations = await Promise . all ( [
72+ createConversation ( api , {
73+ agentId : `user1` ,
74+ departmentId : departmentA . _id ,
75+ } ) ,
76+ createConversation ( api , {
77+ agentId : `user1` ,
78+ departmentId : departmentA . _id ,
79+ } ) ,
80+ createConversation ( api , {
81+ agentId : `user1` ,
82+ departmentId : departmentA . _id ,
83+ } ) ,
84+ ] ) ;
85+
86+ await waitForInquiryToBeTaken (
87+ api ,
88+ conversations . map ( ( c ) => c . data . room . _id ) ,
89+ ) ;
7590 } ) ;
7691
7792 // Create monitors
@@ -115,13 +130,15 @@ test.describe('OC - Chat transfers [Monitor role]', () => {
115130 await Promise . all ( sessions . map ( ( { page } ) => page . close ( ) ) ) ;
116131 } ) ;
117132
118- test . afterAll ( async ( ) => {
133+ test . afterAll ( async ( { api } ) => {
119134 await Promise . all ( [
120135 ...conversations . map ( ( conversation ) => conversation . delete ( ) ) ,
121136 ...monitors . map ( ( monitor ) => monitor . delete ( ) ) ,
122137 ...agents . map ( ( agent ) => agent . delete ( ) ) ,
123138 ...units . map ( ( unit ) => unit . delete ( ) ) ,
124139 ...departments . map ( ( department ) => department . delete ( ) ) ,
140+ setSettingValueById ( api , 'Livechat_waiting_queue' , false ) ,
141+ setSettingValueById ( api , 'Omnichannel_queue_delay_timeout' , 5 ) ,
125142 ] ) ;
126143 } ) ;
127144
@@ -266,6 +283,14 @@ test.describe('OC - Chat transfers [Manager role]', () => {
266283
267284 let poOmnichannel : HomeOmnichannel ;
268285
286+ test . beforeAll ( async ( { api } ) => {
287+ const responses = await Promise . all ( [
288+ setSettingValueById ( api , 'Livechat_waiting_queue' , true ) ,
289+ setSettingValueById ( api , 'Omnichannel_queue_delay_timeout' , 1 ) ,
290+ ] ) ;
291+ responses . forEach ( ( res ) => expect ( res . status ( ) ) . toBe ( 200 ) ) ;
292+ } ) ;
293+
269294 // Create agents
270295 test . beforeAll ( async ( { api } ) => {
271296 agents = await Promise . all ( [ createAgent ( api , 'user1' ) , createAgent ( api , 'user2' ) , createAgent ( api , 'rocketchat.internal.admin.test' ) ] ) ;
@@ -302,19 +327,25 @@ test.describe('OC - Chat transfers [Manager role]', () => {
302327 test . beforeAll ( async ( { api } ) => {
303328 const [ departmentA ] = departments . map ( ( { data } ) => data ) ;
304329
305- const conversationA = await createConversation ( api , {
306- agentId : `user1` ,
307- departmentId : departmentA . _id ,
308- } ) ;
309- const conversationB = await createConversation ( api , {
310- agentId : `user1` ,
311- departmentId : departmentA . _id ,
312- } ) ;
313- const conversationC = await createConversation ( api , {
314- agentId : `user1` ,
315- departmentId : departmentA . _id ,
316- } ) ;
317- conversations = [ conversationA , conversationB , conversationC ] ;
330+ conversations = await Promise . all ( [
331+ createConversation ( api , {
332+ agentId : `user1` ,
333+ departmentId : departmentA . _id ,
334+ } ) ,
335+ createConversation ( api , {
336+ agentId : `user1` ,
337+ departmentId : departmentA . _id ,
338+ } ) ,
339+ createConversation ( api , {
340+ agentId : `user1` ,
341+ departmentId : departmentA . _id ,
342+ } ) ,
343+ ] ) ;
344+
345+ await waitForInquiryToBeTaken (
346+ api ,
347+ conversations . map ( ( c ) => c . data . room . _id ) ,
348+ ) ;
318349 } ) ;
319350
320351 // Create sessions
@@ -337,12 +368,14 @@ test.describe('OC - Chat transfers [Manager role]', () => {
337368 await Promise . all ( sessions . map ( ( { page } ) => page . close ( ) ) ) ;
338369 } ) ;
339370
340- test . afterAll ( async ( ) => {
371+ test . afterAll ( async ( { api } ) => {
341372 await Promise . all ( [
342373 ...conversations . map ( ( conversation ) => conversation . delete ( ) ) ,
343374 ...managers . map ( ( manager ) => manager . delete ( ) ) ,
344375 ...agents . map ( ( agent ) => agent . delete ( ) ) ,
345376 ...departments . map ( ( department ) => department . delete ( ) ) ,
377+ setSettingValueById ( api , 'Livechat_waiting_queue' , false ) ,
378+ setSettingValueById ( api , 'Omnichannel_queue_delay_timeout' , 5 ) ,
346379 ] ) ;
347380 } ) ;
348381
0 commit comments