-
Notifications
You must be signed in to change notification settings - Fork 13k
fix: Contact's custom fields are now properly sent to api #35879
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eb4422c
fix: refactors contact review payload to correctly apply customFields
lucas-a-pelegrino 47046e5
docs: adds changeset
lucas-a-pelegrino b7b8428
test: adds e2e tests for review contact modal
lucas-a-pelegrino a4f02c6
Merge branch 'bugfix/CTZ-97' of github.com:RocketChat/Rocket.Chat int…
lucas-a-pelegrino aec2dd8
test: adjusted request payloads
aleksandernsilva ba295ad
test: improved e2e tests
aleksandernsilva 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,5 @@ | ||
| --- | ||
| "@rocket.chat/meteor": patch | ||
| --- | ||
|
|
||
| Fixes contact's conflict resolution not working due to invalid parameters |
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
93 changes: 93 additions & 0 deletions
93
apps/meteor/tests/e2e/omnichannel/omnichannel-contact-conflict-review.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,93 @@ | ||
| import { faker } from '@faker-js/faker'; | ||
|
|
||
| import { createFakeVisitor } from '../../mocks/data'; | ||
| import { IS_EE } from '../config/constants'; | ||
| import { Users } from '../fixtures/userStates'; | ||
| import { HomeOmnichannel } from '../page-objects'; | ||
| import { createCustomField } from '../utils/omnichannel/custom-field'; | ||
| import { createConversation } from '../utils/omnichannel/rooms'; | ||
| import { test, expect } from '../utils/test'; | ||
|
|
||
| const visitor = createFakeVisitor(); | ||
|
|
||
| test.skip(!IS_EE, 'Omnichannel Contact Review > Enterprise Only'); | ||
|
|
||
| test.use({ storageState: Users.user1.state }); | ||
|
|
||
| test.describe.serial('OC - Contact Review', () => { | ||
| let poHomeChannel: HomeOmnichannel; | ||
|
|
||
| const customFieldName = faker.string.uuid(); | ||
| const visitorToken = faker.string.uuid(); | ||
| let conversation: Awaited<ReturnType<typeof createConversation>>; | ||
| let customField: Awaited<ReturnType<typeof createCustomField>>; | ||
|
|
||
| test.beforeAll(async ({ api }) => { | ||
| ( | ||
| await Promise.all([ | ||
| api.post('/livechat/users/agent', { username: 'user1' }), | ||
| api.post('/livechat/users/manager', { username: 'user1' }), | ||
| ]) | ||
| ).every((res) => expect(res.status()).toBe(200)); | ||
|
|
||
| customField = await createCustomField(api, { field: customFieldName }); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poHomeChannel = new HomeOmnichannel(page); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('/'); | ||
| await page.locator('.main-content').waitFor(); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ api }) => { | ||
| conversation = await createConversation(api, { visitorName: visitor.name, agentId: `user1`, visitorToken }); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ api }) => { | ||
| const resCustomFieldA = await api.post('/livechat/custom.field', { | ||
| token: visitorToken, | ||
| key: customFieldName, | ||
| value: 'custom-field-value', | ||
| overwrite: true, | ||
| }); | ||
|
|
||
| expect(resCustomFieldA.status()).toBe(200); | ||
|
|
||
| const resCustomFieldB = await api.post('/livechat/custom.field', { | ||
| token: visitorToken, | ||
| key: customFieldName, | ||
| value: 'custom-field-value-2', | ||
| overwrite: false, | ||
| }); | ||
|
|
||
| expect(resCustomFieldB.status()).toBe(200); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ api }) => { | ||
| (await Promise.all([api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1')])).every((res) => | ||
| expect(res.status()).toBe(200), | ||
| ); | ||
|
|
||
| await conversation.delete(); | ||
| await customField.delete(); | ||
| }); | ||
|
|
||
| test('OC - Contact Review - Update custom field conflicting', async ({ page }) => { | ||
| await poHomeChannel.sidenav.getSidebarItemByName(visitor.name).click(); | ||
| await poHomeChannel.content.btnContactInformation.click(); | ||
|
|
||
| await poHomeChannel.content.contactReviewModal.btnSeeConflicts.click(); | ||
|
|
||
| await poHomeChannel.content.contactReviewModal.getFieldByName(customFieldName).click(); | ||
| await poHomeChannel.content.contactReviewModal.findOption('custom-field-value-2').click(); | ||
| await poHomeChannel.content.contactReviewModal.btnSave.click(); | ||
|
|
||
| const response = await page.waitForResponse('**/api/v1/omnichannel/contacts.update'); | ||
| await expect(response.status()).toBe(200); | ||
|
|
||
| await expect(poHomeChannel.content.contactReviewModal.btnSeeConflicts).not.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
25 changes: 25 additions & 0 deletions
25
apps/meteor/tests/e2e/page-objects/omnichannel-contact-review-modal.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,25 @@ | ||
| import type { Locator, Page } from '@playwright/test'; | ||
|
|
||
| export class OmnichannelContactReviewModal { | ||
| private readonly page: Page; | ||
|
|
||
| constructor(page: Page) { | ||
| this.page = page; | ||
| } | ||
|
|
||
| get btnSeeConflicts(): Locator { | ||
| return this.page.getByRole('button', { name: 'See conflicts', exact: true }); | ||
| } | ||
|
|
||
| get btnSave(): Locator { | ||
| return this.page.getByRole('button', { name: 'Save', exact: true }); | ||
| } | ||
|
|
||
| getFieldByName(name: string): Locator { | ||
| return this.page.getByLabel(name, { exact: true }); | ||
| } | ||
|
|
||
| findOption(name: string): Locator { | ||
| return this.page.getByRole('option', { name, exact: true }); | ||
| } | ||
| } |
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,54 @@ | ||
| import type { ILivechatCustomField } from '@rocket.chat/core-typings'; | ||
|
|
||
| import { parseMeteorResponse } from '../parseMeteorResponse'; | ||
| import type { BaseTest } from '../test'; | ||
|
|
||
| type CustomField = Omit<ILivechatCustomField, '_id' | '_updatedAt'> & { field: string }; | ||
|
|
||
| export const removeCustomField = (api: BaseTest['api'], id: string) => { | ||
| return api.post('/method.call/livechat:deleteCustomField', { | ||
| method: 'livechat:saveCustomField', | ||
| params: [id], | ||
| id: 'id', | ||
| msg: 'method', | ||
| }); | ||
| }; | ||
|
|
||
| export const createCustomField = async (api: BaseTest['api'], overwrides: Partial<CustomField>) => { | ||
| const response = await api.post('/method.call/livechat:saveCustomField', { | ||
| message: JSON.stringify({ | ||
| method: 'livechat:saveCustomField', | ||
| params: [ | ||
| null, | ||
| { | ||
| field: overwrides.field, | ||
| label: overwrides.label || overwrides.field, | ||
| visibility: 'visible', | ||
| scope: 'visitor', | ||
| searchable: false, | ||
| regexp: '', | ||
| type: 'input', | ||
| required: false, | ||
| defaultValue: '', | ||
| options: '', | ||
| public: false, | ||
| ...overwrides, | ||
| }, | ||
| ], | ||
| id: 'id', | ||
| msg: 'method', | ||
| }), | ||
| }); | ||
|
|
||
| if (!response.ok()) { | ||
| throw new Error(`Failed to create custom field [http status: ${response.status()}]`); | ||
| } | ||
|
|
||
| const customField = await parseMeteorResponse<CustomField & { _id: string }>(response); | ||
|
|
||
| return { | ||
| response, | ||
| customField, | ||
| delete: () => removeCustomField(api, customField._id), | ||
| }; | ||
| }; |
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.