-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat: update Livechat_enabled_when_agent_idle setting to not include offline agents in the query
#39495
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
nazabucciarelli
wants to merge
57
commits into
develop
Choose a base branch
from
fix/livechat-offline-agent-assignment
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
feat: update Livechat_enabled_when_agent_idle setting to not include offline agents in the query
#39495
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
d3fbcf9
move offline agents filtering to query root
nazabucciarelli 04dc75a
fix user presence update from test users
nazabucciarelli 81cf18e
fix linter error
nazabucciarelli 391cce0
Merge branch 'develop' into fix/livechat-offline-agent-assignment
nazabucciarelli cae2152
rollback TEST_MODE conditional
nazabucciarelli 0942d4a
add ws user helpers to fix connectionStatus on tests
nazabucciarelli 9102e16
test on CI without closing ws
nazabucciarelli 395c57b
add use of setUserAwayWS to routing test
nazabucciarelli 6ebec42
enhance ws connection, add ws closures
nazabucciarelli 8b41cd9
change ws port to 3000
nazabucciarelli 6f3c33f
update idle status tests from routing
nazabucciarelli 79d8eb9
fix playwright tests
nazabucciarelli 46d52d0
add ws closure to playwright tests
nazabucciarelli 6c3b010
improve ws cleanup on rooms test, make ws port depend on CI env variable
nazabucciarelli 8137749
fix conflict with develop
nazabucciarelli 7c2f150
remove unintended test lines
nazabucciarelli fcd37ad
Merge branch 'develop' into fix/livechat-offline-agent-assignment
nazabucciarelli 02239ef
add changeset
nazabucciarelli ba26d7f
remove unneeded ws closures
nazabucciarelli e287b5b
handle errors on websockets result
nazabucciarelli 1ae6230
remove accidental timeout
nazabucciarelli 6134a5c
add DDP_LOGIN_PORT env variable for ws connection
nazabucciarelli f6e4a54
Merge branch 'develop' into fix/livechat-offline-agent-assignment
nazabucciarelli fca1d9a
Correct phrasing in changeset description
nazabucciarelli 0b3395c
add forgotten CI new env variable
nazabucciarelli e74d5af
Merge branch 'fix/livechat-offline-agent-assignment' of github.com:Ro…
nazabucciarelli 6d760f1
safe ws closure
nazabucciarelli 7199cc4
enhance overall WS connection logic
nazabucciarelli d808a27
add onError handler for ws
nazabucciarelli 6f6597e
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into fix/…
nazabucciarelli b19afad
modify changeset from patch to minor
nazabucciarelli 06820bc
remove sendAction parameter in favor of stringifiedJsonPayload
nazabucciarelli c75d663
add comment to document auto-assignment bussines rule
nazabucciarelli 402aad3
change websocket variables naming
nazabucciarelli f4c0f10
Update .changeset/purple-boxes-shout.md
KevLehman d03991e
Update .changeset/purple-boxes-shout.md
KevLehman 928583f
remove ddpLogin from livechat test
nazabucciarelli 8bfbc05
Merge branch 'fix/livechat-offline-agent-assignment' of github.com:Ro…
nazabucciarelli a4845d9
update e2e tests to not use ddpLogin
nazabucciarelli b047bc0
implement omnichannel room forward e2e tests
nazabucciarelli b35f583
remove converted api tests and ws logic from 00-rooms.ts
nazabucciarelli 99144ed
add e2e test for livechat_enabled_when_agent_idle setting
nazabucciarelli 17ffb08
remove converted tests from 24-routing.ts
nazabucciarelli 8dae157
rollback ws logic
nazabucciarelli 9303454
remove ci-test-e2e.yml added env variable
nazabucciarelli 489e27f
remove .only
nazabucciarelli 484e3c2
fix livechat test by adding agent browser context
nazabucciarelli 5aec5db
improve tests by using element waiter instead of hardcoded sleep and …
nazabucciarelli 851a449
move setting update to the end of needed test cases
nazabucciarelli e7898f2
use long ifs
nazabucciarelli 1de82a7
use toBeOK instead of toBe for 200 status assertion
nazabucciarelli f332eaf
Merge branch 'develop' into fix/livechat-offline-agent-assignment
nazabucciarelli e17527e
add toBeOK on all api calls, organize the code better
nazabucciarelli 59c0a05
Merge branch 'fix/livechat-offline-agent-assignment' of github.com:Ro…
nazabucciarelli d0fb398
move turn agent away logic to beforeEach instead of having it as a step
nazabucciarelli 521487c
remove unneeded resolves, use createConversation
nazabucciarelli 68f13c0
move createConversation logic to separate beforeEach
nazabucciarelli 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/models': minor | ||
| '@rocket.chat/meteor': minor | ||
| --- | ||
|
|
||
| Updates omnichannel routing so agents with `offline` status are always excluded from assignment. The `Livechat_enabled_when_agent_idle` setting now only affects agents with `away` status. |
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
127 changes: 127 additions & 0 deletions
127
apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-agent-idle-setting.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,127 @@ | ||
| 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 { HomeOmnichannel } from '../page-objects'; | ||
| import { OmnichannelLiveChat } from '../page-objects/omnichannel'; | ||
| import { setSettingValueById } from '../utils'; | ||
| import { createAgent } from '../utils/omnichannel/agents'; | ||
| import { test, expect } from '../utils/test'; | ||
|
|
||
| test.use({ storageState: Users.user1.state }); | ||
|
|
||
| test.describe('OC - Routing to Idle Agents', () => { | ||
| test.skip(!IS_EE, 'Enterprise Edition Only'); | ||
|
|
||
| let poHomeOmnichannel: HomeOmnichannel; | ||
| let poLivechat: OmnichannelLiveChat; | ||
|
|
||
| let livechatPage: Page | undefined; | ||
|
|
||
| let agent: Awaited<ReturnType<typeof createAgent>>; | ||
| let visitor: { name: string; email: string }; | ||
|
|
||
| const routingMethods = ['Auto_Selection', 'Load_Balancing', 'Load_Rotation']; | ||
|
|
||
| test.beforeAll(async ({ api }) => { | ||
| agent = await createAgent(api, 'user1'); | ||
| await expect(agent.response).toBeOK(); | ||
|
|
||
| const settingResponses = await Promise.all([ | ||
| setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 300), | ||
| setSettingValueById(api, 'Omnichannel_enable_department_removal', true), | ||
| ]); | ||
|
|
||
| for (const response of settingResponses) { | ||
| await expect(response).toBeOK(); | ||
| } | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page, browser, api }) => { | ||
| visitor = createFakeVisitor(); | ||
| poHomeOmnichannel = new HomeOmnichannel(page); | ||
| await poHomeOmnichannel.page.goto('/'); | ||
| await poHomeOmnichannel.waitForHome(); | ||
|
|
||
| ({ page: livechatPage } = await createAuxContext(browser, Users.user1, '/livechat', false)); | ||
| poLivechat = new OmnichannelLiveChat(livechatPage, api); | ||
| }); | ||
|
|
||
| test.afterEach(async ({ api }) => { | ||
| if (livechatPage) { | ||
| await livechatPage.context().close(); | ||
| } | ||
|
aleksandernsilva marked this conversation as resolved.
|
||
|
|
||
| await expect(await setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 300)).toBeOK(); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ api }) => { | ||
| const responses = await Promise.all([ | ||
| agent.delete(), | ||
| setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'), | ||
| setSettingValueById(api, 'Livechat_enabled_when_agent_idle', false), | ||
| setSettingValueById(api, 'Omnichannel_enable_department_removal', false), | ||
| ]); | ||
|
|
||
| for (const response of responses) { | ||
| await expect(response).toBeOK(); | ||
| } | ||
| }); | ||
|
|
||
| routingMethods.forEach((routingMethod) => { | ||
| test.describe(`Routing method: ${routingMethod}`, () => { | ||
| test(`should not route to idle agents`, async ({ api }) => { | ||
| await test.step(`Setup routing method to ${routingMethod} and ignore idle agents`, async () => { | ||
| await expect(await setSettingValueById(api, 'Livechat_Routing_Method', routingMethod)).toBeOK(); | ||
| await expect(await setSettingValueById(api, 'Livechat_enabled_when_agent_idle', false)).toBeOK(); | ||
| }); | ||
|
|
||
| await test.step('Visitor tries to initiate a conversation with the away agent', async () => { | ||
| await poLivechat.openAnyLiveChat(); | ||
| await poLivechat.sendMessage(visitor, false); | ||
| await poLivechat.onlineAgentMessage.fill('Hello from visitor'); | ||
|
|
||
| // Force Agent to become away by idle timeout | ||
| await expect(await setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 1)).toBeOK(); | ||
| await poHomeOmnichannel.page.reload(); | ||
| await expect(poHomeOmnichannel.navbar.getUserStatusBadge('away')).toBeVisible(); | ||
|
|
||
| await poLivechat.btnSendMessageToOnlineAgent.click(); | ||
| }); | ||
|
|
||
| await test.step('Verify visitor is not taken by agent', async () => { | ||
| await expect( | ||
| poLivechat.alertMessage('Error starting a new conversation: Sorry, no online agents [no-agent-online]'), | ||
| ).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test(`should route to agents even if they are idle when setting is enabled`, async ({ api }) => { | ||
| await test.step(`Setup routing method to ${routingMethod} and allow idle agents`, async () => { | ||
| await expect(await setSettingValueById(api, 'Livechat_Routing_Method', routingMethod)).toBeOK(); | ||
| await expect(await setSettingValueById(api, 'Livechat_enabled_when_agent_idle', true)).toBeOK(); | ||
| }); | ||
|
|
||
| await test.step('Force agent to become away by idle timeout', async () => { | ||
| await expect(await setSettingValueById(api, 'Accounts_Default_User_Preferences_idleTimeLimit', 1)).toBeOK(); | ||
| await poHomeOmnichannel.page.reload(); | ||
| await expect(poHomeOmnichannel.navbar.getUserStatusBadge('away')).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Visitor initiates chat', async () => { | ||
| await poLivechat.openAnyLiveChatAndSendMessage({ | ||
| liveChatUser: visitor, | ||
| message: 'test message', | ||
| isOffline: false, | ||
| }); | ||
| }); | ||
|
|
||
| await test.step('Verify chat is served to an agent', async () => { | ||
| await expect(poLivechat.headerTitle).toHaveText(agent.data.username); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
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.