Skip to content

Commit

Permalink
Chore: create a test for managers screen (#26581)
Browse files Browse the repository at this point in the history
Co-authored-by: souzaramon <[email protected]>
  • Loading branch information
2 people authored and csuarez committed Aug 26, 2022
1 parent 7c36c15 commit fd37ff4
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const ManagersRoute = (): ReactElement => {
{t('Remove')}
</GenericTableHeaderCell>
</GenericTableHeader>
<GenericTableBody>
<GenericTableBody data-qa-id='GenericTableManagerInfoBody'>
{result.phase === AsyncStatePhase.LOADING && <GenericTableLoadingTable headerCells={2} />}
{result.phase === AsyncStatePhase.RESOLVED &&
result.value.users.length > 0 &&
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/tests/e2e/homepage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const CardIds = {
Desktop: 'homepage-desktop-apps-card',
Docs: 'homepage-documentation-card',
};

test.use({ storageState: 'admin-session.json' });

test.describe.serial('homepage', () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/message-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test.describe.serial('message-actions', () => {
await poHomeChannel.content.sendMessage(message);
await poHomeChannel.content.openLastMessageMenu();
await page.locator('[data-qa-id="quote-message"]').click();
await page.locator('[name="msg"]').type('this is a quote message');
await page.locator('[name="msg"]').fill('this is a quote message');
await page.keyboard.press('Enter');

await expect(poHomeChannel.content.waitForLastMessageTextAttachmentEqualsText).toHaveText(message);
Expand Down
31 changes: 31 additions & 0 deletions apps/meteor/tests/e2e/omnichannel-manager.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { test, expect } from './utils/test';
import { OmnichannelManager } from './page-objects';

test.use({ storageState: 'admin-session.json' });

test.describe.serial('omnichannel-manager', () => {
const user1 = 'user1';
let poOmnichannelManagers: OmnichannelManager;

test.beforeEach(async ({ page }) => {
poOmnichannelManagers = new OmnichannelManager(page);

await page.goto('/omnichannel');
await poOmnichannelManagers.sidenav.linkManagers.click();
});

test('expect add "user1" as manager', async ({ page }) => {
await poOmnichannelManagers.inputUsername.type(user1, { delay: 1000 });
await page.keyboard.press('Enter');
await poOmnichannelManagers.btnAdd.click();

await expect(poOmnichannelManagers.firstRowInTable(user1)).toBeVisible();
});

test('expect remove "user1" as manager', async () => {
await poOmnichannelManagers.btnDeleteFirstRowInTable.click();
await poOmnichannelManagers.btnModalRemove.click();

await expect(poOmnichannelManagers.firstRowInTable(user1)).toBeHidden();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class HomeSidenav {
async openChat(name: string): Promise<void> {
await this.page.locator('[data-qa="sidebar-search"]').click();
await this.page.locator('[data-qa="sidebar-search-input"]').type(name);
await this.page.locator('[data-qa="sidebar-item-title"]', { hasText: name }).first().click();
await this.page.locator(`[data-qa="sidebar-item-title"] >> text="${name}"`).first().click();
}

// Note: this is a workaround for now since queued omnichannel chats are not searchable yet so we can't use openChat() :(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export class OmnichannelSidenav {
return this.page.locator('a[href="omnichannel/agents"]');
}

get linkManagers(): Locator {
return this.page.locator('a[href="omnichannel/managers"]');
}

get linkCustomFields(): Locator {
return this.page.locator('a[href="/omnichannel/customfields"]');
}
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/tests/e2e/page-objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export * from './omnichannel-agents';
export * from './omnichannel-departments';
export * from './omnichannel-current-chats';
export * from './omnichannel-livechat';
export * from './omnichannel-manager';
export * from './omnichannel-custom-fields';
34 changes: 34 additions & 0 deletions apps/meteor/tests/e2e/page-objects/omnichannel-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Locator, Page } from '@playwright/test';

import { OmnichannelSidenav } from './fragments';

export class OmnichannelManager {
private readonly page: Page;

readonly sidenav: OmnichannelSidenav;

constructor(page: Page) {
this.page = page;
this.sidenav = new OmnichannelSidenav(page);
}

get inputUsername(): Locator {
return this.page.locator('input').first();
}

get btnAdd(): Locator {
return this.page.locator('button.rcx-button--primary.rcx-button >> text="Add"');
}

firstRowInTable(userId: string) {
return this.page.locator(`[data-qa-id="GenericTableManagerInfoBody"] [qa-user-id="${userId}"]`);
}

get btnDeleteFirstRowInTable() {
return this.page.locator('button[title="Remove"]');
}

get btnModalRemove(): Locator {
return this.page.locator('#modal-root dialog .rcx-modal__inner .rcx-modal__footer .rcx-button--danger');
}
}

0 comments on commit fd37ff4

Please sign in to comment.