Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ test.describe.serial('OC - Manage Agents', () => {
await poOmnichannelAgents.sidebar.linkAgents.click();
});

test.beforeAll(async ({ api }) => {
expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: true })).status()).toBe(200);
});

test.afterAll(async ({ api }) => {
expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: false })).status()).toBe(200);
});

// Ensure that there is no leftover data even if test fails
test.afterEach(async ({ api }) => {
await api.delete('/livechat/users/agent/user1');
await api.post('/settings/Omnichannel_enable_department_removal', { value: true }).then((res) => expect(res.status()).toBe(200));
await department.delete();
await api.post('/settings/Omnichannel_enable_department_removal', { value: false }).then((res) => expect(res.status()).toBe(200));
});

test('OC - Manage Agents - Add, search and remove using table', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createFakeVisitor } from '../../mocks/data';
import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeOmnichannel } from '../page-objects';
import { setSettingValueById } from '../utils';
import { createAgent } from '../utils/omnichannel/agents';
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
import { createConversation } from '../utils/omnichannel/rooms';
Expand All @@ -13,7 +14,7 @@ const visitorB = createFakeVisitor();

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

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

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

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

test.afterAll(async () => {
test.afterAll(async ({ api }) => {
await Promise.all(conversations.map((conversation) => conversation.delete()));
await Promise.all([tagA, tagB, globalTag, sharedTag].map((tag) => tag.delete()));
await agent.delete();
await departmentA.delete();
await departmentB.delete();
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', false)).status()).toBe(200);
});

test('Verify agent should see correct tags based on department association', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Page } from '@playwright/test';
import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { OmnichannelBusinessHours } from '../page-objects/omnichannel';
import { setSettingValueById } from '../utils';
import { createAgent } from '../utils/omnichannel/agents';
import { createBusinessHour } from '../utils/omnichannel/businessHours';
import { createDepartment } from '../utils/omnichannel/departments';
Expand All @@ -25,6 +26,7 @@ test.describe('OC - Business Hours', () => {
department = await createDepartment(api);
department2 = await createDepartment(api);
agent = await createAgent(api, 'user2');
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', true)).status()).toBe(200);
await api.post('/settings/Livechat_enable_business_hours', { value: true }).then((res) => expect(res.status()).toBe(200));
await api.post('/settings/Livechat_business_hour_type', { value: 'Multiple' }).then((res) => expect(res.status()).toBe(200));
});
Expand All @@ -33,6 +35,7 @@ test.describe('OC - Business Hours', () => {
await department.delete();
await department2.delete();
await agent.delete();
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', false)).status()).toBe(200);
await api.post('/settings/Livechat_enable_business_hours', { value: false }).then((res) => expect(res.status()).toBe(200));
await api.post('/settings/Livechat_business_hour_type', { value: 'Single' }).then((res) => expect(res.status()).toBe(200));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IS_EE } from '../config/constants';
import { createAuxContext } from '../fixtures/createAuxContext';
import { Users } from '../fixtures/userStates';
import { HomeOmnichannel } from '../page-objects';
import { setSettingValueById } from '../utils';
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
import { createManager } from '../utils/omnichannel/managers';
Expand Down Expand Up @@ -94,6 +95,7 @@ test.describe('OC - Chat transfers [Monitor role]', () => {
departments: [{ departmentId: departmentB._id }],
}),
]);
expect((await setSettingValueById(api, 'Omnichannel_enable_department_removal', true)).status()).toBe(200);
});

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

test.afterAll(async () => {
test.afterAll(async ({ api }) => {
await Promise.all([
...conversations.map((conversation) => conversation.delete()),
...monitors.map((monitor) => monitor.delete()),
...agents.map((agent) => agent.delete()),
...units.map((unit) => unit.delete()),
...departments.map((department) => department.delete()),
]);
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
});

test(`OC - Chat transfers [Monitor role] - Transfer to department with no online agents should fail`, async ({ api }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeOmnichannel } from '../page-objects';
import { OmnichannelContactCenterChats } from '../page-objects/omnichannel';
import { setSettingValueById } from '../utils';
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
import { createConversation, updateRoom } from '../utils/omnichannel/rooms';
Expand Down Expand Up @@ -108,6 +109,7 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
tags: [tagB.data.name],
}),
]);
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
});

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

