snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
19
apps/meteor/tests/e2e/page-objects/omnichannel/index.ts
Normal file
19
apps/meteor/tests/e2e/page-objects/omnichannel/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export * from './omnichannel-agents';
|
||||
export * from './omnichannel-departments';
|
||||
export * from './omnichannel-canned-responses';
|
||||
export * from './omnichannel-contact-center';
|
||||
export * from './omnichannel-livechat';
|
||||
export * from './omnichannel-livechat-appearance';
|
||||
export * from './omnichannel-livechat-embedded';
|
||||
export * from './omnichannel-manager';
|
||||
export * from './omnichannel-custom-fields';
|
||||
export * from './omnichannel-units';
|
||||
export * from './omnichannel-monitors';
|
||||
export * from './omnichannel-settings';
|
||||
export * from './omnichannel-business-hours';
|
||||
export * from './omnichannel-tags';
|
||||
export * from './omnichannel-transcript';
|
||||
export * from './omnichannel-triggers';
|
||||
export * from './omnichannel-priorities';
|
||||
export * from './omnichannel-reports';
|
||||
export * from './omnichannel-sla-policies';
|
||||
@@ -0,0 +1,98 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { expect } from '../../utils/test';
|
||||
import { OmnichannelSidebar, ToastMessages } from '../fragments';
|
||||
import { ConfirmDeleteModal } from '../fragments/modals';
|
||||
import { Table } from '../fragments/table';
|
||||
import { RoutedPage } from '../routed-page';
|
||||
|
||||
export enum OmnichannelSectionsHref {
|
||||
currentChats = '/omnichannel/current/chats',
|
||||
currentContacts = '/omnichannel/current/contacts',
|
||||
agents = '/omnichannel/agents',
|
||||
managers = '/omnichannel/managers',
|
||||
monitors = '/omnichannel/monitors',
|
||||
departments = '/omnichannel/departments',
|
||||
units = '/omnichannel/units',
|
||||
customFields = '/omnichannel/customfields',
|
||||
cannedResponses = '/omnichannel/canned-responses',
|
||||
triggers = '/omnichannel/triggers',
|
||||
tags = '/omnichannel/tags',
|
||||
priorities = '/omnichannel/priorities',
|
||||
slaPolicies = '/omnichannel/sla-policies',
|
||||
businessHours = '/omnichannel/businessHours',
|
||||
appearance = '/omnichannel/appearance',
|
||||
livechatAppearance = '/omnichannel/livechat-appearance',
|
||||
analytics = '/omnichannel/analytics',
|
||||
reports = '/omnichannel/reports',
|
||||
realtimeMonitoring = '/omnichannel/realtime-monitoring',
|
||||
securityPrivacy = '/omnichannel/security-privacy',
|
||||
}
|
||||
|
||||
/**
|
||||
* A page under `/omnichannel/*`. Subclasses declare `route` and `title` and get
|
||||
* `goto()`, `pageHeader` and `table` for free.
|
||||
*/
|
||||
export abstract class OmnichannelAdmin extends RoutedPage {
|
||||
protected abstract override readonly route: OmnichannelSectionsHref;
|
||||
|
||||
/** Text of the page's main heading. */
|
||||
protected abstract readonly title: string;
|
||||
|
||||
/** Accessible name of the page's main table, when it differs from `title`. */
|
||||
protected readonly tableName?: string;
|
||||
|
||||
protected readonly toastMessage: ToastMessages;
|
||||
|
||||
readonly sidebar: OmnichannelSidebar;
|
||||
|
||||
readonly deleteModal: ConfirmDeleteModal;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.sidebar = new OmnichannelSidebar(page);
|
||||
this.toastMessage = new ToastMessages(page);
|
||||
this.deleteModal = new ConfirmDeleteModal(page.getByRole('dialog', { name: 'Are you sure?' }));
|
||||
}
|
||||
|
||||
get inputSearch() {
|
||||
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
|
||||
}
|
||||
|
||||
get btnSaveChanges(): Locator {
|
||||
return this.page.getByRole('button', { name: 'Save changes' });
|
||||
}
|
||||
|
||||
getButtonByType(type: 'unit' | 'SLA policy' | 'tag' | 'trigger' | 'department' | 'custom field'): Locator {
|
||||
return this.page.locator('header').getByRole('button', { name: `Create ${type}` });
|
||||
}
|
||||
|
||||
async search(text: string) {
|
||||
await this.inputSearch.fill(text);
|
||||
}
|
||||
|
||||
async clearSearch() {
|
||||
await this.inputSearch.fill('');
|
||||
}
|
||||
|
||||
get emptyState() {
|
||||
return this.page.getByRole('group', { name: 'No results found', exact: true });
|
||||
}
|
||||
|
||||
waitForEmptyState() {
|
||||
return expect(this.emptyState).toBeVisible();
|
||||
}
|
||||
|
||||
get pageHeader(): Locator {
|
||||
return this.page.locator('main').getByRole('heading', { name: this.title, exact: true });
|
||||
}
|
||||
|
||||
get table(): Table {
|
||||
return new Table(this.page.getByRole('table', { name: this.tableName ?? this.title }));
|
||||
}
|
||||
|
||||
async waitForReady(): Promise<void> {
|
||||
await this.pageHeader.waitFor({ state: 'visible' });
|
||||
await this.table.waitForDisplay(this.emptyState);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { FlexTab } from '../fragments/flextabs/flextab';
|
||||
import { Listbox } from '../fragments/listbox';
|
||||
|
||||
class OmnichannelEditAgentFlexTab extends FlexTab {
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'Edit User' }));
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
get inputMaxChats(): Locator {
|
||||
return this.root.locator('input[name="maxNumberSimultaneousChat"]');
|
||||
}
|
||||
|
||||
get inputDepartment(): Locator {
|
||||
return this.root.getByLabel('Departments').getByRole('textbox');
|
||||
}
|
||||
|
||||
getDepartmentOption(name: string) {
|
||||
return this.listbox.getOption(name);
|
||||
}
|
||||
|
||||
async selectDepartment(name: string) {
|
||||
await this.inputDepartment.click();
|
||||
await this.inputDepartment.fill(name);
|
||||
await this.listbox.selectOption(name);
|
||||
// TODO: This is necessary due to the PaginatedMultiSelectFiltered not closing the list when an option is selected nor when close is clicked.
|
||||
// The line below can be removed once the component is adjusted in Fuselage
|
||||
await this.root.click();
|
||||
}
|
||||
|
||||
findSelectedDepartment(name: string) {
|
||||
return this.root.getByLabel('Departments', { exact: true }).getByRole('option', { name });
|
||||
}
|
||||
|
||||
private get inputStatus(): Locator {
|
||||
return this.root.getByText('Status', { exact: true });
|
||||
}
|
||||
|
||||
async selectStatus(status: string) {
|
||||
await this.inputStatus.click();
|
||||
await this.listbox.selectOption(status);
|
||||
}
|
||||
}
|
||||
|
||||
class OmnichannelAgentInfoFlexTab extends FlexTab {
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'User Info' }));
|
||||
}
|
||||
|
||||
get btnEdit(): Locator {
|
||||
return this.root.getByRole('button', { name: 'Edit', exact: true });
|
||||
}
|
||||
|
||||
get btnRemove(): Locator {
|
||||
return this.root.getByRole('button', { name: 'Remove', exact: true });
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelAgents extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.agents;
|
||||
|
||||
protected readonly title = 'Agents';
|
||||
|
||||
readonly editAgent: OmnichannelEditAgentFlexTab;
|
||||
|
||||
readonly agentInfo: OmnichannelAgentInfoFlexTab;
|
||||
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.editAgent = new OmnichannelEditAgentFlexTab(page);
|
||||
this.agentInfo = new OmnichannelAgentInfoFlexTab(page);
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
get inputUsername(): Locator {
|
||||
return this.page.getByRole('textbox', { name: 'Username' });
|
||||
}
|
||||
|
||||
get btnAddAgent(): Locator {
|
||||
return this.page.getByRole('button', { name: 'Add agent', exact: true });
|
||||
}
|
||||
|
||||
async deleteAgent(name: string) {
|
||||
await this.search(name);
|
||||
await this.table.findRowByName(name).getByRole('button', { name: 'Remove' }).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
|
||||
get scrollContainer(): Locator {
|
||||
return this.page.locator('#position-container').getByTestId('virtuoso-scroller');
|
||||
}
|
||||
|
||||
scrollToListBottom() {
|
||||
return this.scrollContainer.evaluate((el) => {
|
||||
el.scrollTop = el.scrollHeight;
|
||||
el.dispatchEvent(new Event('scroll'));
|
||||
});
|
||||
}
|
||||
|
||||
async selectUsername(username: string) {
|
||||
await this.inputUsername.fill(username);
|
||||
await this.listbox.selectOption(username);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { Listbox } from '../fragments/listbox';
|
||||
|
||||
export class OmnichannelBusinessHours extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.businessHours;
|
||||
|
||||
protected readonly title = 'Business Hours';
|
||||
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
get btnCreateBusinessHour(): Locator {
|
||||
return this.page.locator('header').getByRole('button', { name: 'New', exact: true });
|
||||
}
|
||||
|
||||
get btnSave(): Locator {
|
||||
return this.page.getByRole('button', { name: 'Save', exact: true });
|
||||
}
|
||||
|
||||
get btnBack(): Locator {
|
||||
return this.page.locator('header').getByRole('button', { name: 'Back', exact: true });
|
||||
}
|
||||
|
||||
get inputName(): Locator {
|
||||
return this.page.getByRole('textbox', { name: 'Name', exact: true });
|
||||
}
|
||||
|
||||
get fieldDepartment(): Locator {
|
||||
return this.page.getByLabel('Departments', { exact: true });
|
||||
}
|
||||
|
||||
get inputDepartments(): Locator {
|
||||
return this.fieldDepartment.getByRole('textbox');
|
||||
}
|
||||
|
||||
async deleteBusinessHour(name: string) {
|
||||
await this.table.findRowByName(name).getByRole('button', { name: 'Remove' }).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
|
||||
getCheckboxByLabel(name: string): Locator {
|
||||
return this.page.locator('label', { has: this.page.getByRole('checkbox', { name }) });
|
||||
}
|
||||
|
||||
findDepartmentsChipOption(name: string) {
|
||||
return this.fieldDepartment.getByRole('option', { name, exact: true });
|
||||
}
|
||||
|
||||
async selectDepartment(name: string) {
|
||||
await this.inputDepartments.click();
|
||||
await this.inputDepartments.fill(name);
|
||||
await this.listbox.selectOption(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import type { Locator } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
|
||||
export class OmnichannelCannedResponses extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.cannedResponses;
|
||||
|
||||
protected readonly title = 'Canned Responses';
|
||||
|
||||
get inputShortcut() {
|
||||
return this.page.getByRole('textbox', { name: 'Shortcut', exact: true });
|
||||
}
|
||||
|
||||
get inputMessage() {
|
||||
return this.page.getByRole('textbox', { name: 'Message', exact: true });
|
||||
}
|
||||
|
||||
get radioPublic() {
|
||||
return this.page.locator('label', { has: this.page.getByRole('radio', { name: 'Public' }) });
|
||||
}
|
||||
|
||||
get radioPrivate() {
|
||||
return this.page.locator('label', { has: this.page.getByRole('radio', { name: 'Private' }) });
|
||||
}
|
||||
|
||||
get inputTags() {
|
||||
return this.page.getByRole('textbox', { name: 'Tags', exact: true });
|
||||
}
|
||||
|
||||
get btnAddTag() {
|
||||
return this.page.getByRole('button', { name: 'Add', exact: true });
|
||||
}
|
||||
|
||||
listItem(name: string) {
|
||||
return this.page.getByText(`!${name}`, { exact: true });
|
||||
}
|
||||
|
||||
async addTag(tag: string) {
|
||||
await this.inputTags.fill(tag);
|
||||
await this.btnAddTag.click();
|
||||
}
|
||||
|
||||
get btnEdit() {
|
||||
return this.page.getByRole('button', { name: 'Edit', exact: true });
|
||||
}
|
||||
|
||||
get btnSave(): Locator {
|
||||
return this.page.getByRole('button', { name: 'Save', exact: true });
|
||||
}
|
||||
|
||||
get btnNew(): Locator {
|
||||
return this.page.locator('role=button[name="Create canned response"]').first();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './omnichannel-contact-center-chats';
|
||||
export * from './omnichannel-contact-center-contacts';
|
||||
@@ -0,0 +1,182 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelContactCenter } from './omnichannel-contact-center';
|
||||
import { FlexTab } from '../../fragments/flextabs/flextab';
|
||||
import { Listbox } from '../../fragments/listbox';
|
||||
import { OmnichannelConfirmRemoveChat } from '../../fragments/modals';
|
||||
import { Table } from '../../fragments/table';
|
||||
import { OmnichannelSectionsHref } from '../omnichannel-admin';
|
||||
|
||||
class OmnichannelConversationFlexTab extends FlexTab {
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'Conversation' }));
|
||||
}
|
||||
|
||||
private get btnOpenChat(): Locator {
|
||||
return this.root.getByRole('button', { name: 'Open chat' });
|
||||
}
|
||||
|
||||
async openChat() {
|
||||
await this.btnOpenChat.click();
|
||||
await this.waitForDismissal();
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelChatsFilters extends FlexTab {
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'Filters' }));
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
get inputFrom(): Locator {
|
||||
return this.root.locator('input[name="from"]');
|
||||
}
|
||||
|
||||
get inputTo(): Locator {
|
||||
return this.root.locator('input[name="to"]');
|
||||
}
|
||||
|
||||
get btnApply(): Locator {
|
||||
return this.root.getByRole('button', { name: 'Apply' });
|
||||
}
|
||||
|
||||
get inputServedBy(): Locator {
|
||||
return this.root.getByLabel('Served By').locator('input');
|
||||
}
|
||||
|
||||
get inputDepartment(): Locator {
|
||||
return this.root.getByLabel('Department').locator('input');
|
||||
}
|
||||
|
||||
get selectStatusContainer(): Locator {
|
||||
return this.root.getByRole('button', { name: 'Status' });
|
||||
}
|
||||
|
||||
get inputTags(): Locator {
|
||||
return this.root.getByLabel('Tags').locator('input');
|
||||
}
|
||||
|
||||
get inputUnits(): Locator {
|
||||
return this.root.getByLabel('Units').locator('input');
|
||||
}
|
||||
|
||||
get btnClearFilters(): Locator {
|
||||
return this.root.getByRole('button', { name: 'Clear filters' });
|
||||
}
|
||||
|
||||
async selectServedBy(option: string) {
|
||||
await this.inputServedBy.click();
|
||||
await this.inputServedBy.fill(option);
|
||||
await this.listbox.selectOption(option);
|
||||
await this.btnApply.click();
|
||||
}
|
||||
|
||||
async selectStatus(option: string) {
|
||||
await this.selectStatusContainer.click();
|
||||
await this.listbox.selectOption(option);
|
||||
await this.btnApply.click();
|
||||
}
|
||||
|
||||
async selectDepartment(option: string) {
|
||||
await this.inputDepartment.click();
|
||||
await this.inputDepartment.fill(option);
|
||||
await this.listbox.selectOption(option);
|
||||
await this.inputDepartment.click();
|
||||
await this.btnApply.click();
|
||||
}
|
||||
|
||||
async selectTag(option: string) {
|
||||
await this.inputTags.click();
|
||||
await this.inputTags.fill(option);
|
||||
await this.listbox.selectOption(option);
|
||||
await this.inputTags.click();
|
||||
await this.btnApply.click();
|
||||
}
|
||||
|
||||
async removeTag(option: string) {
|
||||
await this.inputTags.click();
|
||||
await this.listbox.selectOption(option);
|
||||
await this.inputTags.click();
|
||||
await this.btnApply.click();
|
||||
}
|
||||
|
||||
async selectUnit(unitName: string) {
|
||||
await this.inputUnits.click();
|
||||
await this.inputUnits.fill(unitName);
|
||||
await this.listbox.selectOption(unitName);
|
||||
await this.btnApply.click();
|
||||
}
|
||||
|
||||
async addTag(option: string) {
|
||||
await this.inputTags.click();
|
||||
await this.listbox.selectOption(option);
|
||||
await this.inputTags.click();
|
||||
}
|
||||
}
|
||||
|
||||
class OmnichannelContactCenterChatsTable extends Table {
|
||||
btnRemoveByName(name: string): Locator {
|
||||
return this.findRowByName(name).getByRole('button', { name: 'Remove' });
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelContactCenterChats extends OmnichannelContactCenter {
|
||||
protected readonly route = OmnichannelSectionsHref.currentChats;
|
||||
|
||||
protected override readonly tableName = 'Omnichannel Contact Center Chats';
|
||||
|
||||
readonly filters: OmnichannelChatsFilters;
|
||||
|
||||
readonly confirmRemoveChatModal: OmnichannelConfirmRemoveChat;
|
||||
|
||||
readonly conversation: OmnichannelConversationFlexTab;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.filters = new OmnichannelChatsFilters(page);
|
||||
this.confirmRemoveChatModal = new OmnichannelConfirmRemoveChat(page);
|
||||
this.conversation = new OmnichannelConversationFlexTab(page);
|
||||
}
|
||||
|
||||
override get table(): OmnichannelContactCenterChatsTable {
|
||||
return new OmnichannelContactCenterChatsTable(this.page.getByRole('table', { name: this.tableName }));
|
||||
}
|
||||
|
||||
async removeChatByName(name: string) {
|
||||
await this.table.btnRemoveByName(name).click();
|
||||
await this.confirmRemoveChatModal.confirm();
|
||||
}
|
||||
|
||||
async openChat(name: string) {
|
||||
await this.inputSearch.fill(name);
|
||||
await this.table.findRowByName(name).click();
|
||||
await this.conversation.openChat();
|
||||
await this.page.locator('#main-content').waitFor();
|
||||
}
|
||||
|
||||
get btnFilters(): Locator {
|
||||
return this.page.getByRole('button', { name: 'Filters' });
|
||||
}
|
||||
|
||||
btnStatusChip(name: string): Locator {
|
||||
return this.page.getByRole('button', { name: `Status: ${name}` });
|
||||
}
|
||||
|
||||
btnServedByChip(name: string): Locator {
|
||||
return this.page.getByRole('button', { name: `Served by: ${name}` });
|
||||
}
|
||||
|
||||
btnDepartmentChip(name: string): Locator {
|
||||
return this.page.getByRole('button', { name: `Department: ${name}` });
|
||||
}
|
||||
|
||||
btnSearchChip(name: string): Locator {
|
||||
return this.page.getByRole('button', { name: `Text: ${name}` });
|
||||
}
|
||||
|
||||
btnUnitsChip(name: string): Locator {
|
||||
return this.page.getByRole('button', { name: `Units: ${name}` });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelContactInfo } from '../omnichannel-info';
|
||||
import { OmnichannelContactCenter } from './omnichannel-contact-center';
|
||||
import { MenuMoreActions } from '../../fragments';
|
||||
import { OmnichannelEditContactFlexTab } from '../../fragments/flextabs';
|
||||
import { OmnichannelDeleteContactModal } from '../../fragments/modals';
|
||||
import { OmnichannelSectionsHref } from '../omnichannel-admin';
|
||||
|
||||
export class OmnichannelContactCenterContacts extends OmnichannelContactCenter {
|
||||
protected readonly route = OmnichannelSectionsHref.currentContacts;
|
||||
|
||||
protected override readonly tableName = 'Omnichannel Contact Center Contacts';
|
||||
|
||||
readonly contactInfo: OmnichannelContactInfo;
|
||||
|
||||
readonly editContact: OmnichannelEditContactFlexTab;
|
||||
|
||||
readonly deleteContactModal: OmnichannelDeleteContactModal;
|
||||
|
||||
readonly menu: MenuMoreActions;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.contactInfo = new OmnichannelContactInfo(page);
|
||||
this.editContact = new OmnichannelEditContactFlexTab(page);
|
||||
this.deleteContactModal = new OmnichannelDeleteContactModal(page);
|
||||
this.menu = new MenuMoreActions(page);
|
||||
}
|
||||
|
||||
get btnNewContact(): Locator {
|
||||
return this.page.getByRole('button', { name: 'New contact' });
|
||||
}
|
||||
|
||||
async deleteContact(contactName: string) {
|
||||
await this.table.findRowByName(contactName).getByRole('button', { name: 'More Actions' }).click();
|
||||
await this.menu.selectMenuItem('Delete');
|
||||
await this.deleteContactModal.waitForDisplay();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { Locator } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin } from '../omnichannel-admin';
|
||||
|
||||
export abstract class OmnichannelContactCenter extends OmnichannelAdmin {
|
||||
protected readonly title = 'Omnichannel Contact Center';
|
||||
|
||||
get tabContacts(): Locator {
|
||||
return this.page.getByRole('tab', { name: 'Contacts' });
|
||||
}
|
||||
|
||||
get tabChats(): Locator {
|
||||
return this.page.getByRole('tab', { name: 'Chats' });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { FlexTab } from '../fragments/flextabs/flextab';
|
||||
|
||||
class OmnichannelManageCustomFieldsFlexTab extends FlexTab {
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'Custom Field' }));
|
||||
}
|
||||
|
||||
get inputField(): Locator {
|
||||
return this.root.getByRole('textbox', { name: 'Field', exact: true });
|
||||
}
|
||||
|
||||
get inputLabel(): Locator {
|
||||
return this.root.getByRole('textbox', { name: 'Label', exact: true });
|
||||
}
|
||||
|
||||
get labelVisible(): Locator {
|
||||
return this.root.getByText('Visible');
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelCustomFields extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.customFields;
|
||||
|
||||
protected readonly title = 'Custom Fields';
|
||||
|
||||
readonly manageCustomFields: OmnichannelManageCustomFieldsFlexTab;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.manageCustomFields = new OmnichannelManageCustomFieldsFlexTab(page);
|
||||
}
|
||||
|
||||
async createNew() {
|
||||
await this.getButtonByType('custom field').click();
|
||||
}
|
||||
|
||||
async deleteCustomField(fieldName: string) {
|
||||
await this.table.findRowByName(fieldName).getByRole('button', { name: 'Remove' }).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { MenuOptions } from '../fragments';
|
||||
import { Listbox } from '../fragments/listbox';
|
||||
import { OmnichannelUpsellDepartmentsModal, ConfirmDeleteDepartmentModal } from '../fragments/modals';
|
||||
import { Table } from '../fragments/table';
|
||||
|
||||
export class OmnichannelDepartments extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.departments;
|
||||
|
||||
protected readonly title = 'Departments';
|
||||
|
||||
readonly agentsTable: Table;
|
||||
|
||||
readonly upsellDepartmentsModal: OmnichannelUpsellDepartmentsModal;
|
||||
|
||||
readonly listbox: Listbox;
|
||||
|
||||
readonly menOptions: MenuOptions;
|
||||
|
||||
override readonly deleteModal: ConfirmDeleteDepartmentModal;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.agentsTable = new Table(page.getByRole('table', { name: 'Agents' }));
|
||||
this.upsellDepartmentsModal = new OmnichannelUpsellDepartmentsModal(page);
|
||||
this.listbox = new Listbox(page);
|
||||
this.menOptions = new MenuOptions(page);
|
||||
this.deleteModal = new ConfirmDeleteDepartmentModal(page);
|
||||
}
|
||||
|
||||
async createNew() {
|
||||
await this.getButtonByType('department').click();
|
||||
}
|
||||
|
||||
get labelEnabled() {
|
||||
return this.page.locator('label', { hasText: 'Enabled' });
|
||||
}
|
||||
|
||||
get inputName() {
|
||||
return this.page.getByRole('textbox', { name: 'Name', exact: true });
|
||||
}
|
||||
|
||||
get inputEmail() {
|
||||
return this.page.getByRole('textbox', { name: 'Email', exact: true });
|
||||
}
|
||||
|
||||
get inputConversationClosingTags() {
|
||||
return this.page.getByRole('textbox', { name: 'Conversation closing tags', exact: true });
|
||||
}
|
||||
|
||||
get btnAddTags() {
|
||||
return this.page.getByText('Conversation closing tags', { exact: true }).locator('..').getByRole('button', { name: 'Add' });
|
||||
}
|
||||
|
||||
get btnSave() {
|
||||
return this.page.getByRole('button', { name: 'Save', exact: true });
|
||||
}
|
||||
|
||||
get tabArchivedDepartments() {
|
||||
return this.page.getByRole('tab', { name: 'Archived' });
|
||||
}
|
||||
|
||||
getDepartmentMenuByName(name: string) {
|
||||
return this.table.findRowByName(name).getByRole('button', { name: 'Options' });
|
||||
}
|
||||
|
||||
get menuEditOption() {
|
||||
return this.menOptions.getMenuItem('Edit');
|
||||
}
|
||||
|
||||
get menuDeleteOption() {
|
||||
return this.menOptions.getMenuItem('Delete');
|
||||
}
|
||||
|
||||
get menuArchiveOption() {
|
||||
return this.menOptions.getMenuItem('Archive');
|
||||
}
|
||||
|
||||
get menuUnarchiveOption() {
|
||||
return this.menOptions.getMenuItem('Unarchive');
|
||||
}
|
||||
|
||||
async archiveDepartmentByName(name: string) {
|
||||
await this.getDepartmentMenuByName(name).click();
|
||||
await this.menuArchiveOption.click();
|
||||
await this.toastMessage.waitForDisplay();
|
||||
}
|
||||
|
||||
get inputUnit(): Locator {
|
||||
return this.page.getByLabel('Unit').getByRole('textbox', { name: 'Select an option' });
|
||||
}
|
||||
|
||||
btnTag(tagName: string) {
|
||||
return this.page.locator('button', { hasText: tagName });
|
||||
}
|
||||
|
||||
errorMessage(message: string): Locator {
|
||||
return this.page.locator(`[role="alert"] >> text="${message}"`);
|
||||
}
|
||||
|
||||
findOption(optionText: string) {
|
||||
return this.listbox.getOption(optionText);
|
||||
}
|
||||
|
||||
async selectUnit(unitName: string) {
|
||||
await this.inputUnit.click();
|
||||
await this.listbox.selectOption(unitName);
|
||||
}
|
||||
|
||||
get inputAgents() {
|
||||
return this.page.getByRole('group', { name: 'Agents' }).getByRole('textbox');
|
||||
}
|
||||
|
||||
get btnAddAgent() {
|
||||
return this.page.getByRole('group', { name: 'Agents' }).getByRole('button', { name: 'Add', exact: true });
|
||||
}
|
||||
|
||||
async createDepartment(departmentName: string, email: string) {
|
||||
await this.labelEnabled.click();
|
||||
await this.inputName.fill(departmentName);
|
||||
await this.inputEmail.fill(email);
|
||||
await this.btnSave.click();
|
||||
await this.toastMessage.dismissToast();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { FlexTab } from '../fragments/flextabs/flextab';
|
||||
import { OmnichannelContactReviewModal } from '../fragments/modals';
|
||||
|
||||
export class OmnichannelContactInfo extends FlexTab {
|
||||
readonly contactReviewModal: OmnichannelContactReviewModal;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'Contact' }));
|
||||
this.contactReviewModal = new OmnichannelContactReviewModal(page);
|
||||
}
|
||||
|
||||
get infoContactEmail(): Locator {
|
||||
return this.root.getByRole('list', { name: 'Email' }).getByRole('listitem').first().locator('p');
|
||||
}
|
||||
|
||||
get btnEdit(): Locator {
|
||||
return this.root.locator('role=button[name="Edit"]');
|
||||
}
|
||||
|
||||
get tabHistory(): Locator {
|
||||
return this.root.getByRole('tab', { name: 'History' });
|
||||
}
|
||||
|
||||
get historyItem(): Locator {
|
||||
return this.root.getByRole('listitem').first();
|
||||
}
|
||||
|
||||
get historyMessage(): Locator {
|
||||
return this.root.getByRole('listitem').first();
|
||||
}
|
||||
|
||||
get btnOpenChat(): Locator {
|
||||
return this.root.getByRole('button', { name: 'Open chat' });
|
||||
}
|
||||
|
||||
get btnSeeConflicts(): Locator {
|
||||
return this.root.getByRole('button', { name: 'See conflicts' });
|
||||
}
|
||||
|
||||
private get customFieldsGroup() {
|
||||
return this.root.getByRole('group', { name: 'Custom Fields' });
|
||||
}
|
||||
|
||||
getInfoByValue(value: string): Locator {
|
||||
return this.root.getByText(value, { exact: true });
|
||||
}
|
||||
|
||||
getVisitorCustomField(label: string): Locator {
|
||||
return this.customFieldsGroup.getByLabel(label);
|
||||
}
|
||||
|
||||
async solveConflict(field: string, value: string) {
|
||||
await this.btnSeeConflicts.click();
|
||||
await this.contactReviewModal.solveConfirmation(field, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { Locator } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
|
||||
export class OmnichannelLivechatAppearance extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.appearance;
|
||||
|
||||
protected readonly title = 'Appearance';
|
||||
|
||||
override async waitForReady(): Promise<void> {
|
||||
await this.pageHeader.waitFor({ state: 'visible' });
|
||||
}
|
||||
|
||||
get inputHideSystemMessages(): Locator {
|
||||
return this.page.locator('label', { hasText: 'Hide system messages' });
|
||||
}
|
||||
|
||||
get inputLivechatBackground(): Locator {
|
||||
return this.page.locator('[name="Livechat_background"]');
|
||||
}
|
||||
|
||||
get inputLivechatTitle(): Locator {
|
||||
return this.page.locator('[name="Livechat_title"]');
|
||||
}
|
||||
|
||||
get inputHideExpandChat(): Locator {
|
||||
return this.page.getByRole('checkbox', { name: 'Hide "Expand chat"' });
|
||||
}
|
||||
|
||||
get labelHideExpandChat(): Locator {
|
||||
return this.page.locator('label', { has: this.inputHideExpandChat });
|
||||
}
|
||||
|
||||
findHideSystemMessageOption(option: string): Locator {
|
||||
return this.page.locator(`[role="option"][value="${option}"]`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import type { Locator } from '@playwright/test';
|
||||
|
||||
import { RoutedPage } from '../routed-page';
|
||||
|
||||
/** The widget as embedded on a host page, driven through `window.RocketChat.livechat`. */
|
||||
export class OmnichannelLiveChatEmbedded extends RoutedPage {
|
||||
protected readonly route = '/packages/rocketchat_livechat/assets/demo.html';
|
||||
|
||||
async waitForReady(): Promise<void> {
|
||||
await this.btnOpenLiveChat().waitFor({ state: 'visible' });
|
||||
}
|
||||
|
||||
btnOpenLiveChat(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`[data-qa-id="chat-button"]`);
|
||||
}
|
||||
|
||||
btnFinishOfflineMessage(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`button[aria-label="OK"]`);
|
||||
}
|
||||
|
||||
get btnOptions(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`button >> text="Options"`);
|
||||
}
|
||||
|
||||
get btnCloseChat(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`button >> text="Finish this chat"`);
|
||||
}
|
||||
|
||||
get btnCloseChatConfirm(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`button >> text="Yes"`);
|
||||
}
|
||||
|
||||
get headerTitle(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator('[data-qa="header-title"]');
|
||||
}
|
||||
|
||||
get btnNewChat(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`role=button[name="New Chat"]`);
|
||||
}
|
||||
|
||||
get messageList(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator('[data-qa="message-list"]');
|
||||
}
|
||||
|
||||
get messageListBackground(): Promise<string> {
|
||||
return this.messageList.evaluate((el) => window.getComputedStyle(el).getPropertyValue('background-color'));
|
||||
}
|
||||
|
||||
messageBubble(message: string): Locator {
|
||||
return this.page
|
||||
.frameLocator('#rocketchat-iframe')
|
||||
.locator('[data-qa="message-bubble"]', { has: this.page.frameLocator('#rocketchat-iframe').locator(`div >> text="${message}"`) });
|
||||
}
|
||||
|
||||
messageBubbleBackground(message: string): Promise<string> {
|
||||
return this.messageBubble(message)
|
||||
.last()
|
||||
.evaluate((el) => window.getComputedStyle(el).getPropertyValue('background-color'));
|
||||
}
|
||||
|
||||
txtChatMessage(message: string): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`li >> text="${message}"`);
|
||||
}
|
||||
|
||||
imgAvatar(username: string): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`img[alt="${username}"]`).last();
|
||||
}
|
||||
|
||||
async openLiveChat(): Promise<void> {
|
||||
await this.btnOpenLiveChat().click();
|
||||
}
|
||||
|
||||
get inputName(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator('[name="name"]');
|
||||
}
|
||||
|
||||
get inputEmail(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator('[name="email"]');
|
||||
}
|
||||
|
||||
get textAreaMessage(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator('[name="message"]');
|
||||
}
|
||||
|
||||
btnSendMessage(btnText: string): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator(`role=button[name="${btnText}"]`);
|
||||
}
|
||||
|
||||
get onlineAgentMessage(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator('[contenteditable="true"]');
|
||||
}
|
||||
|
||||
get btnSendMessageToOnlineAgent(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').locator('footer div div div:nth-child(3) button');
|
||||
}
|
||||
|
||||
get btnExpandChat(): Locator {
|
||||
return this.page.frameLocator('#rocketchat-iframe').getByRole('button', { name: 'Expand chat', exact: true });
|
||||
}
|
||||
|
||||
public async sendMessage(liveChatUser: { name: string; email: string }, isOffline = true): Promise<void> {
|
||||
const buttonLabel = isOffline ? 'Send' : 'Start chat';
|
||||
await this.inputName.fill(liveChatUser.name);
|
||||
await this.inputEmail.fill(liveChatUser.email);
|
||||
if (isOffline) {
|
||||
await this.textAreaMessage.fill('any_message');
|
||||
await this.btnSendMessage(buttonLabel).click();
|
||||
return this.btnFinishOfflineMessage().click();
|
||||
}
|
||||
await this.btnSendMessage(buttonLabel).click();
|
||||
await this.page.frameLocator('#rocketchat-iframe').locator('[data-qa="livechat-composer"]').waitFor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
import fs from 'fs/promises';
|
||||
|
||||
import type { Page, Locator, APIResponse } from '@playwright/test';
|
||||
|
||||
import { expect } from '../../utils/test';
|
||||
import { RoutedPage } from '../routed-page';
|
||||
|
||||
export class OmnichannelLiveChat extends RoutedPage {
|
||||
protected readonly route = '/livechat';
|
||||
|
||||
constructor(
|
||||
page: Page,
|
||||
private readonly api: { get(url: string): Promise<APIResponse> },
|
||||
) {
|
||||
super(page);
|
||||
}
|
||||
|
||||
async waitForReady(): Promise<void> {
|
||||
await this.btnOpenLiveChat.waitFor({ state: 'visible' });
|
||||
}
|
||||
|
||||
btnOpenOnlineLiveChat(label: string): Locator {
|
||||
return this.page.locator(`role=button[name="${label}"]`);
|
||||
}
|
||||
|
||||
get btnOpenLiveChat(): Locator {
|
||||
return this.page.locator(`[data-qa-id="chat-button"]`);
|
||||
}
|
||||
|
||||
get btnNewChat(): Locator {
|
||||
return this.page.locator(`role=button[name="New Chat"]`);
|
||||
}
|
||||
|
||||
get btnOptions(): Locator {
|
||||
return this.page.locator(`button >> text="Options"`);
|
||||
}
|
||||
|
||||
get btnCloseChat(): Locator {
|
||||
return this.page.locator(`button >> text="Finish this chat"`);
|
||||
}
|
||||
|
||||
get btnChangeDepartment(): Locator {
|
||||
return this.page.locator(`button >> text="Change department"`);
|
||||
}
|
||||
|
||||
get btnCloseChatConfirm(): Locator {
|
||||
return this.page.locator(`button >> text="Yes"`);
|
||||
}
|
||||
|
||||
get btnExpandChat(): Locator {
|
||||
return this.page.getByRole('button', { name: 'Expand chat' });
|
||||
}
|
||||
|
||||
get txtHeaderTitle(): Locator {
|
||||
return this.page.locator('div >> text="Chat Finished"');
|
||||
}
|
||||
|
||||
get btnChatNow(): Locator {
|
||||
return this.page.locator('[type="button"] >> text="Chat now"');
|
||||
}
|
||||
|
||||
get headerTitle(): Locator {
|
||||
return this.page.locator('[data-qa="header-title"]');
|
||||
}
|
||||
|
||||
get txtWatermark(): Locator {
|
||||
return this.page.locator('[data-qa="livechat-watermark"]');
|
||||
}
|
||||
|
||||
get imgLogo(): Locator {
|
||||
return this.btnOpenLiveChat.locator('img[alt="Livechat"]');
|
||||
}
|
||||
|
||||
alertMessage(message: string): Locator {
|
||||
return this.page.getByRole('alert').locator(`text="${message}"`);
|
||||
}
|
||||
|
||||
txtChatMessage(message: string): Locator {
|
||||
return this.page.locator(`[data-qa="message-bubble"] >> text="${message}"`);
|
||||
}
|
||||
|
||||
async closeChat(): Promise<void> {
|
||||
await this.btnOptions.click();
|
||||
await this.btnCloseChat.click();
|
||||
await this.btnCloseChatConfirm.click();
|
||||
}
|
||||
|
||||
async openLiveChat(): Promise<void> {
|
||||
const { value: siteName } = await (await this.api.get('/settings/Livechat_title')).json();
|
||||
await this.btnOpenOnlineLiveChat(siteName).click();
|
||||
}
|
||||
|
||||
// TODO: replace openLivechat with this method and create a new method for openOnlineLivechat
|
||||
// as openLivechat only opens a chat that is in the 'online' state
|
||||
async openAnyLiveChat(): Promise<void> {
|
||||
await this.btnOpenLiveChat.click();
|
||||
}
|
||||
|
||||
async startNewChat(): Promise<void> {
|
||||
await this.btnNewChat.click();
|
||||
}
|
||||
|
||||
async openAnyLiveChatAndSendMessage(params: {
|
||||
liveChatUser: { name: string; email: string };
|
||||
message: string;
|
||||
isOffline?: boolean;
|
||||
department?: string;
|
||||
}): Promise<void> {
|
||||
const { liveChatUser, message, isOffline, department } = params;
|
||||
await this.openAnyLiveChat();
|
||||
await this.sendMessage(liveChatUser, isOffline, department);
|
||||
await this.onlineAgentMessage.fill(message);
|
||||
await this.btnSendMessageToOnlineAgent.click();
|
||||
}
|
||||
|
||||
unreadMessagesBadge(count: number): Locator {
|
||||
const name = count === 1 ? `${count} unread message` : `${count} unread messages`;
|
||||
|
||||
return this.page.locator(`role=status[name="${name}"]`);
|
||||
}
|
||||
|
||||
get inputName(): Locator {
|
||||
return this.page.locator('[name="name"]');
|
||||
}
|
||||
|
||||
get inputEmail(): Locator {
|
||||
return this.page.locator('[name="email"]');
|
||||
}
|
||||
|
||||
get selectDepartment(): Locator {
|
||||
return this.page.locator('[name="department"]');
|
||||
}
|
||||
|
||||
get textAreaMessage(): Locator {
|
||||
return this.page.locator('[name="message"]');
|
||||
}
|
||||
|
||||
btnSendMessage(btnText: string): Locator {
|
||||
return this.page.locator(`role=button[name="${btnText}"]`);
|
||||
}
|
||||
|
||||
get btnOk(): Locator {
|
||||
return this.page.locator('role=button[name="OK"]');
|
||||
}
|
||||
|
||||
get btnYes(): Locator {
|
||||
return this.page.locator('role=button[name="Yes"]');
|
||||
}
|
||||
|
||||
get onlineAgentMessage(): Locator {
|
||||
return this.page.locator('[contenteditable="true"]');
|
||||
}
|
||||
|
||||
get btnSendMessageToOnlineAgent(): Locator {
|
||||
return this.page.locator('footer div div div:nth-child(3) button');
|
||||
}
|
||||
|
||||
get livechatModal(): Locator {
|
||||
return this.page.locator('[data-qa-type="modal-overlay"]');
|
||||
}
|
||||
|
||||
livechatModalText(text: string): Locator {
|
||||
return this.page.locator(`[data-qa-type="modal-overlay"] >> text=${text}`);
|
||||
}
|
||||
|
||||
get fileUploadTarget(): Locator {
|
||||
return this.page.locator('#files-drop-target');
|
||||
}
|
||||
|
||||
findUploadedFileLink(fileName: string): Locator {
|
||||
return this.page.getByRole('link', { name: fileName });
|
||||
}
|
||||
|
||||
get typingIndicatorForVisitor(): Locator {
|
||||
return this.page.getByRole('status', { name: /typing/i });
|
||||
}
|
||||
|
||||
public async sendMessage(liveChatUser: { name: string; email: string }, isOffline = true, department?: string): Promise<void> {
|
||||
const buttonLabel = isOffline ? 'Send' : 'Start chat';
|
||||
await this.inputName.fill(liveChatUser.name);
|
||||
await this.inputEmail.fill(liveChatUser.email);
|
||||
|
||||
if (department) {
|
||||
await this.selectDepartment.selectOption({ label: department });
|
||||
}
|
||||
|
||||
if (isOffline) {
|
||||
await this.textAreaMessage.type('any_message');
|
||||
}
|
||||
|
||||
await this.btnSendMessage(buttonLabel).click();
|
||||
await this.page.waitForSelector('[data-qa="livechat-composer"]');
|
||||
}
|
||||
|
||||
public async sendMessageAndCloseChat(
|
||||
liveChatUser: { name: string; email: string },
|
||||
message = 'this_a_test_message_from_user',
|
||||
): Promise<void> {
|
||||
await this.openAnyLiveChat();
|
||||
await this.sendMessage(liveChatUser, false);
|
||||
await this.onlineAgentMessage.fill(message);
|
||||
await this.btnSendMessageToOnlineAgent.click();
|
||||
await expect(this.txtChatMessage(message)).toBeVisible();
|
||||
await expect(this.page.locator('[data-qa="message-bubble"] >> text="Chat started"')).toBeVisible();
|
||||
await this.closeChat();
|
||||
}
|
||||
|
||||
async dragAndDropTxtFile(): Promise<void> {
|
||||
const contract = await fs.readFile('./tests/e2e/fixtures/files/any_file.txt', 'utf-8');
|
||||
const dataTransfer = await this.page.evaluateHandle((contract) => {
|
||||
const data = new DataTransfer();
|
||||
const file = new File([`${contract}`], 'any_file.txt', {
|
||||
type: 'text/plain',
|
||||
});
|
||||
data.items.add(file);
|
||||
return data;
|
||||
}, contract);
|
||||
|
||||
await this.fileUploadTarget.dispatchEvent('dragenter', { dataTransfer });
|
||||
|
||||
await this.fileUploadTarget.dispatchEvent('drop', { dataTransfer });
|
||||
}
|
||||
|
||||
async dragAndDropLstFile(): Promise<void> {
|
||||
const contract = await fs.readFile('./tests/e2e/fixtures/files/lst-test.lst', 'utf-8');
|
||||
const dataTransfer = await this.page.evaluateHandle((contract) => {
|
||||
const data = new DataTransfer();
|
||||
const file = new File([`${contract}`], 'lst-test.lst', {
|
||||
type: 'text/plain',
|
||||
});
|
||||
data.items.add(file);
|
||||
return data;
|
||||
}, contract);
|
||||
|
||||
await this.fileUploadTarget.dispatchEvent('dragenter', { dataTransfer });
|
||||
|
||||
await this.fileUploadTarget.dispatchEvent('drop', { dataTransfer });
|
||||
}
|
||||
|
||||
queuePosition(position: number): Locator {
|
||||
return this.page.locator(`div[role='alert'] >> text=Your spot is #${position}`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { Listbox } from '../fragments/listbox';
|
||||
|
||||
export class OmnichannelManager extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.managers;
|
||||
|
||||
protected readonly title = 'Managers';
|
||||
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
get inputUsername(): Locator {
|
||||
return this.page.getByRole('main').getByLabel('Username');
|
||||
}
|
||||
|
||||
async selectUsername(username: string) {
|
||||
await this.inputUsername.fill(username);
|
||||
await this.listbox.selectOption(username);
|
||||
}
|
||||
|
||||
get btnAddManager(): Locator {
|
||||
return this.page.getByRole('button', { name: 'Add manager' });
|
||||
}
|
||||
|
||||
async removeManager(name: string) {
|
||||
await this.table.findRowByName(name).getByRole('button', { name: 'Remove' }).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { Listbox } from '../fragments/listbox';
|
||||
|
||||
export class OmnichannelMonitors extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.monitors;
|
||||
|
||||
protected readonly title = 'Monitors';
|
||||
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
private get btnAddMonitor(): Locator {
|
||||
return this.page.getByRole('button', { name: 'Add monitor' });
|
||||
}
|
||||
|
||||
get inputMonitor(): Locator {
|
||||
return this.page.locator('input[name="monitor"]');
|
||||
}
|
||||
|
||||
private btnRemoveByName(name: string): Locator {
|
||||
return this.table.findRowByName(name).getByRole('button', { name: 'Remove' });
|
||||
}
|
||||
|
||||
private async selectMonitor(name: string) {
|
||||
await this.inputMonitor.fill(name);
|
||||
await this.listbox.selectOption(name);
|
||||
}
|
||||
|
||||
async removeMonitor(name: string) {
|
||||
await this.btnRemoveByName(name).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
|
||||
async addMonitor(name: string) {
|
||||
await this.selectMonitor(name);
|
||||
await this.btnAddMonitor.click();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { ToastMessages } from '../fragments';
|
||||
import { FlexTab } from '../fragments/flextabs/flextab';
|
||||
import { OmnichannelResetPrioritiesModal } from '../fragments/modals';
|
||||
|
||||
class OmnichannelEditPriorityFlexTab extends FlexTab {
|
||||
readonly toastMessage: ToastMessages;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'Priority' }));
|
||||
this.toastMessage = new ToastMessages(page);
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelPriorities extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.priorities;
|
||||
|
||||
protected readonly title = 'Priorities';
|
||||
|
||||
readonly editPriority: OmnichannelEditPriorityFlexTab;
|
||||
|
||||
readonly resetPrioritiesModal: OmnichannelResetPrioritiesModal;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.resetPrioritiesModal = new OmnichannelResetPrioritiesModal(page);
|
||||
this.editPriority = new OmnichannelEditPriorityFlexTab(page);
|
||||
}
|
||||
|
||||
get btnReset() {
|
||||
return this.page.getByRole('button', { name: 'Reset' });
|
||||
}
|
||||
|
||||
async resetPriorities() {
|
||||
await this.btnReset.click();
|
||||
await this.resetPrioritiesModal.reset();
|
||||
await this.toastMessage.dismissToast();
|
||||
}
|
||||
|
||||
findPriority(name: string) {
|
||||
return this.table.findRowByName(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
|
||||
class OmnichannelReportsSection {
|
||||
private readonly page: Page;
|
||||
|
||||
private readonly section: Locator;
|
||||
|
||||
constructor(page: Page, sectionId: string) {
|
||||
this.page = page;
|
||||
this.section = page.locator(`[data-qa=${sectionId}]`);
|
||||
}
|
||||
|
||||
get element() {
|
||||
return this.section;
|
||||
}
|
||||
|
||||
get inputPeriodSelector() {
|
||||
return this.section.locator('button[aria-label="Select period"]');
|
||||
}
|
||||
|
||||
get txtStateTitle() {
|
||||
return this.section.locator('.rcx-states__title');
|
||||
}
|
||||
|
||||
get txtStateSubtitle() {
|
||||
return this.section.locator('.rcx-states__subtitle');
|
||||
}
|
||||
|
||||
get btnRetry() {
|
||||
return this.section.locator('role=button[name="Retry"]');
|
||||
}
|
||||
|
||||
get txtSummary() {
|
||||
return this.section.locator('[data-qa="report-summary"]');
|
||||
}
|
||||
|
||||
findRowByName(name: string) {
|
||||
return this.section.locator('tr', { has: this.page.locator(`td >> text="${name}"`) });
|
||||
}
|
||||
|
||||
chartItem(label: string, value: number) {
|
||||
return this.section.locator(`rect[aria-label="${label}"] + text >> text=${value}`);
|
||||
}
|
||||
|
||||
legendItem(text: string) {
|
||||
return this.section.locator(`text='${text}'`);
|
||||
}
|
||||
|
||||
async selectPeriod(period: string) {
|
||||
await this.inputPeriodSelector.click();
|
||||
await this.page.locator(`li.rcx-option[data-key="${period}"]`).click();
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelReports extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.reports;
|
||||
|
||||
protected readonly title = 'Reports';
|
||||
|
||||
readonly statusSection: OmnichannelReportsSection;
|
||||
|
||||
readonly channelsSection: OmnichannelReportsSection;
|
||||
|
||||
readonly departmentsSection: OmnichannelReportsSection;
|
||||
|
||||
readonly tagsSection: OmnichannelReportsSection;
|
||||
|
||||
readonly agentsSection: OmnichannelReportsSection;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.statusSection = new OmnichannelReportsSection(page, 'conversations-by-status');
|
||||
this.channelsSection = new OmnichannelReportsSection(page, 'conversations-by-channel');
|
||||
this.departmentsSection = new OmnichannelReportsSection(page, 'conversations-by-department');
|
||||
this.tagsSection = new OmnichannelReportsSection(page, 'conversations-by-tags');
|
||||
this.agentsSection = new OmnichannelReportsSection(page, 'conversations-by-agent');
|
||||
}
|
||||
|
||||
override async waitForReady(): Promise<void> {
|
||||
await this.pageHeader.waitFor({ state: 'visible' });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { Locator } from '@playwright/test';
|
||||
|
||||
import { AdminSectionsHref } from '../admin';
|
||||
import { AdminSettingsSection } from '../admin-settings';
|
||||
|
||||
export class OmnichannelSettings extends AdminSettingsSection {
|
||||
protected readonly route = `${AdminSectionsHref.settings}/Omnichannel` as const;
|
||||
|
||||
protected readonly title = 'Omnichannel';
|
||||
|
||||
get labelLivechatLogo(): Locator {
|
||||
return this.page.locator('//label[@title="Assets_livechat_widget_logo"]');
|
||||
}
|
||||
|
||||
get imgLivechatLogoPreview(): Locator {
|
||||
return this.page.locator('//label[@title="Assets_livechat_widget_logo"]/following-sibling::span >> role=img[name="Asset preview"]');
|
||||
}
|
||||
|
||||
get inputLivechatLogo(): Locator {
|
||||
return this.page.locator('//label[@title="Assets_livechat_widget_logo"]/following-sibling::span >> input[type="file"]');
|
||||
}
|
||||
|
||||
get btnDeleteLivechatLogo(): Locator {
|
||||
return this.page.locator('//label[@title="Assets_livechat_widget_logo"]/following-sibling::span >> role=button[name="Delete"]');
|
||||
}
|
||||
|
||||
group(sectionName: string): Locator {
|
||||
return this.page.locator(`[data-qa-section="${sectionName}"] h2 >> text="${sectionName}"`);
|
||||
}
|
||||
|
||||
get labelHideWatermark(): Locator {
|
||||
return this.page.locator('label').getByText('Hide "powered by Rocket.Chat"');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { FlexTab } from '../fragments/flextabs/flextab';
|
||||
|
||||
class OmnichannelManageSlaPolicyFlexTab extends FlexTab {
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'SLA Policy' }));
|
||||
}
|
||||
|
||||
get inputDescription(): Locator {
|
||||
return this.root.getByRole('textbox', { name: 'Description' });
|
||||
}
|
||||
|
||||
get inputEstimatedWaitTime(): Locator {
|
||||
return this.root.getByRole('spinbutton', { name: 'Estimated wait time (time in minutes)', exact: true });
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelSlaPolicies extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.slaPolicies;
|
||||
|
||||
protected readonly title = 'SLA Policies';
|
||||
|
||||
readonly manageSlaPolicy: OmnichannelManageSlaPolicyFlexTab;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.manageSlaPolicy = new OmnichannelManageSlaPolicyFlexTab(page);
|
||||
}
|
||||
|
||||
btnRemove(name: string) {
|
||||
return this.table.findRowByName(name).getByRole('button', { name: 'Remove' });
|
||||
}
|
||||
|
||||
async removeSLA(name: string) {
|
||||
await this.btnRemove(name).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
|
||||
async createNew() {
|
||||
await this.getButtonByType('SLA policy').click();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { FlexTab } from '../fragments/flextabs/flextab';
|
||||
import { Listbox } from '../fragments/listbox';
|
||||
|
||||
class OmnichannelEditTagFlexTab extends FlexTab {
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'tag' }));
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
get inputDepartments(): Locator {
|
||||
return this.root.getByLabel('Departments').getByRole('textbox');
|
||||
}
|
||||
|
||||
async selectDepartment(name: string) {
|
||||
await this.inputDepartments.click();
|
||||
await this.inputDepartments.fill(name);
|
||||
await this.listbox.selectOption(name);
|
||||
}
|
||||
|
||||
findSelectedDepartment(name: string) {
|
||||
return this.root.getByLabel('Departments').getByRole('option', { name });
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelTags extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.tags;
|
||||
|
||||
protected readonly title = 'Tags';
|
||||
|
||||
readonly editTag: OmnichannelEditTagFlexTab;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.editTag = new OmnichannelEditTagFlexTab(page);
|
||||
}
|
||||
|
||||
async createNew() {
|
||||
await this.getButtonByType('tag').click();
|
||||
}
|
||||
|
||||
async deleteTag(name: string) {
|
||||
await this.table.findRowByName(name).getByRole('button', { name: 'Remove' }).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
export class OmnichannelTranscript {
|
||||
constructor(private readonly page: Page) {}
|
||||
|
||||
get contactCenterChats(): Locator {
|
||||
return this.page.locator('//button[contains(.,"Chats")]');
|
||||
}
|
||||
|
||||
get contactCenterSearch(): Locator {
|
||||
return this.page.locator('[placeholder="Search"]');
|
||||
}
|
||||
|
||||
get firstRow(): Locator {
|
||||
return this.page.locator('//tr[1]//td[1]');
|
||||
}
|
||||
|
||||
get btnOpenChat(): Locator {
|
||||
return this.page.getByRole('dialog').getByRole('button', { name: 'Open chat', exact: true });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { FlexTab } from '../fragments/flextabs/flextab';
|
||||
import { Listbox } from '../fragments/listbox';
|
||||
|
||||
type TriggerConditions = 'Visitor page URL' | 'Visitor time on site' | 'Chat opened by the visitor' | 'After guest registration';
|
||||
|
||||
class OmnichannelEditTriggerFlexTab extends FlexTab {
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'trigger' }));
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
private get inputDescription(): Locator {
|
||||
return this.root.getByRole('textbox', { name: 'Description', exact: true });
|
||||
}
|
||||
|
||||
private get conditionLabel(): Locator {
|
||||
return this.root.getByText('Condition', { exact: true });
|
||||
}
|
||||
|
||||
private get senderLabel(): Locator {
|
||||
return this.root.getByText('Sender', { exact: true });
|
||||
}
|
||||
|
||||
private async selectCondition(condition: string) {
|
||||
await this.conditionLabel.click();
|
||||
await this.listbox.selectOption(condition);
|
||||
}
|
||||
|
||||
private async selectSender(sender: 'queue' | 'custom') {
|
||||
await this.senderLabel.click();
|
||||
await this.listbox.selectOption(sender);
|
||||
}
|
||||
|
||||
private get inputAgentName(): Locator {
|
||||
return this.root.locator('input[name="actions.0.params.name"]');
|
||||
}
|
||||
|
||||
private get inputConditionValue(): Locator {
|
||||
return this.root.locator('input[name="conditions.0.value"]');
|
||||
}
|
||||
|
||||
private get inputTriggerMessage(): Locator {
|
||||
return this.root.locator('textarea[name="actions.0.params.msg"]');
|
||||
}
|
||||
|
||||
async fillTriggerForm(
|
||||
data: Partial<{
|
||||
name: string;
|
||||
description: string;
|
||||
condition: TriggerConditions;
|
||||
conditionValue?: string | number;
|
||||
sender: 'queue' | 'custom';
|
||||
agentName?: string;
|
||||
triggerMessage: string;
|
||||
}>,
|
||||
) {
|
||||
data.name && (await this.inputName.fill(data.name));
|
||||
data.description && (await this.inputDescription.fill(data.description));
|
||||
data.condition && (await this.selectCondition(data.condition));
|
||||
|
||||
if (data.conditionValue) {
|
||||
await this.inputConditionValue.fill(data.conditionValue.toString());
|
||||
}
|
||||
|
||||
data.sender && (await this.selectSender(data.sender));
|
||||
if (data.sender === 'custom' && !data.agentName) {
|
||||
throw new Error('A custom agent is required for this action');
|
||||
} else {
|
||||
data.agentName && (await this.inputAgentName.fill(data.agentName));
|
||||
}
|
||||
|
||||
data.triggerMessage && (await this.inputTriggerMessage.fill(data.triggerMessage));
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelTriggers extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.triggers;
|
||||
|
||||
protected readonly title = 'Livechat Triggers';
|
||||
|
||||
readonly editTrigger: OmnichannelEditTriggerFlexTab;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.editTrigger = new OmnichannelEditTriggerFlexTab(page);
|
||||
}
|
||||
|
||||
async removeTrigger(name: string) {
|
||||
await this.table.findRowByName(name).getByRole('button', { name: 'Remove' }).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
|
||||
public async createTrigger(triggersName: string, triggerMessage: string, condition: TriggerConditions, conditionValue?: number | string) {
|
||||
await this.getButtonByType('trigger').click();
|
||||
await this.editTrigger.fillTriggerForm({
|
||||
name: triggersName,
|
||||
description: 'Creating a fresh trigger',
|
||||
condition,
|
||||
conditionValue,
|
||||
triggerMessage,
|
||||
});
|
||||
await this.editTrigger.save();
|
||||
}
|
||||
|
||||
public async updateTrigger(name: string, triggerMessage: string, condition: TriggerConditions = 'Chat opened by the visitor') {
|
||||
await this.editTrigger.fillTriggerForm({
|
||||
name,
|
||||
description: 'Updating the existing trigger',
|
||||
condition,
|
||||
sender: 'custom',
|
||||
agentName: 'Rocket.cat',
|
||||
triggerMessage,
|
||||
});
|
||||
await this.editTrigger.save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
|
||||
import { OmnichannelAdmin, OmnichannelSectionsHref } from './omnichannel-admin';
|
||||
import { FlexTab } from '../fragments/flextabs/flextab';
|
||||
import { Listbox } from '../fragments/listbox';
|
||||
import { Table } from '../fragments/table';
|
||||
|
||||
export class OmnichannelUnitFlexTab extends FlexTab {
|
||||
readonly listbox: Listbox;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page.getByRole('dialog', { name: 'unit' }));
|
||||
this.listbox = new Listbox(page);
|
||||
}
|
||||
|
||||
private get fieldDepartments() {
|
||||
return this.root.getByLabel('Departments');
|
||||
}
|
||||
|
||||
get inputDepartments() {
|
||||
return this.fieldDepartments.getByRole('textbox');
|
||||
}
|
||||
|
||||
private get fieldMonitors() {
|
||||
return this.root.getByLabel('Monitors');
|
||||
}
|
||||
|
||||
get inputMonitors() {
|
||||
return this.fieldMonitors.getByRole('textbox');
|
||||
}
|
||||
|
||||
get inputVisibility(): Locator {
|
||||
return this.root.getByText('Visibility');
|
||||
}
|
||||
|
||||
findDepartmentsChipOption(name: string) {
|
||||
return this.fieldDepartments.getByRole('option', { name, exact: true });
|
||||
}
|
||||
|
||||
findMonitorChipOption(name: string) {
|
||||
return this.fieldMonitors.getByRole('option', { name, exact: true });
|
||||
}
|
||||
|
||||
async selectDepartment(name: string) {
|
||||
await this.inputDepartments.click();
|
||||
await this.inputDepartments.fill(name);
|
||||
await this.listbox.selectOption(name);
|
||||
await this.inputDepartments.click();
|
||||
}
|
||||
|
||||
async selectMonitor(option: string) {
|
||||
await this.inputMonitors.click();
|
||||
await this.listbox.selectOption(option);
|
||||
await this.inputMonitors.click();
|
||||
}
|
||||
|
||||
async removeMonitor(option: string) {
|
||||
await this.findMonitorChipOption(option).click();
|
||||
}
|
||||
|
||||
async selectVisibility(option: string) {
|
||||
await this.inputVisibility.click();
|
||||
await this.listbox.selectOption(option);
|
||||
}
|
||||
}
|
||||
|
||||
class OmnichannelUnitsTable extends Table {
|
||||
deleteUnitByName(name: string) {
|
||||
return this.findRowByName(name).getByRole('button', { name: 'Remove' });
|
||||
}
|
||||
}
|
||||
|
||||
export class OmnichannelUnits extends OmnichannelAdmin {
|
||||
protected readonly route = OmnichannelSectionsHref.units;
|
||||
|
||||
protected readonly title = 'Units';
|
||||
|
||||
readonly manageUnit: OmnichannelUnitFlexTab;
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
this.manageUnit = new OmnichannelUnitFlexTab(page);
|
||||
}
|
||||
|
||||
override get table() {
|
||||
return new OmnichannelUnitsTable(this.page.getByRole('table', { name: this.title }));
|
||||
}
|
||||
|
||||
async createNew() {
|
||||
await this.getButtonByType('unit').click();
|
||||
}
|
||||
|
||||
async deleteUnit(name: string) {
|
||||
await this.table.deleteUnitByName(name).click();
|
||||
await this.deleteModal.confirmDelete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user