-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implemented e2e tests for manage monitors page (#31067)
- Loading branch information
1 parent
ef9fc92
commit b78845a
Showing
5 changed files
with
151 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
96 changes: 96 additions & 0 deletions
96
apps/meteor/tests/e2e/omnichannel/omnichannel-monitors.spec.ts
This file contains 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,96 @@ | ||
import { IS_EE } from '../config/constants'; | ||
import { Users } from '../fixtures/userStates'; | ||
import { OmnichannelMonitors } from '../page-objects'; | ||
import { test, expect } from '../utils/test'; | ||
|
||
test.use({ storageState: Users.user1.state }); | ||
|
||
test.skip(!IS_EE, 'OC - Manage Monitors > Enterprise Only'); | ||
|
||
test.describe.serial('OC - Manage Monitors', () => { | ||
let poMonitors: OmnichannelMonitors; | ||
|
||
test.beforeAll(async ({ api }) => { | ||
await Promise.all([ | ||
api.post('/livechat/users/agent', { username: 'user1' }), | ||
api.post('/livechat/users/agent', { username: 'user2' }), | ||
api.post('/livechat/users/manager', { username: 'user1' }), | ||
]); | ||
}); | ||
|
||
test.afterAll(async ({ api }) => { | ||
await Promise.all([ | ||
api.delete('/livechat/users/agent/user1'), | ||
api.delete('/livechat/users/manager/user1'), | ||
api.delete('/livechat/users/agent/user2'), | ||
api.delete('/livechat/users/manager/user2'), | ||
]); | ||
}); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
poMonitors = new OmnichannelMonitors(page); | ||
|
||
await page.goto('/omnichannel'); | ||
await page.locator('.main-content').waitFor(); | ||
await poMonitors.sidenav.linkMonitors.click(); | ||
}); | ||
|
||
test('OC - Manager Monitors - Add monitor', async () => { | ||
await test.step('expect to add agent as monitor', async () => { | ||
await expect(poMonitors.findRowByName('user1')).not.toBeVisible(); | ||
await poMonitors.selectMonitor('user1'); | ||
await poMonitors.btnAddMonitor.click(); | ||
await expect(poMonitors.findRowByName('user1')).toBeVisible(); | ||
}); | ||
|
||
await test.step('expect to remove agent from monitor', async () => { | ||
await poMonitors.btnRemoveByName('user1').click(); | ||
await expect(poMonitors.modalConfirmRemove).toBeVisible(); | ||
await poMonitors.btnConfirmRemove.click(); | ||
await expect(poMonitors.findRowByName('user1')).not.toBeVisible(); | ||
}); | ||
}); | ||
|
||
test('OC - Manager Monitors - Search', async () => { | ||
await test.step('expect to add 2 monitors', async () => { | ||
await poMonitors.selectMonitor('user1'); | ||
await poMonitors.btnAddMonitor.click(); | ||
|
||
await poMonitors.selectMonitor('user2'); | ||
await poMonitors.btnAddMonitor.click(); | ||
|
||
await expect(poMonitors.findRowByName('user1')).toBeVisible(); | ||
await expect(poMonitors.findRowByName('user2')).toBeVisible(); | ||
}); | ||
|
||
await test.step('expect to search monitor', async () => { | ||
await expect(poMonitors.findRowByName('user1')).toBeVisible(); | ||
await expect(poMonitors.findRowByName('user2')).toBeVisible(); | ||
|
||
await poMonitors.inputSearch.fill('user1'); | ||
await expect(poMonitors.findRowByName('user1')).toBeVisible(); | ||
await expect(poMonitors.findRowByName('user2')).not.toBeVisible(); | ||
|
||
await poMonitors.inputSearch.fill('user2'); | ||
await expect(poMonitors.findRowByName('user1')).not.toBeVisible(); | ||
await expect(poMonitors.findRowByName('user2')).toBeVisible(); | ||
|
||
await poMonitors.inputSearch.fill(''); | ||
await expect(poMonitors.findRowByName('user1')).toBeVisible(); | ||
await expect(poMonitors.findRowByName('user2')).toBeVisible(); | ||
}); | ||
|
||
await test.step('expect to remove monitors', async () => { | ||
await poMonitors.btnRemoveByName('user1').click(); | ||
await expect(poMonitors.modalConfirmRemove).toBeVisible(); | ||
await poMonitors.btnConfirmRemove.click(); | ||
|
||
await poMonitors.btnRemoveByName('user2').click(); | ||
await expect(poMonitors.modalConfirmRemove).toBeVisible(); | ||
await poMonitors.btnConfirmRemove.click(); | ||
|
||
await expect(poMonitors.findRowByName('user1')).not.toBeVisible(); | ||
await expect(poMonitors.findRowByName('user2')).not.toBeVisible(); | ||
}); | ||
}); | ||
}); |
This file contains 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 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
38 changes: 38 additions & 0 deletions
38
apps/meteor/tests/e2e/page-objects/omnichannel-monitors.ts
This file contains 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,38 @@ | ||
import type { Locator } from '@playwright/test'; | ||
|
||
import { OmnichannelAdministration } from './omnichannel-administration'; | ||
|
||
export class OmnichannelMonitors extends OmnichannelAdministration { | ||
get modalConfirmRemove(): Locator { | ||
return this.page.locator('[data-qa-id="manage-monitors-confirm-remove"]'); | ||
} | ||
|
||
get btnConfirmRemove(): Locator { | ||
return this.modalConfirmRemove.locator('role=button[name="Delete"]'); | ||
} | ||
|
||
get btnAddMonitor(): Locator { | ||
return this.page.locator('role=button[name="Add monitor"]'); | ||
} | ||
|
||
get inputMonitor(): Locator { | ||
return this.page.locator('input[name="monitor"]'); | ||
} | ||
|
||
get inputSearch(): Locator { | ||
return this.page.locator('input[placeholder="Search"]'); | ||
} | ||
|
||
findRowByName(name: string): Locator { | ||
return this.page.locator(`tr[data-qa-id="${name}"]`); | ||
} | ||
|
||
btnRemoveByName(name: string): Locator { | ||
return this.findRowByName(name).locator('role=button[name="Remove"]'); | ||
} | ||
|
||
async selectMonitor(name: string) { | ||
await this.inputMonitor.fill(name); | ||
await this.page.locator(`li[role="option"]`, { has: this.page.locator(`[data-username='${name}']`) }).click(); | ||
} | ||
} |