Skip to content

Commit d0fb398

Browse files
move turn agent away logic to beforeEach instead of having it as a step
1 parent 59c0a05 commit d0fb398

1 file changed

Lines changed: 14 additions & 33 deletions

File tree

apps/meteor/tests/e2e/omnichannel/omnichannel-rooms-forward.spec.ts

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
4949
const responses = await Promise.all([
5050
setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 300),
5151
setSettingValueById(api, 'Omnichannel_enable_department_removal', true),
52+
setSettingValueById(api, 'Livechat_enabled_when_agent_idle', false),
5253
addAgentToDepartment(api, { department: initialDepartment.data, agentId: 'user1' }),
5354
addAgentToDepartment(api, { department: forwardToOfflineDepartment.data, agentId: 'user2' }),
5455
]);
@@ -60,12 +61,20 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
6061

6162
test.beforeEach(async ({ page, browser, api }) => {
6263
visitor = createFakeVisitor();
64+
// Online Agent window opens with idleTimeLimit of 300 by default, therefore it will remain online
6365
poHomeOmnichannelOnlineAgent = new HomeOmnichannel(page);
6466
await poHomeOmnichannelOnlineAgent.page.goto('/');
6567
await poHomeOmnichannelOnlineAgent.waitForHome();
6668

6769
({ page: livechatPage } = await createAuxContext(browser, Users.user1, '/livechat', false));
6870
poLivechat = new OmnichannelLiveChat(livechatPage, api);
71+
72+
await expect(setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 1)).resolves.toBeOK();
73+
74+
// Away Agent window opens with idleTimeLimit of 1, therefore after a second it will turn away
75+
({ page: omnichannelPage } = await createAuxContext(browser, Users.user2, '/', false));
76+
poHomeOmnichannelAwayAgent = new HomeOmnichannel(omnichannelPage);
77+
await expect(poHomeOmnichannelAwayAgent.navbar.getUserStatusBadge('away')).toBeVisible();
6978
});
7079

