feat: update `Livechat_enabled_when_agent_idle` setting to not include `offline` agents in the query
Proposed changes (including videos or screenshots)
The changes made in this PR were done following product team given directives.
- Updated the routing query to always exclude agents whose
statusis offline, regardless of theLivechat_enabled_when_agent_idlesetting. The setting now only affects agents whoseconnectionStatusis away. - Migrated API Tests to E2E: Removed the manual WebSocket helper logic (previously used to force presence updates). The routing tests that required complex presence manipulation were converted to End-to-End (E2E) Playwright tests. This leverages the browser's native WebSocket connection, simulating real agent behavior naturally and eliminating the need for custom socket management.
- E2E Refactoring: Updated existing Playwright tests to properly handle agent states (online/away), ensuring accurate routing scenarios.
- Page Objects: Updated Omnichannel Page Objects to support the newly converted E2E tests, including better UI-based waiters and status validations.
Issue(s)
Steps to test or reproduce
Before testing these cases, you'd need to have a EE license and to create at least two agents and a department with them. Also, you'll need to go to Settings -> Omnichannel -> Queue Management, enable the Waiting queue option and then set Max. number of simultaneous chats to only 1. Please check the task's comment, I've left some recordings there testing this.
Further comments
IMPORTANT NOTE
This PR will introduce a new regression: CORE-1972 - Fix 'Livechat_accept_chats_with_no_agents' omnichannel setting not being respected. This happens because we weren't filtering out offline agents at all, making like the Livechat_accept_chats_with_no_agents (setting intended to assign offline agents to visitors) was always true. So after merging this PR to develop, a new PR will be raised for this 'introduced' regression.
Summary by CodeRabbit
-
Tests
- Enhanced WebSocket handling in omnichannel test infrastructure for improved connection management.
-
Bug Fixes
- Offline agents are now always excluded from visitor assignment in omnichannel routing.
- "Livechat enabled when agent idle" setting now only applies to agents with away status.