-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Chore: Add E2E tests to Triggers view #27413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
fb97afa
Adding tests for triggers
Harmeet221 e1df039
Merge branch 'develop' into Triggers-Automation
Harmeet221 fd6b93f
Resolving lint issues
Harmeet221 6ef16dc
Remove Marketplace
Harmeet221 5d8ca5d
Merge branch 'Triggers-Automation' of https://github.com/RocketChat/R…
Harmeet221 976d866
updated triggers file
Harmeet221 adc8f87
adding agent role
Harmeet221 dfe5400
Modified send message function
Harmeet221 18851dc
Skip steps
Harmeet221 386fe3b
Multiple sessions
Harmeet221 9920ae1
Updated flaky locators
Harmeet221 8c45fd1
Merge branch 'develop' into Triggers-Automation
Harmeet221 93a9577
Update apps/meteor/tests/e2e/page-objects/fragments/home-sidenav.ts
Harmeet221 9c77289
Merge branch 'develop' into Triggers-Automation
KevLehman 0060332
Merge branch 'develop' into Triggers-Automation
ggazzo 790efc6
Merge branch 'develop' into Triggers-Automation
kodiakhq[bot] a6bd8dd
Merge branch 'develop' into Triggers-Automation
kodiakhq[bot] e9c3a34
Merge branch 'develop' into Triggers-Automation
KevLehman 1e636c5
Merge branch 'develop' into Triggers-Automation
kodiakhq[bot] 16fa05d
Merge branch 'develop' into Triggers-Automation
kodiakhq[bot] b31a069
Merge branch 'develop' into Triggers-Automation
kodiakhq[bot] 4a454bf
Merge branch 'develop' into Triggers-Automation
kodiakhq[bot] 3584196
Merge branch 'develop' into Triggers-Automation
kodiakhq[bot] 3cd4f85
Merge branch 'develop' into Triggers-Automation
kodiakhq[bot] 191c533
Merge branch 'develop' into Triggers-Automation
murtaza98 0d28e23
fix whitespace issue
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| 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'; | ||
|
|
||
| const createAuxContext = async (browser: Browser, storageState: string): Promise<{ page: Page; poHomeOmnichannel: HomeOmnichannel }> => { | ||
| const page = await browser.newPage({ storageState }); | ||
| const poHomeOmnichannel = new HomeOmnichannel(page); | ||
| await page.goto('/omnichannel/triggers'); | ||
| await page.locator('.main-content').waitFor(); | ||
|
|
||
| return { page, poHomeOmnichannel }; | ||
| }; | ||
|
|
||
| test.describe.serial('omnichannel-triggers', () => { | ||
| let triggersName: string; | ||
| let triggerMessage: string; | ||
| let poLiveChat: OmnichannelLiveChat; | ||
| let newUser: { email: string; name: string }; | ||
| let agent: { page: Page; poHomeOmnichannel: HomeOmnichannel }; | ||
|
|
||
| test.beforeAll(async ({ api, browser }) => { | ||
| newUser = { | ||
| name: faker.name.firstName(), | ||
| email: faker.internet.email(), | ||
| }; | ||
| triggersName = faker.datatype.uuid(); | ||
| triggerMessage = 'Welcome to Rocket.chat'; | ||
| await api.post('/livechat/users/agent', { username: 'user1' }); | ||
| await api.post('/livechat/users/manager', { username: 'user1' }); | ||
| agent = await createAuxContext(browser, 'user1-session.json'); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poLiveChat = new OmnichannelLiveChat(page); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ api }) => { | ||
| await api.delete('/livechat/users/agent/user1'); | ||
| await api.delete('/livechat/users/manager/user1'); | ||
| }); | ||
|
|
||
| test('expect create new trigger', async () => { | ||
| await agent.poHomeOmnichannel.triggers.createTrigger(triggersName, triggerMessage); | ||
| await expect(agent.poHomeOmnichannel.triggers.toastMessage).toBeVisible(); | ||
| }); | ||
|
|
||
| test('expect update trigger', async () => { | ||
| const newTriggerName = `edited-${triggersName}`; | ||
| await agent.poHomeOmnichannel.triggers.firstRowInTriggerTable(triggersName).click(); | ||
| await agent.poHomeOmnichannel.triggers.updateTrigger(newTriggerName); | ||
| await expect(agent.poHomeOmnichannel.triggers.toastMessage).toBeVisible(); | ||
| }); | ||
|
|
||
| test('expect triggers to be displaye on Livechat', async ({ page }) => { | ||
| await test.step('Expect send a message as a visitor', async () => { | ||
| await page.goto('/livechat'); | ||
| await poLiveChat.btnOpenLiveChat('R').click(); | ||
| if (await page.locator('[type="button"] >> text="Chat now"').isVisible()) { | ||
| await page.locator('[type="button"] >> text="Chat now"').click(); | ||
| } | ||
| await poLiveChat.sendMessage(newUser, false); | ||
| await expect(page.locator(`text=${triggerMessage} >> nth=0`)).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test('expect deleting trigger', async () => { | ||
| await agent.poHomeOmnichannel.triggers.btnDeletefirstRowInTable.click(); | ||
| await agent.poHomeOmnichannel.triggers.btnModalRemove.click(); | ||
| await expect(agent.poHomeOmnichannel.triggers.removeToastMessage).toBeVisible(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
apps/meteor/tests/e2e/page-objects/omnichannel-triggers.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| import type { Locator, Page } from '@playwright/test'; | ||
|
|
||
| import { OmnichannelSidenav } from './fragments'; | ||
|
|
||
| export class OmnichannelTriggers { | ||
| private readonly page: Page; | ||
|
|
||
| readonly sidenav: OmnichannelSidenav; | ||
|
|
||
| constructor(page: Page) { | ||
| this.page = page; | ||
| this.sidenav = new OmnichannelSidenav(page); | ||
| } | ||
|
|
||
| get btnNew(): Locator { | ||
| return this.page.locator('text= New'); | ||
| } | ||
|
|
||
| get Name(): Locator { | ||
| return this.page.locator('[placeholder="Name"]'); | ||
| } | ||
|
|
||
| get Description(): Locator { | ||
| return this.page.locator('[placeholder="Description"]'); | ||
| } | ||
|
|
||
| get visitorTimeOnSite(): Locator { | ||
| return this.page.locator('text=Visitor time on site'); | ||
| } | ||
|
|
||
| get visitorPageURL(): Locator { | ||
| return this.page.locator('text=Visitor page URL'); | ||
| } | ||
|
|
||
| get chatOpenedByVisitor(): Locator { | ||
| return this.page.locator('text=Chat opened by the visitor'); | ||
| } | ||
|
|
||
| get addTime(): Locator { | ||
| return this.page.locator('[placeholder="Time in seconds"]'); | ||
| } | ||
|
|
||
| get impersonateAgent(): Locator { | ||
| return this.page.locator('text=Impersonate next agent from queue'); | ||
| } | ||
|
|
||
| get impersonateAgentListBox(): Locator { | ||
| return this.page.locator('ol[role="listbox"] >> text=Impersonate next agent from queue'); | ||
| } | ||
|
|
||
| get customAgent(): Locator { | ||
| return this.page.locator('text=Custom agent'); | ||
| } | ||
|
|
||
| get agentName(): Locator { | ||
| return this.page.locator('[placeholder="Name of agent"]'); | ||
| } | ||
|
|
||
| get textArea(): Locator { | ||
| return this.page.locator('textarea'); | ||
| } | ||
|
|
||
| get saveBtn(): Locator { | ||
| return this.page.locator('button >> text="Save"'); | ||
| } | ||
|
|
||
| get firstRowInTable() { | ||
| return this.page.locator('table tr:first-child td:first-child'); | ||
| } | ||
|
|
||
| firstRowInTriggerTable(triggersName1: string) { | ||
| return this.page.locator(`text="${triggersName1}"`); | ||
| } | ||
|
|
||
| get toastMessage(): Locator { | ||
| return this.page.locator('.rcx-toastbar.rcx-toastbar--success >> nth=0'); | ||
| } | ||
|
|
||
| get inputSearch() { | ||
| return this.page.locator('[placeholder="Search"]'); | ||
| } | ||
|
|
||
| get pageTitle() { | ||
| return this.page.locator('[data-qa-type="PageHeader-title"]'); | ||
| } | ||
|
|
||
| get btnDeletefirstRowInTable() { | ||
| return this.page.locator('table tr:first-child td:last-child button'); | ||
| } | ||
|
|
||
| get btnModalRemove(): Locator { | ||
| return this.page.locator('#modal-root dialog .rcx-modal__inner .rcx-modal__footer .rcx-button--danger'); | ||
| } | ||
|
|
||
| get removeToastMessage(): Locator { | ||
| return this.page.locator('text=Trigger removed'); | ||
| } | ||
|
|
||
| public async createTrigger(triggersName: string, triggerMessage: string) { | ||
| await this.btnNew.click(); | ||
| await this.Name.fill(triggersName); | ||
| await this.Description.fill('Creating a fresh trigger'); | ||
| await this.visitorPageURL.click(); | ||
| await this.visitorTimeOnSite.click(); | ||
| await this.addTime.click(); | ||
| await this.addTime.fill('5s'); | ||
| await this.impersonateAgent.click(); | ||
| await this.textArea.fill(triggerMessage); | ||
| await this.saveBtn.click(); | ||
| } | ||
|
|
||
| public async updateTrigger(newName: string) { | ||
| await this.Name.fill(newName); | ||
| await this.Description.fill('Updating the existing trigger'); | ||
| await this.visitorTimeOnSite.click(); | ||
| await this.chatOpenedByVisitor.click(); | ||
| await this.impersonateAgent.click(); | ||
| await this.customAgent.click(); | ||
| await this.agentName.fill('Rocket.cat'); | ||
| await this.saveBtn.click(); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.