Skip to content

Commit

Permalink
await expect commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Feb 16, 2023
1 parent 3668d20 commit 30d8902
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 85 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/administration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/tests/e2e/omnichannel-agents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
);
});
Expand All @@ -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}`,
);

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/omnichannel-contact-center.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/omnichannel-custom-fields.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/omnichannel-triggers.spec.ts
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
60 changes: 30 additions & 30 deletions apps/meteor/tests/e2e/page-objects/omnichannel-priorities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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}"`) });
}
}
72 changes: 36 additions & 36 deletions apps/meteor/tests/e2e/page-objects/omnichannel-sla-policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"');
}
}
8 changes: 1 addition & 7 deletions apps/meteor/tests/e2e/system-messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 30d8902

Please sign in to comment.