-
Notifications
You must be signed in to change notification settings - Fork 13k
feat: Allow to dismiss contact unknown callout #35703
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
14 commits
Select commit
Hold shift + click to select a range
e7b36a6
chore: removed old i18n expressions
aleksandernsilva 103d858
feat: updated unknown contact callout title and description
aleksandernsilva aa52e5d
feat: added dismiss action to unknown contact callout
aleksandernsilva 622c919
test: added generics to createFakeRoom
aleksandernsilva 7bd772f
test: added mock functions createFakeContact & createFakeContactChannel
aleksandernsilva dab8058
test: added unit tests to ComposerOmnichannelCallout
aleksandernsilva 4ccc583
test: added e2e tests to ComposerOmnichannelCallout
aleksandernsilva b608783
chore: changeset
aleksandernsilva 7e5a3d9
feat: improved callout's accessibility
aleksandernsilva 6dc32cd
test: updated to a more semantic locator
aleksandernsilva f555e62
refactor: changed from local storage to session storage
aleksandernsilva b1c681b
refactor: use dismiss instead of close
aleksandernsilva d21ef67
Merge branch 'develop' into feat/dismiss-contact-unknown-callout
kodiakhq[bot] 42c2392
Merge branch 'develop' into feat/dismiss-contact-unknown-callout
kodiakhq[bot] 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,6 @@ | ||
| --- | ||
| "@rocket.chat/meteor": minor | ||
| "@rocket.chat/i18n": minor | ||
| --- | ||
|
|
||
| Adds close action to contact unknown callout displayed within Livechat rooms |
75 changes: 75 additions & 0 deletions
75
...meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelCallout.spec.tsx
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,75 @@ | ||
| import { faker } from '@faker-js/faker/locale/af_ZA'; | ||
| import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; | ||
| import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
| import { render, screen, waitFor } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
|
|
||
| import ComposerOmnichannelCallout from './ComposerOmnichannelCallout'; | ||
| import FakeRoomProvider from '../../../../../tests/mocks/client/FakeRoomProvider'; | ||
| import { createFakeContact, createFakeRoom } from '../../../../../tests/mocks/data'; | ||
|
|
||
| jest.mock('../../../omnichannel/contactInfo/tabs/ContactInfoChannels/useBlockChannel', () => ({ | ||
| useBlockChannel: () => jest.fn(), | ||
| })); | ||
|
|
||
| const fakeVisitor = { | ||
| _id: faker.string.uuid(), | ||
| token: faker.string.uuid(), | ||
| username: faker.internet.userName(), | ||
| }; | ||
|
|
||
| const fakeRoom = createFakeRoom<IOmnichannelRoom>({ t: 'l', v: fakeVisitor }); | ||
| const fakeContact = createFakeContact(); | ||
|
|
||
| it('should be displayed if contact is unknown', async () => { | ||
| const getContactMockFn = jest.fn().mockResolvedValue({ contact: fakeContact }); | ||
| const wrapper = mockAppRoot().withEndpoint('GET', '/v1/omnichannel/contacts.get', getContactMockFn).withRoom(fakeRoom); | ||
|
|
||
| render( | ||
| <FakeRoomProvider roomOverrides={fakeRoom}> | ||
| <ComposerOmnichannelCallout /> | ||
| </FakeRoomProvider>, | ||
| { wrapper: wrapper.build() }, | ||
| ); | ||
|
|
||
| await waitFor(() => expect(getContactMockFn).toHaveBeenCalled()); | ||
| expect(screen.getByText('Unknown_contact_callout_description')).toBeVisible(); | ||
| expect(screen.getByRole('button', { name: 'Add_contact' })).toBeVisible(); | ||
| expect(screen.getByRole('button', { name: 'Block' })).toBeVisible(); | ||
| expect(screen.getByRole('button', { name: 'Dismiss' })).toBeVisible(); | ||
| }); | ||
|
|
||
| it('should not be displayed if contact is known', async () => { | ||
| const getContactMockFn = jest.fn().mockResolvedValue({ contact: createFakeContact({ unknown: false }) }); | ||
| const wrapper = mockAppRoot().withEndpoint('GET', '/v1/omnichannel/contacts.get', getContactMockFn).withRoom(fakeRoom); | ||
|
|
||
| render( | ||
| <FakeRoomProvider roomOverrides={fakeRoom}> | ||
| <ComposerOmnichannelCallout /> | ||
| </FakeRoomProvider>, | ||
| { wrapper: wrapper.build() }, | ||
| ); | ||
|
|
||
| await waitFor(() => expect(getContactMockFn).toHaveBeenCalled()); | ||
| expect(screen.queryByText('Unknown_contact_callout_description')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should hide callout on dismiss', async () => { | ||
| const getContactMockFn = jest.fn().mockResolvedValue({ contact: fakeContact }); | ||
| const wrapper = mockAppRoot().withEndpoint('GET', '/v1/omnichannel/contacts.get', getContactMockFn).withRoom(fakeRoom); | ||
|
|
||
| render( | ||
| <FakeRoomProvider roomOverrides={fakeRoom}> | ||
| <ComposerOmnichannelCallout /> | ||
| </FakeRoomProvider>, | ||
| { wrapper: wrapper.build() }, | ||
| ); | ||
|
|
||
| await waitFor(() => expect(getContactMockFn).toHaveBeenCalled()); | ||
| expect(screen.getByText('Unknown_contact_callout_description')).toBeVisible(); | ||
|
|
||
| const btnDismiss = screen.getByRole('button', { name: 'Dismiss' }); | ||
| await userEvent.click(btnDismiss); | ||
|
|
||
| expect(screen.queryByText('Unknown_contact_callout_description')).not.toBeInTheDocument(); | ||
| }); |
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
69 changes: 69 additions & 0 deletions
69
apps/meteor/tests/e2e/omnichannel/omnichannel-contact-unknown-callout.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,69 @@ | ||
| import type { Page } from '@playwright/test'; | ||
|
|
||
| import { createFakeVisitor } from '../../mocks/data'; | ||
| import { IS_EE } from '../config/constants'; | ||
| import { createAuxContext } from '../fixtures/createAuxContext'; | ||
| import { Users } from '../fixtures/userStates'; | ||
| import { OmnichannelLiveChat, HomeChannel } from '../page-objects'; | ||
| import { expect, test } from '../utils/test'; | ||
|
|
||
| test.describe('OC - Contact Unknown Callout', () => { | ||
| test.skip(!IS_EE, 'Enterprise Only'); | ||
|
|
||
| let poLiveChat: OmnichannelLiveChat; | ||
| let newVisitor: { email: string; name: string }; | ||
|
|
||
| let agent: { page: Page; poHomeChannel: HomeChannel }; | ||
|
|
||
| test.beforeAll(async ({ api, browser }) => { | ||
| newVisitor = createFakeVisitor(); | ||
|
|
||
| await api.post('/livechat/users/agent', { username: 'user1' }); | ||
| await api.post('/livechat/users/manager', { username: 'user1' }); | ||
|
|
||
| const { page } = await createAuxContext(browser, Users.user1); | ||
| agent = { page, poHomeChannel: new HomeChannel(page) }; | ||
| }); | ||
| test.beforeEach(async ({ page, api }) => { | ||
| poLiveChat = new OmnichannelLiveChat(page, api); | ||
| }); | ||
|
|
||
| test.beforeEach('create livechat conversation', async ({ page }) => { | ||
| await page.goto('/livechat'); | ||
| await poLiveChat.openLiveChat(); | ||
| await poLiveChat.sendMessage(newVisitor, false); | ||
| await poLiveChat.onlineAgentMessage.type('this_a_test_message_from_visitor'); | ||
| await poLiveChat.btnSendMessageToOnlineAgent.click(); | ||
| }); | ||
|
|
||
| test.afterEach('close livechat conversation', async () => { | ||
| await poLiveChat.closeChat(); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ api }) => { | ||
| await api.delete('/livechat/users/agent/user1'); | ||
| await api.delete('/livechat/users/manager/user1'); | ||
| await agent.page.close(); | ||
| }); | ||
|
|
||
| test('OC - Contact Unknown Callout - Dismiss callout', async () => { | ||
| await test.step('expect to open conversation', async () => { | ||
| await agent.poHomeChannel.sidenav.openChat(newVisitor.name); | ||
| }); | ||
|
|
||
| await test.step('expect contact unknown callout to be visible', async () => { | ||
| await expect(agent.poHomeChannel.content.contactUnknownCallout).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('expect to hide callout when dismiss is clicked', async () => { | ||
| await agent.poHomeChannel.content.btnDismissContactUnknownCallout.click(); | ||
| await expect(agent.poHomeChannel.content.contactUnknownCallout).not.toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('expect keep callout hidden after changing pages', async () => { | ||
| await agent.poHomeChannel.sidenav.sidebarHomeAction.click(); | ||
| await agent.poHomeChannel.sidenav.openChat(newVisitor.name); | ||
| await expect(agent.poHomeChannel.content.contactUnknownCallout).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
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
Oops, something went wrong.
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.