-
Notifications
You must be signed in to change notification settings - Fork 13.2k
test: Add automated tests for custom fields functionality. #38743
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
Open
Harmeet221
wants to merge
13
commits into
develop
Choose a base branch
from
custom-field-implementation
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c5e3232
test: custom field usage
Harmeet221 2dc2534
remove comments
Harmeet221 a540ac8
remove comments
Harmeet221 2649557
added promise.all
Harmeet221 d08b14a
fixed review
Harmeet221 7062e18
Merge branch 'develop' into custom-field-implementation
kodiakhq[bot] bc6ea50
Merge branch 'develop' into custom-field-implementation
kodiakhq[bot] f92df4b
Merge branch 'develop' into custom-field-implementation
kodiakhq[bot] 4521c4d
Merge branch 'develop' into custom-field-implementation
kodiakhq[bot] 92219e0
Merge branch 'develop' into custom-field-implementation
kodiakhq[bot] 949c5b9
Merge branch 'develop' into custom-field-implementation
kodiakhq[bot] 69763a4
Merge branch 'develop' into custom-field-implementation
kodiakhq[bot] 8e1e9b9
improved locator
Harmeet221 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
154 changes: 154 additions & 0 deletions
154
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.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,154 @@ | ||
| import { faker } from '@faker-js/faker'; | ||
|
|
||
| import { createFakeVisitor } from '../../mocks/data'; | ||
| import { Users } from '../fixtures/userStates'; | ||
| import { HomeOmnichannel } from '../page-objects'; | ||
| import { createAgent } from '../utils/omnichannel/agents'; | ||
| import { createCustomField, setVisitorCustomFieldValue } from '../utils/omnichannel/custom-field'; | ||
| import { createManager } from '../utils/omnichannel/managers'; | ||
| import { createConversation } from '../utils/omnichannel/rooms'; | ||
| import { test, expect } from '../utils/test'; | ||
|
|
||
| const visitor = createFakeVisitor(); | ||
|
|
||
| test.use({ storageState: Users.user1.state }); | ||
|
|
||
| test.describe.serial('OC - Custom fields usage, scope : room and visitor', () => { | ||
| let poHomeChannel: HomeOmnichannel; | ||
|
|
||
| const roomCustomFieldLabel = `room_cf_${faker.string.alpha(8)}`; | ||
| const roomCustomFieldName = roomCustomFieldLabel; | ||
| const roomCustomFieldValue = faker.lorem.words(3); | ||
|
|
||
| const visitorCustomFieldLabel = `visitor_cf_${faker.string.alpha(8)}`; | ||
| const visitorCustomFieldName = visitorCustomFieldLabel; | ||
| const visitorCustomFieldValue = faker.lorem.words(3); | ||
| const visitorToken = faker.string.uuid(); | ||
|
|
||
| let agent: Awaited<ReturnType<typeof createAgent>>; | ||
| let manager: Awaited<ReturnType<typeof createManager>>; | ||
| let conversation: Awaited<ReturnType<typeof createConversation>>; | ||
| let roomCustomField: Awaited<ReturnType<typeof createCustomField>>; | ||
| let visitorCustomField: Awaited<ReturnType<typeof createCustomField>>; | ||
|
|
||
| test.beforeAll('Set up agent, manager and custom fields', async ({ api }) => { | ||
| [agent, manager] = await Promise.all([createAgent(api, 'user1'), createManager(api, 'user1')]); | ||
|
|
||
| [roomCustomField, visitorCustomField, conversation] = await Promise.all([ | ||
| createCustomField(api, { | ||
| field: roomCustomFieldLabel, | ||
| label: roomCustomFieldName, | ||
| scope: 'room', | ||
| }), | ||
| createCustomField(api, { | ||
| field: visitorCustomFieldLabel, | ||
| label: visitorCustomFieldName, | ||
| scope: 'visitor', | ||
| }), | ||
| createConversation(api, { | ||
| visitorName: visitor.name, | ||
| agentId: 'user1', | ||
| visitorToken, | ||
| }), | ||
| ]); | ||
|
|
||
| await setVisitorCustomFieldValue(api, { | ||
| token: visitorToken, | ||
| customFieldId: visitorCustomField.customField._id, | ||
| value: visitorCustomFieldValue, | ||
| }); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poHomeChannel = new HomeOmnichannel(page); | ||
| await page.goto('/'); | ||
| await poHomeChannel.waitForHome(); | ||
| }); | ||
|
|
||
| test.afterAll('Remove agent, manager, custom fields and conversation', async () => { | ||
| await Promise.all([agent.delete(), manager.delete(), roomCustomField.delete(), visitorCustomField.delete(), conversation.delete()]); | ||
| }); | ||
|
|
||
| test('Should be allowed to set room custom field for a conversation', async () => { | ||
| await test.step('Agent opens the conversation', async () => { | ||
| await poHomeChannel.sidebar.getSidebarItemByName(visitor.name).click(); | ||
| }); | ||
|
|
||
| await test.step('Agent opens edit room', async () => { | ||
| await poHomeChannel.roomInfo.waitForDisplay(); | ||
| await poHomeChannel.roomInfo.btnEdit.click(); | ||
| await poHomeChannel.editRoomInfo.waitForDisplay(); | ||
| }); | ||
|
|
||
| await test.step('Agent fills room custom field and saves', async () => { | ||
| await poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel).fill(roomCustomFieldValue); | ||
| await poHomeChannel.editRoomInfo.btnSave.click(); | ||
| }); | ||
|
|
||
| await test.step('Custom field should be updated successfully', async () => { | ||
| await poHomeChannel.roomInfo.btnEdit.click(); | ||
| await poHomeChannel.editRoomInfo.waitForDisplay(); | ||
| await expect(poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel)).toHaveValue(roomCustomFieldValue); | ||
| }); | ||
| }); | ||
|
|
||
| test('Should be allowed to update existing room custom field', async () => { | ||
| const updatedValue = faker.lorem.words(2); | ||
|
|
||
| await test.step('Agent opens the conversation', async () => { | ||
| await poHomeChannel.sidebar.getSidebarItemByName(visitor.name).click(); | ||
| }); | ||
|
|
||
| await test.step('Agent opens edit room and updates custom field', async () => { | ||
| await poHomeChannel.roomInfo.waitForDisplay(); | ||
| await poHomeChannel.roomInfo.btnEdit.click(); | ||
| await poHomeChannel.editRoomInfo.waitForDisplay(); | ||
| await poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel).fill(updatedValue); | ||
| await poHomeChannel.editRoomInfo.btnSave.click(); | ||
| }); | ||
|
|
||
| await test.step('Room Information displays the updated custom field value', async () => { | ||
| await poHomeChannel.roomInfo.btnEdit.click(); | ||
| await poHomeChannel.editRoomInfo.waitForDisplay(); | ||
| await expect(poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel)).toHaveValue(updatedValue); | ||
| }); | ||
| }); | ||
|
|
||
| test('Should verify that the visitor custom field is set', async () => { | ||
| await test.step('Agent opens the conversation', async () => { | ||
| await poHomeChannel.sidebar.getSidebarItemByName(visitor.name).click(); | ||
| }); | ||
|
|
||
| await test.step('Agent opens Contact Information', async () => { | ||
| await poHomeChannel.roomToolbar.openContactInfo(); | ||
| await expect(poHomeChannel.contacts.contactInfo.dialogContactInfo).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Assert custom field is set successfully', async () => { | ||
| await expect(poHomeChannel.contacts.contactInfo.dialogContactInfo).toContainText(visitorCustomFieldValue); | ||
| }); | ||
| }); | ||
|
|
||
| test('Should be allowed to update existing visitor custom field', async () => { | ||
| const updatedVisitorCustomFieldValue = faker.lorem.words(2); | ||
|
|
||
| await test.step('Agent opens the conversation', async () => { | ||
| await poHomeChannel.sidebar.getSidebarItemByName(visitor.name).click(); | ||
| }); | ||
|
|
||
| await test.step('Agent opens Contact Information', async () => { | ||
| await poHomeChannel.roomToolbar.openContactInfo(); | ||
| await expect(poHomeChannel.contacts.contactInfo.dialogContactInfo).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Agent clicks edit and updates visitor custom field', async () => { | ||
| await poHomeChannel.contacts.contactInfo.btnEdit.click(); | ||
| await poHomeChannel.contacts.contactInfo.getVisitorCustomField(visitorCustomFieldLabel).fill(updatedVisitorCustomFieldValue); | ||
| await poHomeChannel.contacts.contactInfo.btnSave.click(); | ||
| }); | ||
|
|
||
| await test.step('Assert custom field is updated successfully', async () => { | ||
| await expect(poHomeChannel.contacts.contactInfo.dialogContactInfo).toContainText(updatedVisitorCustomFieldValue); | ||
| }); | ||
| }); | ||
| }); | ||
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
Oops, something went wrong.
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.