From 30d890255af3b45e72f4834c3e542f99a1cdd351 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Thu, 16 Feb 2023 01:32:36 -0300 Subject: [PATCH] await expect commands --- apps/meteor/tests/e2e/administration.spec.ts | 2 +- .../tests/e2e/omnichannel-agents.spec.ts | 4 +- ...nichannel-auto-onhold-chat-closing.spec.ts | 8 ++- ...nel-changing-room-priority-and-sla.spec.ts | 4 +- .../e2e/omnichannel-contact-center.spec.ts | 2 +- .../e2e/omnichannel-custom-fields.spec.ts | 2 +- .../tests/e2e/omnichannel-triggers.spec.ts | 2 +- .../page-objects/fragments/home-sidenav.ts | 2 +- .../page-objects/omnichannel-priorities.ts | 60 ++++++++-------- .../page-objects/omnichannel-sla-policies.ts | 72 +++++++++---------- apps/meteor/tests/e2e/system-messages.spec.ts | 8 +-- 11 files changed, 81 insertions(+), 85 deletions(-) diff --git a/apps/meteor/tests/e2e/administration.spec.ts b/apps/meteor/tests/e2e/administration.spec.ts index 191d9da14fa1..0811f4cb49f3 100644 --- a/apps/meteor/tests/e2e/administration.spec.ts +++ b/apps/meteor/tests/e2e/administration.spec.ts @@ -33,7 +33,7 @@ test.describe.parallel('administration', () => { test('expect find "user1" user', async ({ page }) => { await poAdmin.inputSearchUsers.type('user1'); - expect(page.locator('table tr[qa-user-id="user1"]')).toBeVisible(); + await expect(page.locator('table tr[qa-user-id="user1"]')).toBeVisible(); }); test('expect create a user', async () => { diff --git a/apps/meteor/tests/e2e/omnichannel-agents.spec.ts b/apps/meteor/tests/e2e/omnichannel-agents.spec.ts index a26c7bea742e..02b42be9b6c9 100644 --- a/apps/meteor/tests/e2e/omnichannel-agents.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-agents.spec.ts @@ -19,7 +19,7 @@ test.describe.serial('omnichannel-agents', () => { await poOmnichannelAgents.btnAdd.click(); await poOmnichannelAgents.inputSearch.fill('user1'); - expect(poOmnichannelAgents.firstRowInTable).toBeVisible(); + await expect(poOmnichannelAgents.firstRowInTable).toBeVisible(); }); test('expect update "user1" status', async ({ page }) => { @@ -38,6 +38,6 @@ test.describe.serial('omnichannel-agents', () => { await poOmnichannelAgents.btnModalRemove.click(); await poOmnichannelAgents.inputSearch.fill('user1'); - expect(poOmnichannelAgents.firstRowInTable).toBeHidden(); + await expect(poOmnichannelAgents.firstRowInTable).toBeHidden(); }); }); 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 ae6ec3db9e96..4831c4842297 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 @@ -68,9 +68,11 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => { await agent.poHomeChannel.content.btnModalConfirm.click(); // expect to see a system message saying the chat was on-hold - expect(agent.poHomeChannel.content.lastSystemMessageBody).toHaveText(`Chat On Hold: The chat was manually placed On Hold by user1`); - expect(agent.poHomeChannel.content.inputMessage).not.toBeVisible(); - expect(agent.poHomeChannel.content.resumeOnHoldOmnichannelChatButton).toBeVisible(); + await expect(agent.poHomeChannel.content.lastSystemMessageBody).toHaveText( + `Chat On Hold: The chat was manually placed On Hold by user1`, + ); + await expect(agent.poHomeChannel.content.inputMessage).not.toBeVisible(); + await expect(agent.poHomeChannel.content.resumeOnHoldOmnichannelChatButton).toBeVisible(); // current url const chatRoomUrl = agent.page.url(); 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 1ab778aa5097..4c3730886c98 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 @@ -74,7 +74,7 @@ test.describe('omnichannel-changing-room-priority-and-sla', () => { await agent.page.waitForTimeout(1000); }); - expect(agent.poHomeChannel.content.lastSystemMessageBody).toHaveText( + await expect(agent.poHomeChannel.content.lastSystemMessageBody).toHaveText( `Priority changed: ${ADMIN_CREDENTIALS.username} changed the priority to ${priority.name || priority.i18n}`, ); }); @@ -88,7 +88,7 @@ test.describe('omnichannel-changing-room-priority-and-sla', () => { await agent.page.waitForTimeout(1000); }); - expect(agent.poHomeChannel.content.lastSystemMessageBody).toHaveText( + await expect(agent.poHomeChannel.content.lastSystemMessageBody).toHaveText( `SLA Policy changed: ${ADMIN_CREDENTIALS.username} changed the SLA Policy to ${sla.name}`, ); diff --git a/apps/meteor/tests/e2e/omnichannel-contact-center.spec.ts b/apps/meteor/tests/e2e/omnichannel-contact-center.spec.ts index 9f6f74a919ac..440b886cfaf8 100644 --- a/apps/meteor/tests/e2e/omnichannel-contact-center.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-contact-center.spec.ts @@ -155,7 +155,7 @@ test.describe('Omnichannel Contact Center', () => { }); await test.step('edit contact', async () => { - poContacts.contactInfo.btnEdit.click(); + await poContacts.contactInfo.btnEdit.click(); await page.waitForURL(URL.editContact); }); diff --git a/apps/meteor/tests/e2e/omnichannel-custom-fields.spec.ts b/apps/meteor/tests/e2e/omnichannel-custom-fields.spec.ts index 000b316fc249..614ea47f91b0 100644 --- a/apps/meteor/tests/e2e/omnichannel-custom-fields.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-custom-fields.spec.ts @@ -42,6 +42,6 @@ test.describe.serial('omnichannel-agents', () => { await poOmnichannelCustomFields.btnModalRemove.click(); await poOmnichannelCustomFields.inputSearch.fill(newField); - expect(poOmnichannelCustomFields.firstRowInTable(newField)).toBeHidden(); + await expect(poOmnichannelCustomFields.firstRowInTable(newField)).toBeHidden(); }); }); diff --git a/apps/meteor/tests/e2e/omnichannel-triggers.spec.ts b/apps/meteor/tests/e2e/omnichannel-triggers.spec.ts index d68936ca4a97..5b3a5e308f9a 100644 --- a/apps/meteor/tests/e2e/omnichannel-triggers.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel-triggers.spec.ts @@ -1,8 +1,8 @@ import { faker } from '@faker-js/faker'; import type { Browser, Page } from '@playwright/test'; -import { test, expect } from './utils/test'; import { OmnichannelLiveChat, HomeOmnichannel } from './page-objects'; +import { test, expect } from './utils/test'; const createAuxContext = async (browser: Browser, storageState: string): Promise<{ page: Page; poHomeOmnichannel: HomeOmnichannel }> => { const page = await browser.newPage({ storageState }); diff --git a/apps/meteor/tests/e2e/page-objects/fragments/home-sidenav.ts b/apps/meteor/tests/e2e/page-objects/fragments/home-sidenav.ts index 1ee25ca90f00..72a843521870 100644 --- a/apps/meteor/tests/e2e/page-objects/fragments/home-sidenav.ts +++ b/apps/meteor/tests/e2e/page-objects/fragments/home-sidenav.ts @@ -69,7 +69,7 @@ export class HomeSidenav { async switchOmnichannelStatus(status: 'offline' | 'online') { // button has a id of "omnichannel-status-toggle" const toggleButton = this.page.locator('#omnichannel-status-toggle'); - expect(toggleButton).toBeVisible(); + await expect(toggleButton).toBeVisible(); enum StatusTitleMap { offline = 'Turn on answer chats', diff --git a/apps/meteor/tests/e2e/page-objects/omnichannel-priorities.ts b/apps/meteor/tests/e2e/page-objects/omnichannel-priorities.ts index 01d7ec5021b5..1941c78f92ca 100644 --- a/apps/meteor/tests/e2e/page-objects/omnichannel-priorities.ts +++ b/apps/meteor/tests/e2e/page-objects/omnichannel-priorities.ts @@ -2,36 +2,6 @@ import type { Locator, Page } from '@playwright/test'; import { OmnichannelSidenav } from './fragments'; -export class OmnichannelPriorities { - private readonly page: Page; - - readonly managePriority: OmnichannelManagePriority; - - readonly sidenav: OmnichannelSidenav; - - constructor(page: Page) { - this.page = page; - this.managePriority = new OmnichannelManagePriority(page); - this.sidenav = new OmnichannelSidenav(page); - } - - get toastSuccess(): Locator { - return this.page.locator('.rcx-toastbar.rcx-toastbar--success'); - } - - get btnReset() { - return this.page.locator('role=button[name="Reset"]'); - } - - get btnResetConfirm() { - return this.page.locator('.rcx-modal').locator('role=button[name="Reset"]'); - } - - findPriority(name: string) { - return this.page.locator('tr', { has: this.page.locator(`td >> text="${name}"`) }); - } -} - class OmnichannelManagePriority { private readonly page: Page; @@ -63,3 +33,33 @@ class OmnichannelManagePriority { return this.page.locator(`.rcx-field__error >> text="${message}"`); } } + +export class OmnichannelPriorities { + private readonly page: Page; + + readonly managePriority: OmnichannelManagePriority; + + readonly sidenav: OmnichannelSidenav; + + constructor(page: Page) { + this.page = page; + this.managePriority = new OmnichannelManagePriority(page); + this.sidenav = new OmnichannelSidenav(page); + } + + get toastSuccess(): Locator { + return this.page.locator('.rcx-toastbar.rcx-toastbar--success'); + } + + get btnReset() { + return this.page.locator('role=button[name="Reset"]'); + } + + get btnResetConfirm() { + return this.page.locator('.rcx-modal').locator('role=button[name="Reset"]'); + } + + findPriority(name: string) { + return this.page.locator('tr', { has: this.page.locator(`td >> text="${name}"`) }); + } +} diff --git a/apps/meteor/tests/e2e/page-objects/omnichannel-sla-policies.ts b/apps/meteor/tests/e2e/page-objects/omnichannel-sla-policies.ts index 8be1ecc1a81b..3c75fab117f3 100644 --- a/apps/meteor/tests/e2e/page-objects/omnichannel-sla-policies.ts +++ b/apps/meteor/tests/e2e/page-objects/omnichannel-sla-policies.ts @@ -2,80 +2,80 @@ import type { Locator, Page } from '@playwright/test'; import { OmnichannelSidenav } from './fragments'; -export class OmnichannelSlaPolicies { +class OmnichannelManageSlaPolicy { private readonly page: Page; - readonly manageSlaPolicy: OmnichannelManageSlaPolicy; - - readonly sidenav: OmnichannelSidenav; - constructor(page: Page) { this.page = page; - this.manageSlaPolicy = new OmnichannelManageSlaPolicy(page); - this.sidenav = new OmnichannelSidenav(page); } - findRowByName(name: string) { - return this.page.locator('tr', { has: this.page.locator(`td >> text="${name}"`) }); + get inputName(): Locator { + return this.page.locator('[name="name"]'); } - btnRemove(name: string) { - return this.findRowByName(name).locator('button[title="Remove"]'); + get inputDescription(): Locator { + return this.page.locator('[name="description"]'); } - get inputSearch() { - return this.page.locator('[placeholder="Search"]'); + get inputEstimatedWaitTime(): Locator { + return this.page.locator('[name="dueTimeInMinutes"]'); } - get btnNew() { - return this.page.locator('button.rcx-button >> text="New"'); + get btnClose() { + return this.page.locator('button.rcx-button >> text="Close"'); } - get btnDelete() { - return this.page.locator('button.rcx-button >> text="Delete"'); + get btnCancel() { + return this.page.locator('button.rcx-button >> text="Cancel"'); } - get txtDeleteModalTitle() { - return this.page.locator('div.rcx-modal__title >> text="Are you sure?"'); + get btnSave() { + return this.page.locator('button.rcx-button >> text="Save"'); } - get txtEmptyState() { - return this.page.locator('div >> text="No data found"'); + errorMessage(message: string): Locator { + return this.page.locator(`.rcx-field__error >> text="${message}"`); } } -class OmnichannelManageSlaPolicy { +export class OmnichannelSlaPolicies { private readonly page: Page; + readonly manageSlaPolicy: OmnichannelManageSlaPolicy; + + readonly sidenav: OmnichannelSidenav; + constructor(page: Page) { this.page = page; + this.manageSlaPolicy = new OmnichannelManageSlaPolicy(page); + this.sidenav = new OmnichannelSidenav(page); } - get inputName(): Locator { - return this.page.locator('[name="name"]'); + findRowByName(name: string) { + return this.page.locator('tr', { has: this.page.locator(`td >> text="${name}"`) }); } - get inputDescription(): Locator { - return this.page.locator('[name="description"]'); + btnRemove(name: string) { + return this.findRowByName(name).locator('button[title="Remove"]'); } - get inputEstimatedWaitTime(): Locator { - return this.page.locator('[name="dueTimeInMinutes"]'); + get inputSearch() { + return this.page.locator('[placeholder="Search"]'); } - get btnClose() { - return this.page.locator('button.rcx-button >> text="Close"'); + get btnNew() { + return this.page.locator('button.rcx-button >> text="New"'); } - get btnCancel() { - return this.page.locator('button.rcx-button >> text="Cancel"'); + get btnDelete() { + return this.page.locator('button.rcx-button >> text="Delete"'); } - get btnSave() { - return this.page.locator('button.rcx-button >> text="Save"'); + get txtDeleteModalTitle() { + return this.page.locator('div.rcx-modal__title >> text="Are you sure?"'); } - errorMessage(message: string): Locator { - return this.page.locator(`.rcx-field__error >> text="${message}"`); + get txtEmptyState() { + return this.page.locator('div >> text="No data found"'); } } diff --git a/apps/meteor/tests/e2e/system-messages.spec.ts b/apps/meteor/tests/e2e/system-messages.spec.ts index 52c3c687fffc..97b28c714fee 100644 --- a/apps/meteor/tests/e2e/system-messages.spec.ts +++ b/apps/meteor/tests/e2e/system-messages.spec.ts @@ -18,19 +18,13 @@ const userData = { // There currently are over 33 system messages. Testing only a couple due to test being too slow right now. // Ideally, we should test all. -const a = async () => { - console.log('das'); -}; test.describe.serial('System Messages', () => { let adminPage: Page; let poHomeChannel: HomeChannel; let group: IRoom; let user: IUser; - const findSysMes = (id: string): Locator => { - a(); - return adminPage.locator(`[data-qa="system-message"][data-system-message-type="${id}"]`); - }; + const findSysMes = (id: string): Locator => adminPage.locator(`[data-qa="system-message"][data-system-message-type="${id}"]`); test.beforeAll(async ({ api, browser }) => { expect((await setSettingValueById(api, 'Hide_System_Messages', [])).status()).toBe(200);