Skip to content

Commit 1ed5327

Browse files
committed
refactor: Enable and disable department removal setting in omnichannel tests
1 parent c68ac53 commit 1ed5327

11 files changed

+51
-10
lines changed

apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ test.describe.serial('OC - Manage Agents', () => {
2424
await poOmnichannelAgents.sidebar.linkAgents.click();
2525
});
2626

27+
test.beforeAll(async ({ api }) => {
28+
expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: true })).status()).toBe(200);
29+
});
30+
31+
test.afterAll(async ({ api }) => {
32+
expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: false })).status()).toBe(200);
33+
});
34+
2735
// Ensure that there is no leftover data even if test fails
2836
test.afterEach(async ({ api }) => {
2937
await api.delete('/livechat/users/agent/user1');
30-
await api.post('/settings/Omnichannel_enable_department_removal', { value: true }).then((res) => expect(res.status()).toBe(200));
3138
await department.delete();
32-
await api.post('/settings/Omnichannel_enable_department_removal', { value: false }).then((res) => expect(res.status()).toBe(200));
3339
});
3440

3541
test('OC - Manage Agents - Add, search and remove using table', async ({ page }) => {
@@ -75,6 +81,7 @@ test.describe.serial('OC - Manage Agents', () => {
7581
await poOmnichannelAgents.editAgent.selectStatus('Not Available');
7682
await poOmnichannelAgents.editAgent.selectDepartment(department.data.name);
7783
await poOmnichannelAgents.editAgent.btnSave.click();
84+
await poOmnichannelAgents.editAgent.close();
7885
});
7986

8087
await test.step('expect removing "user1" via sidebar', async () => {

apps/meteor/tests/e2e/omnichannel/omnichannel-assign-room-tags.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createFakeVisitor } from '../../mocks/data';
22
import { IS_EE } from '../config/constants';
33
import { Users } from '../fixtures/userStates';
44
import { HomeOmnichannel } from '../page-objects';
5+
import { setSettingValueById } from '../utils';
56
import { createAgent } from '../utils/omnichannel/agents';
67
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
78
import { createConversation } from '../utils/omnichannel/rooms';
@@ -13,7 +14,7 @@ const visitorB = createFakeVisitor();
1314

1415
test.use({ storageState: Users.user1.state });
1516

16-
test.describe('OC - Tags Visibility', () => {
17+
test.describe.serial('OC - Tags Visibility', () => {
1718
test.skip(!IS_EE, 'OC - Tags Visibility > Enterprise Edition Only');
1819

1920
let poOmnichannel: HomeOmnichannel;
@@ -27,6 +28,7 @@ test.describe('OC - Tags Visibility', () => {
2728
let sharedTag: Awaited<ReturnType<typeof createTag>>;
2829

2930
test.beforeAll('Create departments', async ({ api }) => {
31+
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', true)).status()).toBe(200);
3032
departmentA = await createDepartment(api, { name: 'Department A' });
3133
departmentB = await createDepartment(api, { name: 'Department B' });
3234
});
@@ -63,12 +65,13 @@ test.describe('OC - Tags Visibility', () => {
6365
await page.goto('/');
6466
});
6567

66-
test.afterAll(async () => {
68+
test.afterAll(async ({ api }) => {
6769
await Promise.all(conversations.map((conversation) => conversation.delete()));
6870
await Promise.all([tagA, tagB, globalTag, sharedTag].map((tag) => tag.delete()));
6971
await agent.delete();
7072
await departmentA.delete();
7173
await departmentB.delete();
74+
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', false)).status()).toBe(200);
7275
});
7376

7477
test('Verify agent should see correct tags based on department association', async () => {

apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Page } from '@playwright/test';
33
import { IS_EE } from '../config/constants';
44
import { Users } from '../fixtures/userStates';
55
import { OmnichannelBusinessHours } from '../page-objects/omnichannel';
6+
import { setSettingValueById } from '../utils';
67
import { createAgent } from '../utils/omnichannel/agents';
78
import { createBusinessHour } from '../utils/omnichannel/businessHours';
89
import { createDepartment } from '../utils/omnichannel/departments';
@@ -25,6 +26,7 @@ test.describe('OC - Business Hours', () => {
2526
department = await createDepartment(api);
2627
department2 = await createDepartment(api);
2728
agent = await createAgent(api, 'user2');
29+
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', true)).status()).toBe(200);
2830
await api.post('/settings/Livechat_enable_business_hours', { value: true }).then((res) => expect(res.status()).toBe(200));
2931
await api.post('/settings/Livechat_business_hour_type', { value: 'Multiple' }).then((res) => expect(res.status()).toBe(200));
3032
});
@@ -33,6 +35,7 @@ test.describe('OC - Business Hours', () => {
3335
await department.delete();
3436
await department2.delete();
3537
await agent.delete();
38+
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', false)).status()).toBe(200);
3639
await api.post('/settings/Livechat_enable_business_hours', { value: false }).then((res) => expect(res.status()).toBe(200));
3740
await api.post('/settings/Livechat_business_hour_type', { value: 'Single' }).then((res) => expect(res.status()).toBe(200));
3841
});

apps/meteor/tests/e2e/omnichannel/omnichannel-chat-transfers.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IS_EE } from '../config/constants';
44
import { createAuxContext } from '../fixtures/createAuxContext';
55
import { Users } from '../fixtures/userStates';
66
import { HomeOmnichannel } from '../page-objects';
7+
import { setSettingValueById } from '../utils';
78
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
89
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
910
import { createManager } from '../utils/omnichannel/managers';
@@ -94,6 +95,7 @@ test.describe('OC - Chat transfers [Monitor role]', () => {
9495
departments: [{ departmentId: departmentB._id }],
9596
}),
9697
]);
98+
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', true)).status()).toBe(200);
9799
});
98100

99101
// Create sessions
@@ -116,14 +118,15 @@ test.describe('OC - Chat transfers [Monitor role]', () => {
116118
await Promise.all(sessions.map(({ page }) => page.close()));
117119
});
118120

119-
test.afterAll(async () => {
121+
test.afterAll(async ({ api }) => {
120122
await Promise.all([
121123
...conversations.map((conversation) => conversation.delete()),
122124
...monitors.map((monitor) => monitor.delete()),
123125
...agents.map((agent) => agent.delete()),
124126
...units.map((unit) => unit.delete()),
125127
...departments.map((department) => department.delete()),
126128
]);
129+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
127130
});
128131

129132
test(`OC - Chat transfers [Monitor role] - Transfer to department with no online agents should fail`, async ({ api }) => {

apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { IS_EE } from '../config/constants';
55
import { Users } from '../fixtures/userStates';
66
import { HomeOmnichannel } from '../page-objects';
77
import { OmnichannelContactCenterChats } from '../page-objects/omnichannel';
8+
import { setSettingValueById } from '../utils';
89
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
910
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
1011
import { createConversation, updateRoom } from '../utils/omnichannel/rooms';
@@ -108,6 +109,7 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
108109
tags: [tagB.data.name],
109110
}),
110111
]);
112+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
111113
});
112114

113115
test.beforeEach(async ({ page }: { page: Page }) => {
@@ -132,6 +134,7 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
132134
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }),
133135
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }),
134136
]);
137+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
135138
});
136139

