@@ -22,8 +22,8 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
2222 let poHomeOmnichannelAwayAgent : HomeOmnichannel ;
2323 let poLivechat : OmnichannelLiveChat ;
2424
25- let livechatPage : Page ;
26- let omnichannelPage : Page ;
25+ let livechatPage : Page | undefined ;
26+ let omnichannelPage : Page | undefined ;
2727
2828 let manager : Awaited < ReturnType < typeof createManager > > ;
2929 let onlineAgent : Awaited < ReturnType < typeof createAgent > > ;
@@ -39,21 +39,30 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
3939 createAgent ( api , 'user2' ) ,
4040 createDepartment ( api , { name : 'Initial Dept' } ) ,
4141 createDepartment ( api , { name : 'Forward Dept' , allowReceiveForwardOffline : true } ) ,
42- setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 300 ) ,
43- expect ( await setSettingValueById ( api , 'Omnichannel_enable_department_removal' , true ) ) . toBeOK ( ) ,
4442 ] ) ;
43+ await expect ( manager . response ) . toBeOK ( ) ;
44+ await expect ( onlineAgent . response ) . toBeOK ( ) ;
45+ await expect ( awayAgent . response ) . toBeOK ( ) ;
46+ await expect ( initialDepartment . response ) . toBeOK ( ) ;
47+ await expect ( forwardToOfflineDepartment . response ) . toBeOK ( ) ;
4548
46- await Promise . all ( [
49+ const responses = await Promise . all ( [
50+ setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 300 ) ,
51+ setSettingValueById ( api , 'Omnichannel_enable_department_removal' , true ) ,
4752 addAgentToDepartment ( api , { department : initialDepartment . data , agentId : 'user1' } ) ,
4853 addAgentToDepartment ( api , { department : forwardToOfflineDepartment . data , agentId : 'user2' } ) ,
4954 ] ) ;
55+
56+ for ( const response of responses ) {
57+ await expect ( response ) . toBeOK ( ) ;
58+ }
5059 } ) ;
5160
5261 test . beforeEach ( async ( { page, browser, api } ) => {
5362 visitor = createFakeVisitor ( ) ;
5463 poHomeOmnichannelOnlineAgent = new HomeOmnichannel ( page ) ;
55- await page . goto ( '/' ) ;
56- await page . locator ( '#main-content' ) . waitFor ( ) ;
64+ await poHomeOmnichannelOnlineAgent . page . goto ( '/' ) ;
65+ await poHomeOmnichannelOnlineAgent . waitForHome ( ) ;
5766
5867 ( { page : livechatPage } = await createAuxContext ( browser , Users . user1 , '/livechat' , false ) ) ;
5968 poLivechat = new OmnichannelLiveChat ( livechatPage , api ) ;
@@ -67,41 +76,45 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
6776 await omnichannelPage . context ( ) . close ( ) ;
6877 }
6978
70- await setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 300 ) ;
79+ await expect ( setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 300 ) ) . resolves . toBeOK ( ) ;
7180 } ) ;
7281
7382 test . afterAll ( async ( { api } ) => {
74- await Promise . all ( [
83+ const responses = await Promise . all ( [
7584 initialDepartment . delete ( ) ,
7685 forwardToOfflineDepartment . delete ( ) ,
7786 manager . delete ( ) ,
7887 onlineAgent . delete ( ) ,
7988 awayAgent . delete ( ) ,
8089 setSettingValueById ( api , 'Livechat_Routing_Method' , 'Auto_Selection' ) ,
8190 setSettingValueById ( api , 'Livechat_enabled_when_agent_idle' , false ) ,
82- expect ( await setSettingValueById ( api , 'Omnichannel_enable_department_removal' , false ) ) . toBeOK ( ) ,
91+ setSettingValueById ( api , 'Omnichannel_enable_department_removal' , false ) ,
8392 ] ) ;
93+ for ( const response of responses ) {
94+ await expect ( response ) . toBeOK ( ) ;
95+ }
8496 } ) ;
8597
8698 test ( 'when manager forward to offline (agent away, accept when agent idle off) department the inquiry should be set to the queue' , async ( {
8799 api,
88100 browser,
89101 } ) => {
90102 await test . step ( 'Setup routing settings' , async ( ) => {
91- await setSettingValueById ( api , 'Livechat_Routing_Method' , 'Manual_Selection' ) ;
92- await setSettingValueById ( api , 'Livechat_enabled_when_agent_idle' , false ) ;
103+ await expect ( setSettingValueById ( api , 'Livechat_Routing_Method' , 'Manual_Selection' ) ) . resolves . toBeOK ( ) ;
104+ await expect ( setSettingValueById ( api , 'Livechat_enabled_when_agent_idle' , false ) ) . resolves . toBeOK ( ) ;
93105 } ) ;
94106
95107 await test . step ( 'Visitor initiates chat' , async ( ) => {
96108 await poLivechat . page . reload ( ) ;
97- await poLivechat . openAnyLiveChat ( ) ;
98- await poLivechat . sendMessage ( visitor , false ) ;
99- await poLivechat . onlineAgentMessage . fill ( 'test' ) ;
100- await poLivechat . btnSendMessageToOnlineAgent . click ( ) ;
109+ await poLivechat . openAnyLiveChatAndSendMessage ( {
110+ liveChatUser : visitor ,
111+ message : 'test message' ,
112+ isOffline : false ,
113+ } ) ;
101114 } ) ;
102115
103116 await test . step ( 'Set user2 agent away by idle timeout' , async ( ) => {
104- await setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 1 ) ;
117+ await expect ( setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 1 ) ) . resolves . toBeOK ( ) ;
105118 ( { page : omnichannelPage } = await createAuxContext ( browser , Users . user2 , '/' , false ) ) ;
106119 poHomeOmnichannelAwayAgent = new HomeOmnichannel ( omnichannelPage ) ;
107120 await expect ( poHomeOmnichannelAwayAgent . navbar . getUserStatusBadge ( 'away' ) ) . toBeVisible ( ) ;
@@ -117,10 +130,12 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
117130
118131 await test . step ( 'Check inquiry status via API is queued' , async ( ) => {
119132 const roomInfoResp = await api . get ( `/livechat/rooms` ) ;
133+ await expect ( roomInfoResp ) . toBeOK ( ) ;
120134 const roomBody = await roomInfoResp . json ( ) ;
121135 const roomId = roomBody . rooms . find ( ( room : IRoom ) => room . fname === visitor . name ) . _id ;
122136
123137 const inquiryResp = await api . get ( `/livechat/inquiries.getOne?roomId=${ roomId } ` ) ;
138+ await expect ( inquiryResp ) . toBeOK ( ) ;
124139 const inquiryBody = await inquiryResp . json ( ) ;
125140
126141 expect ( inquiryBody . inquiry . status ) . toBe ( 'queued' ) ;
@@ -133,27 +148,28 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
133148 browser,
134149 } ) => {
135150 await test . step ( 'Setup routing settings' , async ( ) => {
136- await setSettingValueById ( api , 'Livechat_Routing_Method' , 'Auto_Selection' ) ;
151+ await expect ( setSettingValueById ( api , 'Livechat_Routing_Method' , 'Auto_Selection' ) ) . resolves . toBeOK ( ) ;
137152 } ) ;
138153
139154 await test . step ( 'Visitor initiates chat' , async ( ) => {
140155 await poLivechat . page . reload ( ) ;
141- await poLivechat . openAnyLiveChat ( ) ;
142- await poLivechat . sendMessage ( visitor , false ) ;
143- await poLivechat . onlineAgentMessage . fill ( 'test' ) ;
144- await poLivechat . btnSendMessageToOnlineAgent . click ( ) ;
156+ await poLivechat . openAnyLiveChatAndSendMessage ( {
157+ liveChatUser : visitor ,
158+ message : 'test message' ,
159+ isOffline : false ,
160+ } ) ;
145161 } ) ;
146162
147163 await test . step ( 'Set user2 agent away by idle timeout' , async ( ) => {
148- await setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 1 ) ;
164+ await expect ( setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 1 ) ) . resolves . toBeOK ( ) ;
149165 ( { page : omnichannelPage } = await createAuxContext ( browser , Users . user2 , '/' , false ) ) ;
150166 poHomeOmnichannelAwayAgent = new HomeOmnichannel ( omnichannelPage ) ;
151167 await expect ( poHomeOmnichannelAwayAgent . navbar . getUserStatusBadge ( 'away' ) ) . toBeVisible ( ) ;
152168 } ) ;
153169
154170 await test . step ( 'Manager enables queue and forwards chat' , async ( ) => {
155171 await poHomeOmnichannelOnlineAgent . sidebar . getSidebarItemByName ( visitor . name ) . click ( ) ;
156- await setSettingValueById ( api , 'Livechat_waiting_queue' , true ) ;
172+ await expect ( setSettingValueById ( api , 'Livechat_waiting_queue' , true ) ) . resolves . toBeOK ( ) ;
157173
158174 await poHomeOmnichannelOnlineAgent . quickActionsRoomToolbar . forwardChat ( ) ;
159175 await poHomeOmnichannelOnlineAgent . content . forwardChatModal . selectDepartment ( 'Forward Dept' ) ;
@@ -163,18 +179,20 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
163179
164180 await test . step ( 'Check inquiry status via API is queued' , async ( ) => {
165181 const roomInfoResp = await api . get ( `/livechat/rooms` ) ;
182+ await expect ( roomInfoResp ) . toBeOK ( ) ;
166183 const roomBody = await roomInfoResp . json ( ) ;
167184 const roomId = roomBody . rooms . find ( ( room : IRoom ) => room . fname === visitor . name ) . _id ;
168185
169186 const inquiryResp = await api . get ( `/livechat/inquiries.getOne?roomId=${ roomId } ` ) ;
187+ await expect ( inquiryResp ) . toBeOK ( ) ;
170188 const inquiryBody = await inquiryResp . json ( ) ;
171189
172190 expect ( inquiryBody . inquiry . status ) . toBe ( 'queued' ) ;
173191 expect ( inquiryBody . inquiry . department ) . toBe ( forwardToOfflineDepartment . data . _id ) ;
174192 } ) ;
175193
176194 await test . step ( 'Disable waiting queue' , async ( ) => {
177- await setSettingValueById ( api , 'Livechat_waiting_queue' , false ) ;
195+ await expect ( setSettingValueById ( api , 'Livechat_waiting_queue' , false ) ) . resolves . toBeOK ( ) ;
178196 } ) ;
179197 } ) ;
180198
@@ -183,30 +201,33 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
183201 browser,
184202 } ) => {
185203 await test . step ( 'Setup routing and department settings' , async ( ) => {
186- await setSettingValueById ( api , 'Livechat_Routing_Method' , 'Auto_Selection' ) ;
187- await api . put ( `/livechat/department/${ forwardToOfflineDepartment . data . _id } ` , {
188- department : { ...forwardToOfflineDepartment . data , allowReceiveForwardOffline : false } ,
189- } ) ;
204+ await expect ( setSettingValueById ( api , 'Livechat_Routing_Method' , 'Auto_Selection' ) ) . resolves . toBeOK ( ) ;
205+ await expect (
206+ api . put ( `/livechat/department/${ forwardToOfflineDepartment . data . _id } ` , {
207+ department : { ...forwardToOfflineDepartment . data , allowReceiveForwardOffline : false } ,
208+ } ) ,
209+ ) . resolves . toBeOK ( ) ;
190210 } ) ;
191211
192212 await test . step ( 'Visitor initiates chat' , async ( ) => {
193213 await poLivechat . page . reload ( ) ;
194- await poLivechat . openAnyLiveChat ( ) ;
195- await poLivechat . sendMessage ( visitor , false ) ;
196- await poLivechat . onlineAgentMessage . fill ( 'test' ) ;
197- await poLivechat . btnSendMessageToOnlineAgent . click ( ) ;
214+ await poLivechat . openAnyLiveChatAndSendMessage ( {
215+ liveChatUser : visitor ,
216+ message : 'test message' ,
217+ isOffline : false ,
218+ } ) ;
198219 } ) ;
199220
200221 await test . step ( 'Set user2 agent away by idle timeout' , async ( ) => {
201- await setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 1 ) ;
222+ await expect ( setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 1 ) ) . resolves . toBeOK ( ) ;
202223 ( { page : omnichannelPage } = await createAuxContext ( browser , Users . user2 , '/' , false ) ) ;
203224 poHomeOmnichannelAwayAgent = new HomeOmnichannel ( omnichannelPage ) ;
204225 await expect ( poHomeOmnichannelAwayAgent . navbar . getUserStatusBadge ( 'away' ) ) . toBeVisible ( ) ;
205226 } ) ;
206227
207228 await test . step ( 'Manager attempts to forward and sees error' , async ( ) => {
208229 await poHomeOmnichannelOnlineAgent . sidebar . getSidebarItemByName ( visitor . name ) . click ( ) ;
209- await setSettingValueById ( api , 'Livechat_waiting_queue' , true ) ;
230+ await expect ( setSettingValueById ( api , 'Livechat_waiting_queue' , true ) ) . resolves . toBeOK ( ) ;
210231
211232 await poHomeOmnichannelOnlineAgent . quickActionsRoomToolbar . forwardChat ( ) ;
212233 await poHomeOmnichannelOnlineAgent . content . forwardChatModal . selectDepartment ( 'Forward Dept' ) ;
@@ -217,13 +238,15 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
217238 } ) ;
218239
219240 await test . step ( 'Restore department setting' , async ( ) => {
220- await api . put ( `/livechat/department/${ forwardToOfflineDepartment . data . _id } ` , {
221- department : { ...forwardToOfflineDepartment . data , allowReceiveForwardOffline : true } ,
222- } ) ;
241+ await expect (
242+ api . put ( `/livechat/department/${ forwardToOfflineDepartment . data . _id } ` , {
243+ department : { ...forwardToOfflineDepartment . data , allowReceiveForwardOffline : true } ,
244+ } ) ,
245+ ) . resolves . toBeOK ( ) ;
223246 } ) ;
224247
225248 await test . step ( 'Disable waiting queue' , async ( ) => {
226- await setSettingValueById ( api , 'Livechat_waiting_queue' , false ) ;
249+ await expect ( setSettingValueById ( api , 'Livechat_waiting_queue' , false ) ) . resolves . toBeOK ( ) ;
227250 } ) ;
228251 } ) ;
229252
@@ -232,20 +255,21 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
232255 browser,
233256 } ) => {
234257 await test . step ( 'Setup routing settings' , async ( ) => {
235- await setSettingValueById ( api , 'Livechat_Routing_Method' , 'Auto_Selection' ) ;
236- await setSettingValueById ( api , 'Livechat_enabled_when_agent_idle' , true ) ;
258+ await expect ( setSettingValueById ( api , 'Livechat_Routing_Method' , 'Auto_Selection' ) ) . resolves . toBeOK ( ) ;
259+ await expect ( setSettingValueById ( api , 'Livechat_enabled_when_agent_idle' , true ) ) . resolves . toBeOK ( ) ;
237260 } ) ;
238261
239262 await test . step ( 'Visitor initiates chat' , async ( ) => {
240263 await poLivechat . page . reload ( ) ;
241- await poLivechat . openAnyLiveChat ( ) ;
242- await poLivechat . sendMessage ( visitor , false ) ;
243- await poLivechat . onlineAgentMessage . fill ( 'test' ) ;
244- await poLivechat . btnSendMessageToOnlineAgent . click ( ) ;
264+ await poLivechat . openAnyLiveChatAndSendMessage ( {
265+ liveChatUser : visitor ,
266+ message : 'test message' ,
267+ isOffline : false ,
268+ } ) ;
245269 } ) ;
246270
247271 await test . step ( 'Set user2 agent away by idle timeout' , async ( ) => {
248- await setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 1 ) ;
272+ await expect ( setSettingValueById ( api , 'Accounts_Default_User_Preferences_idleTimeLimit' , 1 ) ) . resolves . toBeOK ( ) ;
249273 ( { page : omnichannelPage } = await createAuxContext ( browser , Users . user2 , '/' , false ) ) ;
250274 poHomeOmnichannelAwayAgent = new HomeOmnichannel ( omnichannelPage ) ;
251275 await expect ( poHomeOmnichannelAwayAgent . navbar . getUserStatusBadge ( 'away' ) ) . toBeVisible ( ) ;
@@ -261,6 +285,7 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
261285
262286 await test . step ( 'Check room routing via API serves to away agent' , async ( ) => {
263287 const roomInfoResp = await api . get ( `/livechat/rooms` ) ;
288+ await expect ( roomInfoResp ) . toBeOK ( ) ;
264289 const roomBody = await roomInfoResp . json ( ) ;
265290 const room = roomBody . rooms . find ( ( room : IRoom ) => room . fname === visitor . name ) ;
266291
0 commit comments