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
134 lines
4.6 KiB
TypeScript
134 lines
4.6 KiB
TypeScript
import { faker } from '@faker-js/faker';
|
|
import type { Page } from '@playwright/test';
|
|
|
|
import { createFakeVisitor } from '../../mocks/data';
|
|
import { createAuxContext } from '../fixtures/createAuxContext';
|
|
import { Users } from '../fixtures/userStates';
|
|
import { HomeOmnichannel } from '../page-objects';
|
|
import { OmnichannelLiveChat } from '../page-objects/omnichannel';
|
|
import { test, expect } from '../utils/test';
|
|
|
|
test.describe('OC - Livechat New Chat Triggers - After Registration', () => {
|
|
let triggersName: string;
|
|
let triggerMessage: string;
|
|
let poLiveChat: OmnichannelLiveChat;
|
|
let newVisitor: { email: string; name: string };
|
|
let agent: { page: Page; poHomeOmnichannel: HomeOmnichannel };
|
|
|
|
test.beforeEach(async ({ api, browser, page }) => {
|
|
newVisitor = createFakeVisitor();
|
|
triggersName = faker.string.uuid();
|
|
triggerMessage = 'This is a trigger message after guest registration';
|
|
|
|
await api.post('/livechat/triggers', {
|
|
name: triggersName,
|
|
description: 'Creating a fresh trigger',
|
|
enabled: true,
|
|
runOnce: false,
|
|
conditions: [
|
|
{
|
|
name: 'after-guest-registration',
|
|
value: '',
|
|
},
|
|
],
|
|
actions: [
|
|
{
|
|
name: 'send-message',
|
|
params: {
|
|
name: '',
|
|
msg: triggerMessage,
|
|
sender: 'queue',
|
|
},
|
|
},
|
|
],
|
|
});
|
|
|
|
await Promise.all([
|
|
api.post('/livechat/users/agent', { username: 'user1' }),
|
|
api.post('/livechat/users/manager', { username: 'user1' }),
|
|
]);
|
|
|
|
const { page: agentPage } = await createAuxContext(browser, Users.user1);
|
|
agent = { page: agentPage, poHomeOmnichannel: new HomeOmnichannel(agentPage) };
|
|
|
|
poLiveChat = new OmnichannelLiveChat(page, api);
|
|
});
|
|
|
|
test.afterEach(async ({ api }) => {
|
|
const ids = (await (await api.get('/livechat/triggers')).json()).triggers.map(
|
|
(trigger: { _id: string }) => trigger._id,
|
|
) as unknown as string[];
|
|
|
|
await Promise.all(ids.map((id) => api.delete(`/livechat/triggers/${id}`)));
|
|
|
|
await Promise.all([api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1')]);
|
|
|
|
await agent.page.close();
|
|
});
|
|
|
|
test.afterAll(async ({ api }) => {
|
|
await api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: false });
|
|
});
|
|
|
|
test.describe('OC - Livechat New Chat Triggers - After Registration', async () => {
|
|
test('expect trigger message after registration', async () => {
|
|
await poLiveChat.goto();
|
|
await poLiveChat.sendMessageAndCloseChat(newVisitor);
|
|
|
|
await poLiveChat.startNewChat();
|
|
await expect(poLiveChat.txtChatMessage(triggerMessage)).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('OC - Livechat Triggers - After Registration - Reload', async () => {
|
|
test('expect trigger message after registration', async () => {
|
|
await test.step('expect trigger message after registration to be visible', async () => {
|
|
await poLiveChat.goto();
|
|
await poLiveChat.openAnyLiveChat();
|
|
await poLiveChat.sendMessage(newVisitor, false);
|
|
await expect(poLiveChat.txtChatMessage(triggerMessage)).toBeVisible();
|
|
});
|
|
|
|
await test.step('expect trigger message after registration to be visible after reload', async () => {
|
|
await poLiveChat.page.reload();
|
|
await poLiveChat.openAnyLiveChat();
|
|
await expect(poLiveChat.txtChatMessage(triggerMessage)).toBeVisible();
|
|
});
|
|
|
|
await test.step('expect to close room and reload', async () => {
|
|
await poLiveChat.onlineAgentMessage.type('message_after_trigger');
|
|
await poLiveChat.btnSendMessageToOnlineAgent.click();
|
|
await expect(poLiveChat.txtChatMessage('message_after_trigger')).toBeVisible();
|
|
await poLiveChat.closeChat();
|
|
|
|
await expect(poLiveChat.btnNewChat).toBeVisible();
|
|
await poLiveChat.startNewChat();
|
|
await poLiveChat.page.reload();
|
|
});
|
|
|
|
await test.step('expect trigger message after registration to be visible after reload on new chat', async () => {
|
|
await poLiveChat.openAnyLiveChat();
|
|
await expect(poLiveChat.txtChatMessage(triggerMessage)).toBeVisible();
|
|
});
|
|
});
|
|
});
|
|
|
|
test.describe('OC - Livechat New Chat Triggers - After Registration, clear Local storage', async () => {
|
|
test.beforeAll(async ({ api }) => {
|
|
await api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: true });
|
|
});
|
|
|
|
test('expect trigger message after registration not be visible after local storage clear', async () => {
|
|
await poLiveChat.goto();
|
|
await poLiveChat.sendMessageAndCloseChat(newVisitor);
|
|
|
|
await expect(poLiveChat.btnNewChat).toBeVisible();
|
|
await expect(poLiveChat.txtChatMessage(triggerMessage)).not.toBeVisible();
|
|
|
|
await poLiveChat.startNewChat();
|
|
await poLiveChat.sendMessage(newVisitor, false);
|
|
await expect(poLiveChat.txtChatMessage(triggerMessage)).toBeVisible();
|
|
});
|
|
});
|
|
});
|