137140
// Change conversation A to on hold and close conversation B

apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-filters.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IS_EE } from '../config/constants';
33
import { Users } from '../fixtures/userStates';
44
import { Navbar } from '../page-objects/fragments';
55
import { OmnichannelContactCenterChats } from '../page-objects/omnichannel';
6+
import { setSettingValueById } from '../utils';
67
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
78
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
89
import { createConversation, updateRoom } from '../utils/omnichannel/rooms';
@@ -128,6 +129,7 @@ test.describe('OC - Contact Center', async () => {
128129
tags: [tagB.data.name],
129130
}),
130131
]);
132+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
131133
});
132134

133135
test.afterAll(async ({ api }) => {
@@ -146,6 +148,7 @@ test.describe('OC - Contact Center', async () => {
146148
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }),
147149
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }),
148150
]);
151+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
149152
});
150153

151154
// Change conversation A to on hold and close conversation B

apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { IS_EE } from '../config/constants';
55
import { Users } from '../fixtures/userStates';
66
import { HomeOmnichannel } from '../page-objects';
77
import { OmnichannelAgents, OmnichannelManager, OmnichannelMonitors } from '../page-objects/omnichannel';
8+
import { setSettingValueById } from '../utils';
89
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
910
import { createDepartment } from '../utils/omnichannel/departments';
1011
import { createManager } from '../utils/omnichannel/managers';
@@ -79,6 +80,7 @@ test.describe('OC - Manager Role', () => {
7980
agentId: `user2`,
8081
}),
8182
]);
83+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
8284
});
8385

