Skip to content

Commit 7fadcc3

Browse files
committed
tests
1 parent 1e5b840 commit 7fadcc3

File tree

6 files changed

+177
-81
lines changed

6 files changed

+177
-81
lines changed

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

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ 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';
7-
import { createConversation } from '../utils/omnichannel/rooms';
8+
import { createConversation, waitForInquiryToBeTaken } from '../utils/omnichannel/rooms';
89
import { createTag } from '../utils/omnichannel/tags';
910
import { test, expect } from '../utils/test';
1011

@@ -26,6 +27,14 @@ test.describe('OC - Tags Visibility', () => {
2627
let globalTag: Awaited<ReturnType<typeof createTag>>;
2728
let sharedTag: Awaited<ReturnType<typeof createTag>>;
2829

30+
test.beforeAll('Configure queue settings', async ({ api }) => {
31+
const responses = await Promise.all([
32+
setSettingValueById(api, 'Livechat_waiting_queue', true),
33+
setSettingValueById(api, 'Omnichannel_queue_delay_timeout', 1),
34+
]);
35+
responses.forEach((res) => expect(res.status()).toBe(200));
36+
});
37+
2938
test.beforeAll('Create departments', async ({ api }) => {
3039
departmentA = await createDepartment(api, { name: 'Department A' });
3140
departmentB = await createDepartment(api, { name: 'Department B' });
@@ -52,30 +61,39 @@ test.describe('OC - Tags Visibility', () => {
5261
});
5362

5463
test.beforeAll('Create conversations', async ({ api }) => {
55-
const conversationA = await createConversation(api, {
56-
visitorName: visitorA.name,
57-
agentId: 'user1',
58-
departmentId: departmentA.data._id,
59-
});
60-
const conversationB = await createConversation(api, {
61-
visitorName: visitorB.name,
62-
agentId: 'user1',
63-
departmentId: departmentB.data._id,
64-
});
65-
conversations = [conversationA, conversationB];
64+
conversations = await Promise.all([
65+
createConversation(api, {
66+
visitorName: visitorA.name,
67+
agentId: 'user1',
68+
departmentId: departmentA.data._id,
69+
}),
70+
createConversation(api, {
71+
visitorName: visitorB.name,
72+
agentId: 'user1',
73+
departmentId: departmentB.data._id,
74+
}),
75+
]);
76+
await waitForInquiryToBeTaken(
77+
api,
78+
conversations.map((c) => c.data.room._id),
79+
);
6680
});
6781

6882
test.beforeEach(async ({ page }) => {
6983
poOmnichannel = new HomeOmnichannel(page);
7084
await page.goto('/');
7185
});
7286

73-
test.afterAll(async () => {
74-
await Promise.all(conversations.map((conversation) => conversation.delete()));
75-
await Promise.all([tagA, tagB, globalTag, sharedTag].map((tag) => tag.delete()));
76-
await agent.delete();
77-
await departmentA.delete();
78-
await departmentB.delete();
87+
test.afterAll(async ({ api }) => {
88+
await Promise.all([
89+
...conversations.map((conversation) => conversation.delete()),
90+
[tagA, tagB, globalTag, sharedTag].map((tag) => tag.delete()),
91+
agent.delete(),
92+
departmentA.delete(),
93+
departmentB.delete(),
94+
setSettingValueById(api, 'Livechat_waiting_queue', false),
95+
setSettingValueById(api, 'Omnichannel_queue_delay_timeout', 5),
96+
]);
7997
});
8098

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

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

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ 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';
1011
import { createMonitor } from '../utils/omnichannel/monitors';
11-
import { createConversation } from '../utils/omnichannel/rooms';
12+
import { createConversation, waitForInquiryToBeTaken } from '../utils/omnichannel/rooms';
1213
import { createOrUpdateUnit } from '../utils/omnichannel/units';
1314
import { 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

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Users } from '../fixtures/userStates';
44
import { OmnichannelChats } from '../page-objects/omnichannel-contact-center-chats';
55
import { setSettingValueById } from '../utils';
66
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
7-
import { createConversation } from '../utils/omnichannel/rooms';
7+
import { createConversation, waitForInquiryToBeTaken } from '../utils/omnichannel/rooms';
88
import { test, expect } from '../utils/test';
99

1010
test.use({ storageState: Users.user1.state });
@@ -30,9 +30,17 @@ test.describe('OC - Contact Center - Chats', () => {
3030
});
3131

3232
test.beforeAll(async ({ api }) => {
33+
// run synchronously because this test runs in the CE environment,
34+
// which lacks the waiting queue setting. with parallel execution,
35+
// the agent lock would prevent the second assignment and keep the
36+
// conversation in READY state (see RoutingManager.ts:118)
3337
const conversationA = await createConversation(api, { agentId: `user1`, visitorName: visitorA });
3438
const conversationB = await createConversation(api, { agentId: `user1`, visitorName: visitorB });
3539
conversations = [conversationA, conversationB];
40+
await waitForInquiryToBeTaken(
41+
api,
42+
conversations.map((c) => c.data.room._id),
43+
);
3644
});
3745

3846
test.beforeEach(async ({ page }) => {

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import type { Page } from '@playwright/test';
44
import { IS_EE } from '../config/constants';
55
import { Users } from '../fixtures/userStates';
66
import { OmnichannelChats } from '../page-objects';
7+
import { setSettingValueById } from '../utils';
78
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
89
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
9-
import { createConversation, updateRoom } from '../utils/omnichannel/rooms';
10+
import { createConversation, updateRoom, waitForInquiryToBeTaken } from '../utils/omnichannel/rooms';
1011
import { createTag } from '../utils/omnichannel/tags';
1112
import { test, expect } from '../utils/test';
1213

@@ -29,8 +30,10 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
2930
// Allow manual on hold
3031
test.beforeAll(async ({ api }) => {
3132
const responses = await Promise.all([
32-
api.post('/settings/Livechat_allow_manual_on_hold', { value: true }),
33-
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: false }),
33+
setSettingValueById(api, 'Livechat_allow_manual_on_hold', true),
34+
setSettingValueById(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', false),
35+
setSettingValueById(api, 'Livechat_waiting_queue', true),
36+
setSettingValueById(api, 'Omnichannel_queue_delay_timeout', 1),
3437
]);
3538
responses.forEach((res) => expect(res.status()).toBe(200));
3639
});
@@ -92,6 +95,11 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
9295
}),
9396
]);
9497

98+
await waitForInquiryToBeTaken(
99+
api,
100+
conversations.map((c) => c.data.room._id),
101+
);
102+
95103
const [conversationA, conversationB] = conversations.map(({ data }) => data);
96104

97105
await Promise.all([
@@ -126,8 +134,10 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
126134
// Delete tags
127135
...[tagA, tagB].map((tag) => tag.delete()),
128136
// Reset setting
129-
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }),
130-
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }),
137+
setSettingValueById(api, 'Livechat_allow_manual_on_hold', false),
138+
setSettingValueById(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', true),
139+
setSettingValueById(api, 'Livechat_waiting_queue', false),
140+
setSettingValueById(api, 'Omnichannel_queue_delay_timeout', 5),
131141
]);
132142
});
133143

0 commit comments

Comments
 (0)