Files
upstream-rocketchat/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts
upstream-mirror 30810eecd7
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
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

230 lines
9.2 KiB
TypeScript

import { faker } from '@faker-js/faker';
import type { Page } from '@playwright/test';
import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeOmnichannel } from '../page-objects';
import { OmnichannelAgents, OmnichannelManager, OmnichannelMonitors } from '../page-objects/omnichannel';
import { setSettingValueById } from '../utils';
import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents';
import { createDepartment } from '../utils/omnichannel/departments';
import { createManager } from '../utils/omnichannel/managers';
import { createConversation } from '../utils/omnichannel/rooms';
import { test, expect } from '../utils/test';
const MANAGER = 'user3';
const ROOM_A = faker.person.fullName();
const ROOM_B = faker.person.fullName();
const ROOM_C = faker.person.fullName();
test.use({ storageState: Users.user3.state });
test.describe('OC - Manager Role', () => {
test.skip(!IS_EE, 'Enterprise Edition Only');
let departments: Awaited<ReturnType<typeof createDepartment>>[];
let conversations: Awaited<ReturnType<typeof createConversation>>[];
let agents: Awaited<ReturnType<typeof createAgent>>[];
let poOmnichannel: HomeOmnichannel;
let manager: Awaited<ReturnType<typeof createManager>>;
// Allow manual on hold
test.beforeAll(async ({ api }) => {
const responses = await Promise.all([
api.post('/settings/Livechat_allow_manual_on_hold', { value: true }),
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: false }),
]);
responses.forEach((res) => expect(res.status()).toBe(200));
});
// Create agents
test.beforeAll(async ({ api }) => {
agents = await Promise.all([createAgent(api, 'user1'), createAgent(api, 'user2'), createAgent(api, MANAGER)]);
const agentsStatuses = await Promise.all(agents.slice(0, 2).map(({ data: agent }) => makeAgentAvailable(api, agent._id)));
agentsStatuses.forEach((res) => expect(res.status()).toBe(200));
});
// Create departments
test.beforeAll(async ({ api }) => {
departments = await Promise.all([createDepartment(api), createDepartment(api)]);
});
// Create manager
test.beforeAll(async ({ api }) => {
manager = await createManager(api, MANAGER);
});
// Create conversations
test.beforeAll(async ({ api }) => {
const [departmentA, departmentB] = departments.map(({ data }) => data);
conversations = await Promise.all([
createConversation(api, {
visitorName: ROOM_A,
visitorToken: 'roomA',
agentId: `user1`,
departmentId: departmentA._id,
}),
createConversation(api, {
visitorName: ROOM_B,
visitorToken: 'roomB',
agentId: `user2`,
departmentId: departmentB._id,
}),
createConversation(api, {
visitorName: ROOM_C,
visitorToken: 'roomC',
agentId: `user2`,
}),
]);
await setSettingValueById(api, 'Omnichannel_enable_department_removal', true);
});
// Delete all created data
test.afterAll(async ({ api }) => {
await Promise.all([
...agents.map((agent) => agent.delete()),
...departments.map((department) => department.delete()),
...conversations.map((conversation) => conversation.delete()),
manager.delete(),
// Reset setting
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }),
api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }),
]);
await setSettingValueById(api, 'Omnichannel_enable_department_removal', false);
});
test.beforeEach(async ({ page }: { page: Page }) => {
poOmnichannel = new HomeOmnichannel(page);
await poOmnichannel.chats.goto();
});
test('OC - Manager Role - Basic permissions', async () => {
await test.step('expect agent to not have access to omnichannel administration', async () => {
await expect(poOmnichannel.omnisidenav.getSidebarLinkByName('Contact Center')).toBeVisible();
await expect(poOmnichannel.omnisidenav.getSidebarLinkByName('Analytics')).toBeVisible();
await expect(poOmnichannel.omnisidenav.getSidebarLinkByName('Real-time Monitoring')).toBeVisible();
await expect(poOmnichannel.omnisidenav.getSidebarLinkByName('Agents')).toBeVisible();
await expect(poOmnichannel.omnisidenav.getSidebarLinkByName('Departments')).toBeVisible();
await expect(poOmnichannel.omnisidenav.getSidebarLinkByName('Business Hours')).toBeVisible();
await expect(poOmnichannel.omnisidenav.getSidebarLinkByName('Reports')).toBeVisible();
await expect(poOmnichannel.omnisidenav.getSidebarLinkByName('Canned Responses')).toBeVisible();
});
});
test('OC - Manager Role - Contact Center', async () => {
await test.step('expect to be able to view all chats', async () => {
await expect(poOmnichannel.chats.table.findRowByName(ROOM_A)).toBeVisible();
await expect(poOmnichannel.chats.table.findRowByName(ROOM_B)).toBeVisible();
await expect(poOmnichannel.chats.table.findRowByName(ROOM_C)).toBeVisible();
});
await test.step('expect to be able to join chats', async () => {
await poOmnichannel.chats.openChat(ROOM_A);
await expect(poOmnichannel.composer.btnJoinRoom).toBeVisible();
await expect(poOmnichannel.composer.inputMessage).not.toBeVisible();
await poOmnichannel.composer.btnJoinRoom.click();
await expect(poOmnichannel.content.lastSystemMessageBody).toHaveText('joined the channel');
await expect(poOmnichannel.composer.btnJoinRoom).not.toBeVisible();
await expect(poOmnichannel.composer.inputMessage).toBeVisible();
});
await test.step('expect to be able to put a conversation from another agent on hold', async () => {
await poOmnichannel.quickActionsRoomToolbar.placeChatOnHold();
await expect(poOmnichannel.content.lastSystemMessageBody).toHaveText(
`Chat On Hold: The chat was manually placed On Hold by ${MANAGER}`,
);
await expect(poOmnichannel.composer.inputMessage).not.toBeVisible();
await expect(poOmnichannel.content.btnResume).toBeVisible();
});
await test.step('expect to be able resume a conversation from another agent on hold', async () => {
await poOmnichannel.content.btnResume.click();
await expect(poOmnichannel.content.btnResume).not.toBeVisible();
await expect(poOmnichannel.composer.inputMessage).toBeVisible();
await expect(poOmnichannel.quickActionsRoomToolbar.btnOnHold).toBeVisible();
});
await test.step('expect to be able to close a conversation from another agent', async () => {
await poOmnichannel.quickActionsRoomToolbar.closeChat();
await poOmnichannel.chats.goto();
});
await test.step('expect to be able to remove closed rooms', async () => {
await poOmnichannel.chats.removeChatByName(ROOM_A);
await expect(poOmnichannel.chats.table.findRowByName(ROOM_A)).not.toBeVisible();
});
});
test('OC - Manager Role - Add/remove agents', async ({ page }) => {
const poOmnichannelAgents = new OmnichannelAgents(page);
await poOmnichannelAgents.goto();
await test.step('expect add "user1" as agent', async () => {
await poOmnichannelAgents.selectUsername('user1');
await poOmnichannelAgents.btnAddAgent.click();
await poOmnichannelAgents.inputSearch.fill('user1');
await expect(poOmnichannelAgents.table.findRowByName('user1')).toBeVisible();
});
await test.step('expect remove "user1" as agent', async () => {
await poOmnichannelAgents.inputSearch.fill('user1');
await poOmnichannelAgents.deleteAgent('user1');
await poOmnichannelAgents.inputSearch.fill('');
await poOmnichannelAgents.inputSearch.fill('user1');
await expect(poOmnichannelAgents.table.findRowByName('user1')).toBeHidden();
});
});
test('OC - Manager Role - Add/remove managers', async ({ page }) => {
const poOmnichannelManagers = new OmnichannelManager(page);
await poOmnichannelManagers.goto();
await test.step('expect add "user1" as manager', async () => {
await poOmnichannelManagers.selectUsername('user1');
await poOmnichannelManagers.btnAddManager.click();
await expect(poOmnichannelManagers.table.findRowByName('user1')).toBeVisible();
});
await test.step('expect search for manager', async () => {
await poOmnichannelManagers.search('user1');
await expect(poOmnichannelManagers.table.findRowByName('user1')).toBeVisible();
await poOmnichannelManagers.search('NonExistingUser');
await expect(poOmnichannelManagers.table.findRowByName('user1')).toBeHidden();
await poOmnichannelManagers.clearSearch();
});
await test.step('expect remove "user1" as manager', async () => {
await poOmnichannelManagers.search('user1');
await poOmnichannelManagers.removeManager('user1');
await expect(poOmnichannelManagers.table.findRowByName('user1')).toBeHidden();
});
});
test('OC - Manager Role - Add/remove monitors', async ({ page }) => {
const poOmnichannelMonitors = new OmnichannelMonitors(page);
await poOmnichannelMonitors.goto();
await test.step('expect to add agent as monitor', async () => {
await expect(poOmnichannelMonitors.table.findRowByName('user1')).not.toBeVisible();
await poOmnichannelMonitors.addMonitor('user1');
await expect(poOmnichannelMonitors.table.findRowByName('user1')).toBeVisible();
});
await test.step('expect to remove agent from monitor', async () => {
await poOmnichannelMonitors.removeMonitor('user1');
await expect(poOmnichannelMonitors.table.findRowByName('user1')).not.toBeVisible();
});
});
});