snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Code scanning - action / CodeQL-Build (push) Failing after 1s
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-16 01:21:02 +05:00
commit 30810eecd7
10161 changed files with 987110 additions and 0 deletions

View File

@@ -0,0 +1,153 @@
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 { createAgent } from '../utils/omnichannel/agents';
import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments';
import { test, expect } from '../utils/test';
test.use({ storageState: Users.user1.state });
test.describe('OC - Livechat - Department Flow', () => {
// Needs Departments to test this, so needs an EE license for multiple deps
test.skip(!IS_EE, 'Enterprise Only');
let poLiveChat: OmnichannelLiveChat;
let poHomeOmnichannelAgent1: HomeOmnichannel;
let poHomeOmnichannelAgent2: HomeOmnichannel;
let departments: Awaited<ReturnType<typeof createDepartment>>[];
let departmentA: Awaited<ReturnType<typeof createDepartment>>['data'];
let departmentB: Awaited<ReturnType<typeof createDepartment>>['data'];
let agents: Awaited<ReturnType<typeof createDepartment>>[];
let agent1: Awaited<ReturnType<typeof createAgent>>['data'];
let agent2: Awaited<ReturnType<typeof createAgent>>['data'];
test.beforeAll(async ({ api }) => {
// Assign agents & departments
agents = await Promise.all([createAgent(api, 'user1'), createAgent(api, 'user2')]);
[agent1, agent2] = agents.map(({ data }) => data);
departments = await Promise.all([
createDepartment(api, { showOnRegistration: true }),
createDepartment(api, { showOnRegistration: true }),
]);
[departmentA, departmentB] = departments.map(({ data }) => data);
await addAgentToDepartment(api, { department: departmentA, agentId: agent1._id });
await addAgentToDepartment(api, { department: departmentB, agentId: agent2._id });
});
test.beforeEach(async ({ page, api, browser }) => {
// Create Pages
const { page: agent1Page } = await createAuxContext(browser, Users.user1, '/', true);
poHomeOmnichannelAgent1 = new HomeOmnichannel(agent1Page);
const { page: agent2Page } = await createAuxContext(browser, Users.user2, '/', true);
poHomeOmnichannelAgent2 = new HomeOmnichannel(agent2Page);
poLiveChat = new OmnichannelLiveChat(page, api);
await poLiveChat.goto();
});
test.afterEach(async ({ page }) => {
await poHomeOmnichannelAgent1.page.close();
await poHomeOmnichannelAgent2.page.close();
await page.close();
});
test.afterAll(async ({ api }) => {
await expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: true })).status()).toBe(200);
await Promise.all([...agents.map((agent) => agent.delete())]);
await Promise.all([...departments.map((department) => department.delete())]);
await expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: false })).status()).toBe(200);
});
test('OC - Livechat - Chat with Department', async () => {
const guest = createFakeVisitor();
await test.step('expect start Chat with department', async () => {
await poLiveChat.openAnyLiveChat();
await poLiveChat.sendMessage(guest, false, departmentA.name);
await expect(poLiveChat.onlineAgentMessage).toBeVisible();
await poLiveChat.onlineAgentMessage.fill('this_a_test_message_from_user');
await poLiveChat.btnSendMessageToOnlineAgent.click();
await expect(poLiveChat.page.locator('div >> text="this_a_test_message_from_user"')).toBeVisible();
});
await test.step('expect message to be received by department', async () => {
await poHomeOmnichannelAgent1.navbar.openChat(guest.name);
await expect(poHomeOmnichannelAgent1.content.lastUserMessage).toBeVisible();
await expect(poHomeOmnichannelAgent1.content.lastUserMessage).toContainText('this_a_test_message_from_user');
});
await test.step('expect message to be sent by department', async () => {
await poHomeOmnichannelAgent1.content.sendMessage('this_a_test_message_from_agent');
await expect(poLiveChat.page.locator('div >> text="this_a_test_message_from_agent"')).toBeVisible();
});
});
test('OC - Livechat - Change Department', async () => {
const guest = createFakeVisitor();
await test.step('expect start Chat with department', async () => {
await poLiveChat.openAnyLiveChat();
await poLiveChat.sendMessage(guest, false, departmentA.name);
await expect(poLiveChat.onlineAgentMessage).toBeVisible();
await poLiveChat.onlineAgentMessage.fill('this_a_test_message_from_user');
await poLiveChat.btnSendMessageToOnlineAgent.click();
await expect(poLiveChat.page.locator('div >> text="this_a_test_message_from_user"')).toBeVisible();
});
await test.step('expect message to be received by department 1', async () => {
await poHomeOmnichannelAgent1.navbar.openChat(guest.name);
await expect(poHomeOmnichannelAgent1.content.lastUserMessage).toBeVisible();
await expect(poHomeOmnichannelAgent1.content.lastUserMessage).toContainText('this_a_test_message_from_user');
});
await test.step('expect message to be sent by department 1', async () => {
await poHomeOmnichannelAgent1.content.sendMessage('this_a_test_message_from_agent_department_1');
await expect(poLiveChat.page.locator('div >> text="this_a_test_message_from_agent_department_1"')).toBeVisible();
await poHomeOmnichannelAgent1.page.close();
});
await test.step('expect to change department', async () => {
await poLiveChat.btnOptions.click();
await poLiveChat.btnChangeDepartment.click();
await expect(poLiveChat.selectDepartment).toBeVisible();
await poLiveChat.selectDepartment.selectOption({ label: departmentB.name });
await expect(poLiveChat.btnSendMessage('Start chat')).toBeEnabled();
await poLiveChat.btnSendMessage('Start chat').click();
await expect(poLiveChat.livechatModal).toBeVisible();
await expect(poLiveChat.livechatModalText('Are you sure you want to switch the department?')).toBeVisible();
await poLiveChat.btnYes.click();
await expect(poLiveChat.livechatModal).toBeVisible();
await expect(poLiveChat.livechatModalText('Department switched')).toBeVisible();
await poLiveChat.btnOk.click();
// Expect keep chat history
await expect(poLiveChat.page.locator('div >> text="this_a_test_message_from_user"')).toBeVisible();
// Expect user to have changed
await expect(await poLiveChat.headerTitle.textContent()).toEqual(agent2.username);
await poLiveChat.onlineAgentMessage.fill('this_a_test_message_from_user_to_department_2');
await poLiveChat.btnSendMessageToOnlineAgent.click();
await expect(poLiveChat.page.locator('div >> text="this_a_test_message_from_user_to_department_2"')).toBeVisible();
});
await test.step('expect message to be received by department', async () => {
await poHomeOmnichannelAgent2.navbar.openChat(guest.name);
await expect(poHomeOmnichannelAgent2.content.lastUserMessage).toBeVisible();
await expect(poHomeOmnichannelAgent2.content.lastUserMessage).toContainText('this_a_test_message_from_user_to_department_2');
});
await test.step('expect message to be sent by department', async () => {
await poHomeOmnichannelAgent2.content.sendMessage('this_a_test_message_from_agent_department_2');
await expect(poLiveChat.page.locator('div >> text="this_a_test_message_from_agent_department_2"')).toBeVisible();
});
});
});