Automation for Export PDF Transcript functionality

pull/29702/head
Harmeet221 3 years ago
parent aa77a17c25
commit de2a5ff9af
  1. 92
      apps/meteor/tests/e2e/omnichannel-send-transcript-pdf.spec.ts
  2. 9
      apps/meteor/tests/e2e/page-objects/fragments/home-content.ts
  3. 4
      apps/meteor/tests/e2e/page-objects/home-omnichannel.ts
  4. 46
      apps/meteor/tests/e2e/page-objects/omnichannel-chat-transcript.ts

@ -0,0 +1,92 @@
import { faker } from '@faker-js/faker';
import type { Page } from '@playwright/test';
import { IS_EE } from './config/constants';
import { createAuxContext } from './fixtures/createAuxContext';
import { Users } from './fixtures/userStates';
import { OmnichannelLiveChat, HomeOmnichannel } from './page-objects';
import { test, expect } from './utils/test';
test.describe('omnichannel- export chat transcript as PDF', () => {
let poLiveChat: OmnichannelLiveChat;
let newUser: { email: string; name: string };
let agent: { page: Page; poHomeChannel: HomeOmnichannel };
test.beforeAll(async ({ api, browser }) => {
newUser = {
name: faker.name.firstName(),
email: faker.internet.email(),
};
// Set user user 1 as manager and agent
await api.post('/livechat/users/agent', { username: 'user1' });
const { page } = await createAuxContext(browser, Users.user1);
agent = { page, poHomeChannel: new HomeOmnichannel(page) };
});
test.beforeEach(async ({ page }) => {
poLiveChat = new OmnichannelLiveChat(page);
});
test.afterAll(async ({ api }) => {
await api.delete('/livechat/users/agent/user1');
await agent.page.close();
});
test('Export PDF transcript', async ({ page }) => {
await test.step('Expect send a message as a visitor', async () => {
await page.goto('/livechat');
await poLiveChat.btnOpenLiveChat('R').click();
await poLiveChat.sendMessage(newUser, false);
await poLiveChat.onlineAgentMessage.type('this_a_test_message_from_visitor');
await poLiveChat.btnSendMessageToOnlineAgent.click();
});
await test.step('Expect to have 1 omnichannel assigned to agent 1', async () => {
await new Promise(resolve => setTimeout(resolve, 5000));
await agent.poHomeChannel.sidenav.openChat(newUser.name);
});
await test.step('Expect to be not able send transcript as PDF', async () => {
test.skip(!IS_EE, 'Enterprise Only');
await agent.poHomeChannel.content.btnSendTranscript.click();
await agent.poHomeChannel.content.btnSendTranscriptAsPDF.hover();
await expect(agent.poHomeChannel.content.btnSendTranscriptAsPDF).toHaveAttribute('aria-disabled', 'true');
});
await test.step('Expect chat to be closed', async () => {
test.skip(!IS_EE, 'Enterprise Only');
await agent.poHomeChannel.content.btnCloseChat.click();
await agent.poHomeChannel.content.inputModalClosingComment.type('any_comment');
await expect(agent.poHomeChannel.transcript.checkboxPDF).toHaveAttribute('aria-hidden', 'true');
await agent.poHomeChannel.transcript.checkboxPDF.click();
await agent.poHomeChannel.content.btnModalConfirm.click();
await expect(agent.poHomeChannel.toastSuccess).toBeVisible();
});
// Exported PDF can be downloaded from rocket.cat room
await test.step('Expect to have exported PDF in rocket.cat', async () => {
test.skip(!IS_EE, 'Enterprise Only');
await new Promise(resolve => setTimeout(resolve, 3000));
await agent.poHomeChannel.sidenav.openChat('rocket.cat');
await expect(agent.poHomeChannel.transcript.DownloadedPDF).toBeVisible();
});
// PDF can be exported from Omnichannel Contact Center
await test.step('Expect to have exported PDF in rocket.cat', async () => {
test.skip(!IS_EE, 'Enterprise Only');
await agent.poHomeChannel.transcript.contactCenter.click();
await agent.poHomeChannel.transcript.contactCenterChats.click();
await agent.poHomeChannel.transcript.contactCenterSearch.type(newUser.name);
await new Promise(resolve => setTimeout(resolve, 3000));
await agent.poHomeChannel.transcript.firstRow.click();
await agent.poHomeChannel.transcript.viewFullConversation.click();
await agent.poHomeChannel.content.btnSendTranscript.click();
await expect(agent.poHomeChannel.content.btnSendTranscriptAsPDF).toHaveAttribute('aria-disabled', 'false');
await agent.poHomeChannel.content.btnSendTranscriptAsPDF.click();
await expect(agent.poHomeChannel.toastSuccess).toBeVisible();
});
});
});

@ -2,11 +2,16 @@ import fs from 'fs/promises';
import type { Locator, Page } from '@playwright/test';
import { OmnichannelCustomFields } from '../omnichannel-custom-fields';
export class HomeContent {
protected readonly page: Page;
readonly omnichannelCustomFields: OmnichannelCustomFields;
constructor(page: Page) {
this.page = page;
this.omnichannelCustomFields = new OmnichannelCustomFields(page);
}
get inputMessage(): Locator {
@ -156,6 +161,10 @@ export class HomeContent {
return this.page.locator('[data-qa-id="ToolBoxAction-mail-arrow-top-right"]');
}
get btnCloseChat(): Locator {
return this.page.locator('[data-qa-id="ToolBoxAction-balloon-close-top-right"]');
}
get btnSendTranscriptToEmail(): Locator {
return this.page.locator('li.rcx-option', { hasText: 'Send via email' });
}

@ -1,6 +1,7 @@
import type { Locator, Page } from '@playwright/test';
import { HomeOmnichannelContent, HomeSidenav, HomeFlextab, OmnichannelSidenav } from './fragments';
import { OmnichannelTranscript } from './omnichannel-chat-transcript';
import { OmnichannelTriggers } from './omnichannel-triggers';
export class HomeOmnichannel {
@ -16,6 +17,8 @@ export class HomeOmnichannel {
readonly omnisidenav: OmnichannelSidenav;
readonly transcript: OmnichannelTranscript;
constructor(page: Page) {
this.page = page;
this.content = new HomeOmnichannelContent(page);
@ -23,6 +26,7 @@ export class HomeOmnichannel {
this.tabs = new HomeFlextab(page);
this.triggers = new OmnichannelTriggers(page);
this.omnisidenav = new OmnichannelSidenav(page);
this.transcript = new OmnichannelTranscript(page);
}
get toastSuccess(): Locator {

@ -0,0 +1,46 @@
import type { Locator, Page } from '@playwright/test';
import { OmnichannelSidenav } from './fragments';
export class OmnichannelTranscript {
private readonly page: Page;
readonly sidenav: OmnichannelSidenav;
constructor(page: Page) {
this.page = page;
this.sidenav = new OmnichannelSidenav(page);
}
get checkboxPDF(): Locator {
return this.page.locator('//input[@name="transcriptPDF"]//following::i[1]');
}
get exportedPDF(): Locator {
return this.page.locator('//div[contains(text(),"PDF Transcript successfully generated")]');
}
get contactCenter(): Locator {
return this.page.locator('//button[@data-tooltip="Contact Center"]');
}
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 viewFullConversation(): Locator {
return this.page.locator('//button[@title="View full conversation"]/i');
}
get DownloadedPDF(): Locator {
return this.page.locator('[data-qa-type="attachment-title-link"]').last();
}
}
Loading…
Cancel
Save