parent
aa77a17c25
commit
de2a5ff9af
@ -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(); |
||||
}); |
||||
}); |
||||
}); |
||||
|
||||
@ -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…
Reference in new issue