Files
upstream-rocketchat/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-read-receipts.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

89 lines
3.4 KiB
TypeScript

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';
const visitor = createFakeVisitor();
test.use({ storageState: Users.user1.state });
test.describe('OC - Livechat - Read Receipts', () => {
let poLiveChat: OmnichannelLiveChat;
let poHomeOmnichannel: HomeOmnichannel;
let livechatPage: Page;
let agentPage: Page;
let agent: Awaited<ReturnType<typeof createAgent>>;
test.skip(!IS_EE, 'Enterprise Only');
test.beforeAll(async ({ api, browser }) => {
agent = await createAgent(api, 'user1');
await Promise.all([
setSettingValueById(api, 'Message_Read_Receipt_Enabled', true),
setSettingValueById(api, 'Message_Read_Receipt_Store_Users', true),
setSettingValueById(api, 'UI_Use_Real_Name', true),
]);
({ page: agentPage } = await createAuxContext(browser, Users.user1, '/', true));
poHomeOmnichannel = new HomeOmnichannel(agentPage);
({ page: livechatPage } = await createAuxContext(browser, Users.user1, '/livechat', false));
poLiveChat = new OmnichannelLiveChat(livechatPage, api);
});
test.afterAll(({ api }) =>
Promise.all([
setSettingValueById(api, 'Message_Read_Receipt_Enabled', false),
setSettingValueById(api, 'Message_Read_Receipt_Store_Users', false),
setSettingValueById(api, 'UI_Use_Real_Name', false),
agent.delete(),
livechatPage.close(),
agentPage.close(),
]),
);
test('OC - Livechat - Read receipts should display visitor name', async () => {
const testMessage = 'test_message_for_read_receipts';
await test.step('send message from livechat widget', async () => {
await poLiveChat.page.reload();
await poLiveChat.openAnyLiveChat();
await poLiveChat.sendMessage(visitor, false);
await poLiveChat.onlineAgentMessage.fill(testMessage);
await poLiveChat.btnSendMessageToOnlineAgent.click();
await expect(poLiveChat.txtChatMessage(testMessage)).toBeVisible();
});
await test.step('agent reads the message', async () => {
const markedAsRead = agentPage.waitForResponse(
(res) => /api\/v1\/subscriptions\.read(?:\/|\?|$)/.test(res.url()) && res.request().method() === 'POST',
);
await poHomeOmnichannel.navbar.openChat(visitor.name);
await expect(poHomeOmnichannel.content.lastUserMessage).toBeVisible();
await expect(poHomeOmnichannel.content.lastUserMessage).toContainText(testMessage);
await markedAsRead;
await expect(poHomeOmnichannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible();
});
await test.step('read receipts show both agent and visitor names', async () => {
await poHomeOmnichannel.content.openLastMessageMenu();
await agentPage.locator('role=menuitem[name="Read receipts"]').click();
const dialog = agentPage.getByRole('dialog', { name: 'Read by' });
const listItems = dialog.getByRole('listitem');
await expect(listItems).toHaveCount(2);
await expect(listItems.filter({ hasText: visitor.name })).toHaveCount(1);
await expect(listItems.filter({ hasText: 'user1' })).toHaveCount(1);
await dialog.getByLabel('Close').click();
});
});
});