// Change conversation A to on hold and close conversation B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { Navbar } from '../page-objects/fragments';
import { OmnichannelContactCenterChats } from '../page-objects/omnichannel';
import { setSettingValueById } from '../utils';
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
import { createConversation, updateRoom } from '../utils/omnichannel/rooms';
Expand Down Expand Up @@ -128,6 +129,7 @@ test.describe('OC - Contact Center', async () => {
tags: [tagB.data.name],
}),
]);
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
});

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

// Change conversation A to on hold and close conversation B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeOmnichannel } from '../page-objects';
import { OmnichannelAgents, OmnichannelManager, OmnichannelMonitors } from '../page-objects/omnichannel';
import { setSettingValueById } from '../utils';
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
import { createDepartment } from '../utils/omnichannel/departments';
import { createManager } from '../utils/omnichannel/managers';
Expand Down Expand Up @@ -79,6 +80,7 @@ test.describe('OC - Manager Role', () => {
agentId: `user2`,
}),
]);
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
});

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

test.beforeEach(async ({ page }: { page: Page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test';
import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { OmnichannelDepartments } from '../page-objects/omnichannel';
import { setSettingValueById } from '../utils';
import { createAgent } from '../utils/omnichannel/agents';
import { createDepartment } from '../utils/omnichannel/departments';
import { createMonitor } from '../utils/omnichannel/monitors';
Expand Down Expand Up @@ -63,16 +64,18 @@ test.describe.serial('OC - Monitor Role', () => {
departments: [{ departmentId: departmentA._id }],
}),
]);
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
});

// Delete all created data
test.afterAll(async () => {
test.afterAll(async ({ api }) => {
await Promise.all([
...agents.map((agent) => agent.delete()),
...departments.map((department) => department.delete()),
...units.map((unit) => unit.delete()),
monitor.delete(),
]);
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
});

test.beforeEach(async ({ page }: { page: Page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test';
import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeOmnichannel } from '../page-objects';
import { setSettingValueById } from '../utils';
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
import { createDepartment } from '../utils/omnichannel/departments';
import { createMonitor } from '../utils/omnichannel/monitors';
Expand Down Expand Up @@ -44,7 +45,7 @@ test.describe('OC - Monitor Role', () => {
const responses = await Promise.all([
api.post('/settings/Livechat_allow_manual_on_hold', { value: true }),
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: false }),
api.post('/settings/Omnichannel_enable_department_removal', { value: true }),
setSettingValueById(api, 'Omnichannel_enable_department_removal', true),
// This is required now we're sending a chat into a department with no agents and no default agent
api.post('/settings/Livechat_accept_chats_with_no_agents', { value: true }),
]);
Expand Down Expand Up @@ -124,7 +125,7 @@ test.describe('OC - Monitor Role', () => {
// Reset setting
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }),
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }),
api.post('/settings/Omnichannel_enable_department_removal', { value: false }),
setSettingValueById(api, 'Omnichannel_enable_department_removal', false),
api.post('/settings/Livechat_accept_chats_with_no_agents', { value: false }),
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test';
import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { OmnichannelTags } from '../page-objects/omnichannel';
import { setSettingValueById } from '../utils';
import { createAgent } from '../utils/omnichannel/agents';
import { createDepartment } from '../utils/omnichannel/departments';
import { createTag } from '../utils/omnichannel/tags';
Expand All @@ -29,10 +30,15 @@ test.describe('OC - Manage Tags', () => {
agent = await createAgent(api, 'user2');
});

test.afterAll(async () => {
test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
});

test.afterAll(async ({ api }) => {
await department.delete();
await department2.delete();
await agent.delete();
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
});

test.beforeEach(async ({ page }: { page: Page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test';
import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { OmnichannelUnits } from '../page-objects/omnichannel';
import { setSettingValueById } from '../utils';
import { createAgent } from '../utils/omnichannel/agents';
import { createDepartment } from '../utils/omnichannel/departments';
import { createMonitor } from '../utils/omnichannel/monitors';
Expand Down Expand Up @@ -40,12 +41,17 @@ test.describe('OC - Manage Units', () => {
monitor2 = await createMonitor(api, 'user3');
});

test.afterAll(async () => {
test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
});

test.afterAll(async ({ api }) => {
await department.delete();
await department2.delete();
await monitor.delete();
await monitor2.delete();
await agent.delete();
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
});

test.beforeEach(async ({ page }: { page: Page }) => {
Expand Down
Loading