7180
test.afterEach(async ({ api }) => {
@@ -87,7 +96,7 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
8796
onlineAgent.delete(),
8897
awayAgent.delete(),
8998
setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'),
90-
setSettingValueById(api, 'Livechat_enabled_when_agent_idle', false),
99+
setSettingValueById(api, 'Livechat_enabled_when_agent_idle', true),
91100
setSettingValueById(api, 'Omnichannel_enable_department_removal', false),
92101
]);
93102
for (const response of responses) {
@@ -97,11 +106,9 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
97106

98107
test('when manager forward to offline (agent away, accept when agent idle off) department the inquiry should be set to the queue', async ({
99108
api,
100-
browser,
101109
}) => {
102110
await test.step('Setup routing settings', async () => {
103111
await expect(setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection')).resolves.toBeOK();
104-
await expect(setSettingValueById(api, 'Livechat_enabled_when_agent_idle', false)).resolves.toBeOK();
105112
});
106113

107114
await test.step('Visitor initiates chat', async () => {
@@ -113,13 +120,6 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
113120
});
114121
});
115122

116-
await test.step('Set user2 agent away by idle timeout', async () => {
117-
await expect(setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 1)).resolves.toBeOK();
118-
({ page: omnichannelPage } = await createAuxContext(browser, Users.user2, '/', false));
119-
poHomeOmnichannelAwayAgent = new HomeOmnichannel(omnichannelPage);
120-
await expect(poHomeOmnichannelAwayAgent.navbar.getUserStatusBadge('away')).toBeVisible();
121-
});
122-
123123
await test.step('Manager forwards chat', async () => {
124124
await poHomeOmnichannelOnlineAgent.sidebar.getSidebarItemByName(visitor.name).click();
125125
await poHomeOmnichannelOnlineAgent.quickActionsRoomToolbar.forwardChat();
@@ -145,7 +145,6 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
145145

146146
test('when manager forward to a department while waiting_queue is active and allowReceiveForwardOffline is true, chat should end in departments queue', async ({
147147
api,
148-
browser,
149148
}) => {
150149
await test.step('Setup routing settings', async () => {
151150
await expect(setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection')).resolves.toBeOK();
@@ -160,13 +159,6 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
160159
});
161160
});
162161

163-
await test.step('Set user2 agent away by idle timeout', async () => {
164-
await expect(setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 1)).resolves.toBeOK();
165-
({ page: omnichannelPage } = await createAuxContext(browser, Users.user2, '/', false));
166-
poHomeOmnichannelAwayAgent = new HomeOmnichannel(omnichannelPage);
167-
await expect(poHomeOmnichannelAwayAgent.navbar.getUserStatusBadge('away')).toBeVisible();
168-
});
169-
170162
await test.step('Manager enables queue and forwards chat', async () => {
171163
await poHomeOmnichannelOnlineAgent.sidebar.getSidebarItemByName(visitor.name).click();
172164
await expect(setSettingValueById(api, 'Livechat_waiting_queue', true)).resolves.toBeOK();
@@ -198,7 +190,6 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
198190

199191
test('when manager forward to a department while waiting_queue is active and allowReceiveForwardOffline is false, transfer should fail', async ({
200192
api,
201-
browser,
202193
}) => {
203194
await test.step('Setup routing and department settings', async () => {
204195
await expect(setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection')).resolves.toBeOK();
@@ -218,13 +209,6 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
218209
});
219210
});
220211

221-
await test.step('Set user2 agent away by idle timeout', async () => {
222-
await expect(setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 1)).resolves.toBeOK();
223-
({ page: omnichannelPage } = await createAuxContext(browser, Users.user2, '/', false));
224-
poHomeOmnichannelAwayAgent = new HomeOmnichannel(omnichannelPage);
225-
await expect(poHomeOmnichannelAwayAgent.navbar.getUserStatusBadge('away')).toBeVisible();
226-
});
227-
228212
await test.step('Manager attempts to forward and sees error', async () => {
229213
await poHomeOmnichannelOnlineAgent.sidebar.getSidebarItemByName(visitor.name).click();
230214
await expect(setSettingValueById(api, 'Livechat_waiting_queue', true)).resolves.toBeOK();
@@ -252,11 +236,9 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
252236

253237
test('when manager forward to online (agent away, accept when agent idle on) department the inquiry should not be set to the queue', async ({
254238
api,
255-
browser,
256239
}) => {
257240
await test.step('Setup routing settings', async () => {
258241
await expect(setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection')).resolves.toBeOK();
259-
await expect(setSettingValueById(api, 'Livechat_enabled_when_agent_idle', true)).resolves.toBeOK();
260242
});
261243

262244
await test.step('Visitor initiates chat', async () => {
@@ -266,13 +248,12 @@ test.describe('OC - Forwarding to away agents (EE)', () => {
266248
message: 'test message',
267249
isOffline: false,
268250
});
251+
await expect(poLivechat.headerTitle).toHaveText(onlineAgent.data.username);
269252
});
270253

271-
await test.step('Set user2 agent away by idle timeout', async () => {
272-
await expect(setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 1)).resolves.toBeOK();
273-
({ page: omnichannelPage } = await createAuxContext(browser, Users.user2, '/', false));
274-
poHomeOmnichannelAwayAgent = new HomeOmnichannel(omnichannelPage);
275-
await expect(poHomeOmnichannelAwayAgent.navbar.getUserStatusBadge('away')).toBeVisible();
254+
await test.step('Set Livechat_enabled_when_agent_idle to true', async () => {
255+
// We set Livechat_enabled_when_agent_idle to true here in order to not assign the away agent in the previous step
256+
await expect(setSettingValueById(api, 'Livechat_enabled_when_agent_idle', true)).resolves.toBeOK();
276257
});
277258

278259
await test.step('Manager forwards chat successfully', async () => {

0 commit comments

Comments
 (0)