From aa27d12551b41400f0e5f255a748b5f4e247e83a Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 24 Feb 2023 09:39:09 -0300 Subject: [PATCH] Close every opened page after the test --- ...nichannel-auto-onhold-chat-closing.spec.ts | 19 +++++++-------- ...nnel-auto-transfer-unanswered-chat.spec.ts | 22 ++++++++--------- ...nel-changing-room-priority-and-sla.spec.ts | 24 ++++++++++--------- .../tests/e2e/omnichannel-close-chat.spec.ts | 1 + .../e2e/omnichannel-send-transcript.spec.ts | 1 + .../tests/e2e/omnichannel-takeChat.spec.ts | 20 ++++++++-------- ...channel-transfer-to-another-agents.spec.ts | 23 +++++++++--------- 7 files changed, 56 insertions(+), 54 deletions(-) diff --git a/apps/meteor/tests/e2e/omnichannel-auto-onhold-chat-closing.spec.ts b/apps/meteor/tests/e2e/omnichannel-auto-onhold-chat-closing.spec.ts index c1d6270fd3fc..72b9ab09a1b7 100644 --- a/apps/meteor/tests/e2e/omnichannel-auto-onhold-chat-closing.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-auto-onhold-chat-closing.spec.ts @@ -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 @@ -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(); - }); }); diff --git a/apps/meteor/tests/e2e/omnichannel-auto-transfer-unanswered-chat.spec.ts b/apps/meteor/tests/e2e/omnichannel-auto-transfer-unanswered-chat.spec.ts index 77876318f29a..2f4631dfe9e9 100644 --- a/apps/meteor/tests/e2e/omnichannel-auto-transfer-unanswered-chat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-auto-transfer-unanswered-chat.spec.ts @@ -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'); @@ -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(); - }); }); diff --git a/apps/meteor/tests/e2e/omnichannel-changing-room-priority-and-sla.spec.ts b/apps/meteor/tests/e2e/omnichannel-changing-room-priority-and-sla.spec.ts index 197a171d0bf8..030d4572fe3d 100644 --- a/apps/meteor/tests/e2e/omnichannel-changing-room-priority-and-sla.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-changing-room-priority-and-sla.spec.ts @@ -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(), @@ -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); - }); }); diff --git a/apps/meteor/tests/e2e/omnichannel-close-chat.spec.ts b/apps/meteor/tests/e2e/omnichannel-close-chat.spec.ts index b509e1aa305f..5ab2ca871f24 100644 --- a/apps/meteor/tests/e2e/omnichannel-close-chat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-close-chat.spec.ts @@ -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 }) => { diff --git a/apps/meteor/tests/e2e/omnichannel-send-transcript.spec.ts b/apps/meteor/tests/e2e/omnichannel-send-transcript.spec.ts index 338e36b9e10f..2d8d465779e1 100644 --- a/apps/meteor/tests/e2e/omnichannel-send-transcript.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-send-transcript.spec.ts @@ -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 }) => { diff --git a/apps/meteor/tests/e2e/omnichannel-takeChat.spec.ts b/apps/meteor/tests/e2e/omnichannel-takeChat.spec.ts index d61201a609ff..a77836cbcce8 100644 --- a/apps/meteor/tests/e2e/omnichannel-takeChat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-takeChat.spec.ts @@ -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'); @@ -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(); diff --git a/apps/meteor/tests/e2e/omnichannel-transfer-to-another-agents.spec.ts b/apps/meteor/tests/e2e/omnichannel-transfer-to-another-agents.spec.ts index 7f8cef2e3704..2435b3a256a7 100644 --- a/apps/meteor/tests/e2e/omnichannel-transfer-to-another-agents.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-transfer-to-another-agents.spec.ts @@ -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'); @@ -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);