8486
// Delete all created data
@@ -92,6 +94,7 @@ test.describe('OC - Manager Role', () => {
9294
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }),
9395
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }),
9496
]);
97+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
9598
});
9699

97100
test.beforeEach(async ({ page }: { page: Page }) => {

apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-department.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Page } from '@playwright/test';
44
import { IS_EE } from '../config/constants';
55
import { Users } from '../fixtures/userStates';
66
import { OmnichannelDepartments } from '../page-objects/omnichannel';
7+
import { setSettingValueById } from '../utils';
78
import { createAgent } from '../utils/omnichannel/agents';
89
import { createDepartment } from '../utils/omnichannel/departments';
910
import { createMonitor } from '../utils/omnichannel/monitors';
@@ -63,16 +64,18 @@ test.describe.serial('OC - Monitor Role', () => {
6364
departments: [{ departmentId: departmentA._id }],
6465
}),
6566
]);
67+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
6668
});
6769

6870
// Delete all created data
69-
test.afterAll(async () => {
71+
test.afterAll(async ({ api }) => {
7072
await Promise.all([
7173
...agents.map((agent) => agent.delete()),
7274
...departments.map((department) => department.delete()),
7375
...units.map((unit) => unit.delete()),
7476
monitor.delete(),
7577
]);
78+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
7679
});
7780

7881
test.beforeEach(async ({ page }: { page: Page }) => {

apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Page } from '@playwright/test';
44
import { IS_EE } from '../config/constants';
55
import { Users } from '../fixtures/userStates';
66
import { HomeOmnichannel } from '../page-objects';
7+
import { setSettingValueById } from '../utils';
78
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
89
import { createDepartment } from '../utils/omnichannel/departments';
910
import { createMonitor } from '../utils/omnichannel/monitors';
@@ -44,7 +45,7 @@ test.describe('OC - Monitor Role', () => {
4445
const responses = await Promise.all([
4546
api.post('/settings/Livechat_allow_manual_on_hold', { value: true }),
4647
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: false }),
47-
api.post('/settings/Omnichannel_enable_department_removal', { value: true }),
48+
setSettingValueById(api, 'Omnichannel_enable_department_removal', true),
4849
// This is required now we're sending a chat into a department with no agents and no default agent
4950
api.post('/settings/Livechat_accept_chats_with_no_agents', { value: true }),
5051
]);
@@ -124,7 +125,7 @@ test.describe('OC - Monitor Role', () => {
124125
// Reset setting
125126
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }),
126127
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }),
127-
api.post('/settings/Omnichannel_enable_department_removal', { value: false }),
128+
setSettingValueById(api, 'Omnichannel_enable_department_removal', false),
128129
api.post('/settings/Livechat_accept_chats_with_no_agents', { value: false }),
129130
]);
130131
});

apps/meteor/tests/e2e/omnichannel/omnichannel-tags.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Page } from '@playwright/test';
44
import { IS_EE } from '../config/constants';
55
import { Users } from '../fixtures/userStates';
66
import { OmnichannelTags } from '../page-objects/omnichannel';
7+
import { setSettingValueById } from '../utils';
78
import { createAgent } from '../utils/omnichannel/agents';
89
import { createDepartment } from '../utils/omnichannel/departments';
910
import { createTag } from '../utils/omnichannel/tags';
@@ -29,10 +30,15 @@ test.describe('OC - Manage Tags', () => {
2930
agent = await createAgent(api, 'user2');
3031
});
3132

32-
test.afterAll(async () => {
33+
test.beforeAll(async ({ api }) => {
34+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
35+
});
36+
37+
test.afterAll(async ({ api }) => {
3338
await department.delete();
3439
await department2.delete();
3540
await agent.delete();
41+
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
3642
});
3743

3844
test.beforeEach(async ({ page }: { page: Page }) => {

0 commit comments

Comments
 (0)