Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: e2e omnichannel tests - Close every opened page after the test #28152

Merged
merged 1 commit into from
Feb 24, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => {
const { page } = await createAuxContext(browser, Users.user1);
agent = { page, poHomeChannel: new HomeChannel(page) };
});
test.afterAll(async ({ api }) => {
await Promise.all([
api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_auto_close_on_hold_chats_timeout', { value: 3600 }).then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }).then((res) => expect(res.status()).toBe(200)),
]);

await agent.page.close();
});

test.beforeEach(async ({ page }) => {
// make "user-1" online
Expand Down Expand Up @@ -71,14 +80,4 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => {
'Conversation closed: Closed automatically because chat was On Hold for 5 seconds.',
);
});

test.afterAll(async ({ api }) => {
await Promise.all([
api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_auto_close_on_hold_chats_timeout', { value: 3600 }).then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }).then((res) => expect(res.status()).toBe(200)),
]);

await agent.page.close();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ test.describe('omnichannel-auto-transfer-unanswered-chat', () => {
agent2 = { page: page2, poHomeChannel: new HomeChannel(page2) };
});

test.afterAll(async ({ api }) => {
await Promise.all([
api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
api.delete('/livechat/users/agent/user2').then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_auto_transfer_chat_timeout', { value: 0 }).then((res) => expect(res.status()).toBe(200)),
]);

await agent1.page.close();
await agent2.page.close();
});

test.beforeEach(async ({ page }) => {
// make "user-1" online
await agent1.poHomeChannel.sidenav.switchOmnichannelStatus('online');
Expand Down Expand Up @@ -59,15 +70,4 @@ test.describe('omnichannel-auto-transfer-unanswered-chat', () => {

await agent2.poHomeChannel.sidenav.openChat(newVisitor.name);
});

test.afterAll(async ({ api }) => {
await Promise.all([
api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
api.delete('/livechat/users/agent/user2').then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_auto_transfer_chat_timeout', { value: 0 }).then((res) => expect(res.status()).toBe(200)),
]);

await agent1.page.close();
await agent2.page.close();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ test.describe('omnichannel-changing-room-priority-and-sla', () => {
await agent.poHomeChannel.sidenav.switchStatus('online');
});

test.afterAll(async ({ api }) => {
let statusCode = (await api.delete(`/livechat/users/agent/${ADMIN_CREDENTIALS.username}`)).status();
await expect(statusCode).toBe(200);

statusCode = (await api.delete(`/livechat/users/manager/${ADMIN_CREDENTIALS.username}`)).status();
await expect(statusCode).toBe(200);

statusCode = (await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' })).status();
await expect(statusCode).toBe(200);

await agent.page.close();
});

test('expect to initiate a new livechat conversation', async ({ page }) => {
newVisitor = {
name: faker.name.firstName(),
Expand Down Expand Up @@ -92,15 +105,4 @@ test.describe('omnichannel-changing-room-priority-and-sla', () => {
expect(status).toBe(200);
});
});

test.afterAll(async ({ api }) => {
let statusCode = (await api.delete(`/livechat/users/agent/${ADMIN_CREDENTIALS.username}`)).status();
await expect(statusCode).toBe(200);

statusCode = (await api.delete(`/livechat/users/manager/${ADMIN_CREDENTIALS.username}`)).status();
await expect(statusCode).toBe(200);

statusCode = (await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' })).status();
await expect(statusCode).toBe(200);
});
});
1 change: 1 addition & 0 deletions apps/meteor/tests/e2e/omnichannel-close-chat.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test.describe('Omnichannel close chat', () => {
test.afterAll(async ({ api }) => {
await api.delete('/livechat/users/agent/user1');
await api.delete('/livechat/users/manager/user1');
await agent.page.close();
});

test('Receiving a message from visitor', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test.describe('omnichannel-transcript', () => {
test.afterAll(async ({ api }) => {
await api.delete('/livechat/users/agent/user1');
await api.delete('/livechat/users/manager/user1');
await agent.page.close();
});

test('Receiving a message from visitor', async ({ page }) => {
Expand Down
20 changes: 10 additions & 10 deletions apps/meteor/tests/e2e/omnichannel-takeChat.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ test.describe('omnichannel-takeChat', () => {
agent = { page, poHomeChannel: new HomeChannel(page) };
});

test.afterAll(async ({ api }) => {
await Promise.all([
await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }).then((res) => expect(res.status()).toBe(200)),
await api.post('/settings/Livechat_enabled_when_agent_idle', { value: false }).then((res) => expect(res.status()).toBe(200)),
await api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
]);

await agent.page.close();
});

test.beforeEach(async ({ page }) => {
// make "user-1" online
await agent.poHomeChannel.sidenav.switchStatus('online');
Expand All @@ -40,16 +50,6 @@ test.describe('omnichannel-takeChat', () => {
await poLiveChat.btnSendMessageToOnlineAgent.click();
});

test.afterAll(async ({ api }) => {
await Promise.all([
await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }).then((res) => expect(res.status()).toBe(200)),
await api.post('/settings/Livechat_enabled_when_agent_idle', { value: false }).then((res) => expect(res.status()).toBe(200)),
await api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
]);

await agent.page.close();
});

test('expect "user1" to be able to take the chat from the queue', async () => {
await agent.poHomeChannel.sidenav.openQueuedOmnichannelChat(newVisitor.name);
await expect(agent.poHomeChannel.content.takeOmnichannelChatButton).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ test.describe('omnichannel-transfer-to-another-agent', () => {
agent2 = { page: page2, poHomeOmnichannel: new HomeOmnichannel(page2) };
});

test.afterAll(async ({ api }) => {
await Promise.all([
api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
api.delete('/livechat/users/manager/user1').then((res) => expect(res.status()).toBe(200)),
api.delete('/livechat/users/agent/user2').then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_enabled_when_agent_idle', { value: true }).then((res) => expect(res.status()).toBe(200)),
]);

await agent1.page.close();
await agent2.page.close();
});
test.beforeEach(async ({ page }) => {
// make "user-1" online & "user-2" offline so that chat can be automatically routed to "user-1"
await agent1.poHomeOmnichannel.sidenav.switchStatus('online');
Expand All @@ -45,18 +56,6 @@ test.describe('omnichannel-transfer-to-another-agent', () => {
await poLiveChat.btnSendMessageToOnlineAgent.click();
});

test.afterAll(async ({ api }) => {
await Promise.all([
api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
api.delete('/livechat/users/manager/user1').then((res) => expect(res.status()).toBe(200)),
api.delete('/livechat/users/agent/user2').then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_enabled_when_agent_idle', { value: true }).then((res) => expect(res.status()).toBe(200)),
]);

await agent1.page.close();
await agent2.page.close();
});

test('transfer omnichannel chat to another agent', async () => {
await test.step('Expect to have 1 omnichannel assigned to agent 1', async () => {
await agent1.poHomeOmnichannel.sidenav.openChat(newVisitor.name);
Expand Down