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
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
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
This commit is contained in:
30
apps/meteor/tests/e2e/utils/omnichannel/agents.ts
Normal file
30
apps/meteor/tests/e2e/utils/omnichannel/agents.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
export const makeAgentAvailable = async (api: BaseTest['api'], agentId: string) => {
|
||||
await api.post('/users.setStatus', {
|
||||
userId: agentId,
|
||||
message: '',
|
||||
status: 'online',
|
||||
});
|
||||
|
||||
return api.post('/livechat/agent.status', {
|
||||
agentId,
|
||||
status: 'available',
|
||||
});
|
||||
};
|
||||
|
||||
export const createAgent = async (api: BaseTest['api'], username: string) => {
|
||||
const response = await api.post('/livechat/users/agent', { username });
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw new Error(`Failed to create agent [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const { user: agent } = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data: agent,
|
||||
delete: async () => api.delete(`/livechat/users/agent/${agent._id}`),
|
||||
};
|
||||
};
|
||||
36
apps/meteor/tests/e2e/utils/omnichannel/businessHours.ts
Normal file
36
apps/meteor/tests/e2e/utils/omnichannel/businessHours.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
type CreateBusinessHoursParams = {
|
||||
id?: string | null;
|
||||
name?: string;
|
||||
description?: string;
|
||||
departments?: { departmentId: string }[];
|
||||
};
|
||||
|
||||
export const createBusinessHour = async (api: BaseTest['api'], { name, departments = [] }: CreateBusinessHoursParams = {}) => {
|
||||
const departmentIds = departments.join(',');
|
||||
|
||||
return api.post('/livechat/business-hours.save', {
|
||||
name,
|
||||
timezoneName: 'America/Sao_Paulo',
|
||||
daysOpen: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
|
||||
daysTime: [
|
||||
{ day: 'Monday', start: { time: '08:00' }, finish: { time: '18:00' }, open: true },
|
||||
{ day: 'Tuesday', start: { time: '08:00' }, finish: { time: '18:00' }, open: true },
|
||||
{ day: 'Wednesday', start: { time: '08:00' }, finish: { time: '18:00' }, open: true },
|
||||
{ day: 'Thursday', start: { time: '08:00' }, finish: { time: '18:00' }, open: true },
|
||||
{ day: 'Friday', start: { time: '08:00' }, finish: { time: '18:00' }, open: true },
|
||||
],
|
||||
departmentsToApplyBusinessHour: departmentIds,
|
||||
active: true,
|
||||
type: 'custom',
|
||||
timezone: 'America/Sao_Paulo',
|
||||
workHours: [
|
||||
{ day: 'Monday', start: '08:00', finish: '18:00', open: true },
|
||||
{ day: 'Tuesday', start: '08:00', finish: '18:00', open: true },
|
||||
{ day: 'Wednesday', start: '08:00', finish: '18:00', open: true },
|
||||
{ day: 'Thursday', start: '08:00', finish: '18:00', open: true },
|
||||
{ day: 'Friday', start: '08:00', finish: '18:00', open: true },
|
||||
],
|
||||
});
|
||||
};
|
||||
60
apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts
Normal file
60
apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { ILivechatCustomField } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
type CustomField = Omit<ILivechatCustomField, '_id' | '_updatedAt'> & { field: string };
|
||||
|
||||
export const removeCustomField = (api: BaseTest['api'], id: string) => {
|
||||
return api.post('/livechat/custom-fields.delete', {
|
||||
customFieldId: id,
|
||||
});
|
||||
};
|
||||
|
||||
export const setVisitorCustomFieldValue = async (
|
||||
api: BaseTest['api'],
|
||||
params: { token: string; customFieldId: string; value: string; overwrite?: boolean },
|
||||
) => {
|
||||
const response = await api.post('/livechat/custom.field', {
|
||||
token: params.token,
|
||||
key: params.customFieldId,
|
||||
value: params.value,
|
||||
overwrite: params.overwrite ?? true,
|
||||
});
|
||||
if (!response.ok()) {
|
||||
throw new Error(`Failed to set visitor custom field [http status: ${response.status()}]`);
|
||||
}
|
||||
const { field } = await response.json();
|
||||
return { response, field };
|
||||
};
|
||||
|
||||
export const createCustomField = async (api: BaseTest['api'], overwrites: Partial<CustomField>) => {
|
||||
const response = await api.post('/livechat/custom-fields.save', {
|
||||
customFieldId: null,
|
||||
customFieldData: {
|
||||
field: overwrites.field,
|
||||
label: overwrites.label || overwrites.field,
|
||||
visibility: 'visible',
|
||||
scope: 'visitor',
|
||||
searchable: false,
|
||||
regexp: '',
|
||||
type: 'input',
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
options: '',
|
||||
public: false,
|
||||
...overwrites,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok()) {
|
||||
throw new Error(`Failed to create custom field [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const { customField } = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
customField,
|
||||
delete: () => removeCustomField(api, customField._id),
|
||||
};
|
||||
};
|
||||
93
apps/meteor/tests/e2e/utils/omnichannel/departments.ts
Normal file
93
apps/meteor/tests/e2e/utils/omnichannel/departments.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import type { ILivechatDepartment } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
type CreateDepartmentParams = {
|
||||
name?: string;
|
||||
enabled?: boolean;
|
||||
description?: string;
|
||||
showOnRegistration?: boolean;
|
||||
showOnOfflineForm?: boolean;
|
||||
requestTagBeforeClosingChat?: boolean;
|
||||
email?: string;
|
||||
chatClosingTags?: string[];
|
||||
offlineMessageChannelName?: string;
|
||||
abandonedRoomsCloseCustomMessage?: string;
|
||||
waitingQueueMessage?: string;
|
||||
departmentsAllowedToForward?: string[];
|
||||
fallbackForwardDepartment?: string;
|
||||
maxNumberSimultaneousChat?: number;
|
||||
allowReceiveForwardOffline?: boolean;
|
||||
};
|
||||
|
||||
export const createDepartment = async (
|
||||
api: BaseTest['api'],
|
||||
{
|
||||
name = '',
|
||||
enabled = true,
|
||||
description = '',
|
||||
showOnRegistration = false,
|
||||
showOnOfflineForm = false,
|
||||
requestTagBeforeClosingChat = false,
|
||||
email = '',
|
||||
chatClosingTags = [],
|
||||
offlineMessageChannelName = '',
|
||||
abandonedRoomsCloseCustomMessage = '',
|
||||
waitingQueueMessage = '',
|
||||
departmentsAllowedToForward = [],
|
||||
fallbackForwardDepartment = '',
|
||||
maxNumberSimultaneousChat,
|
||||
allowReceiveForwardOffline,
|
||||
}: CreateDepartmentParams = {},
|
||||
) => {
|
||||
const response = await api.post('/livechat/department', {
|
||||
department: {
|
||||
name: name || faker.string.uuid(),
|
||||
enabled,
|
||||
description,
|
||||
showOnRegistration,
|
||||
showOnOfflineForm,
|
||||
requestTagBeforeClosingChat,
|
||||
email: email || faker.internet.email(),
|
||||
chatClosingTags,
|
||||
offlineMessageChannelName,
|
||||
abandonedRoomsCloseCustomMessage,
|
||||
waitingQueueMessage,
|
||||
departmentsAllowedToForward,
|
||||
fallbackForwardDepartment,
|
||||
maxNumberSimultaneousChat,
|
||||
allowReceiveForwardOffline,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw Error(`Unable to create department [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const { department } = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data: department,
|
||||
delete: async () => api.delete(`/livechat/department/${department._id}`),
|
||||
};
|
||||
};
|
||||
|
||||
export const addAgentToDepartment = async (
|
||||
api: BaseTest['api'],
|
||||
{ department, agentId, username }: { department: ILivechatDepartment; agentId: string; username?: string },
|
||||
) =>
|
||||
api.post(`/livechat/department/${department._id}/agents`, {
|
||||
remove: [],
|
||||
upsert: [
|
||||
{
|
||||
agentId,
|
||||
username: username || agentId,
|
||||
count: 0,
|
||||
order: 0,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export const deleteDepartment = async (api: BaseTest['api'], { id }: { id: string }) => api.delete(`/livechat/department/${id}`);
|
||||
19
apps/meteor/tests/e2e/utils/omnichannel/managers.ts
Normal file
19
apps/meteor/tests/e2e/utils/omnichannel/managers.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
export const createManager = async (api: BaseTest['api'], username: string) => {
|
||||
const response = await api.post('/livechat/users/manager', {
|
||||
username,
|
||||
});
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw Error(`Unable to create manager [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const { user: manager } = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data: manager,
|
||||
delete: async () => api.delete(`/livechat/users/manager/${manager._id}`),
|
||||
};
|
||||
};
|
||||
19
apps/meteor/tests/e2e/utils/omnichannel/monitors.ts
Normal file
19
apps/meteor/tests/e2e/utils/omnichannel/monitors.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
const deleteMonitor = async (api: BaseTest['api'], username: string) => api.post('/livechat/monitors.delete', { username });
|
||||
|
||||
export const createMonitor = async (api: BaseTest['api'], username: string) => {
|
||||
const response = await api.post('/livechat/monitors.create', { username });
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw new Error(`Failed to create monitor [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data,
|
||||
delete: async () => deleteMonitor(api, data.username),
|
||||
};
|
||||
};
|
||||
16
apps/meteor/tests/e2e/utils/omnichannel/priority.ts
Normal file
16
apps/meteor/tests/e2e/utils/omnichannel/priority.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { ILivechatPriority } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { BaseTest } from '../test';
|
||||
import { expect } from '../test';
|
||||
|
||||
export const getPriorityByi18nLabel = async (api: BaseTest['api'], i18n: string): Promise<ILivechatPriority> => {
|
||||
const allPriorityResp = await api.get('/livechat/priorities');
|
||||
expect(allPriorityResp.status()).toBe(200);
|
||||
const { priorities } = (await allPriorityResp.json()) as { priorities: ILivechatPriority[] };
|
||||
const priority = priorities.find((p) => p.i18n === i18n);
|
||||
if (!priority) {
|
||||
throw new Error('Could not find priority with i18n "High"');
|
||||
}
|
||||
|
||||
return priority;
|
||||
};
|
||||
123
apps/meteor/tests/e2e/utils/omnichannel/rooms.ts
Normal file
123
apps/meteor/tests/e2e/utils/omnichannel/rooms.ts
Normal file
@@ -0,0 +1,123 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
import { createFakeVisitor } from '../../../mocks/data';
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
type UpdateRoomParams = { roomId: string; visitorId: string; tags: string[] };
|
||||
|
||||
type CloseRoomParams = { roomId: string; visitorToken: string };
|
||||
|
||||
type CreateRoomParams = { tags?: string[]; visitorToken: string; agentId?: string };
|
||||
|
||||
type CreateVisitorParams = { token: string; departmentId?: string; name?: string; email?: string };
|
||||
|
||||
type CreateConversationParams = { visitorName?: string; visitorToken?: string; agentId?: string; departmentId?: string };
|
||||
|
||||
export const updateRoom = async (api: BaseTest['api'], { roomId, visitorId, tags }: UpdateRoomParams) => {
|
||||
if (!roomId) {
|
||||
throw Error('Unable to update room info, missing room id');
|
||||
}
|
||||
|
||||
if (!visitorId) {
|
||||
throw Error('Unable to update room info, missing visitor id');
|
||||
}
|
||||
|
||||
const response = await api.post('/livechat/room.saveInfo', {
|
||||
guestData: { _id: visitorId },
|
||||
roomData: { _id: roomId, tags },
|
||||
});
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw Error(`Unable to update room info [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
export const closeRoom = async (api: BaseTest['api'], { roomId, visitorToken }: CloseRoomParams) =>
|
||||
api.post('/livechat/room.close', { rid: roomId, token: visitorToken });
|
||||
|
||||
export const createRoom = async (api: BaseTest['api'], { visitorToken, agentId }: CreateRoomParams) => {
|
||||
const response = await api.get('/livechat/room', {
|
||||
token: visitorToken,
|
||||
agentId,
|
||||
});
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw Error(`Unable to create room [http status: ${response.status()}]`, { cause: await response.json() });
|
||||
}
|
||||
|
||||
const { room } = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data: room,
|
||||
async delete() {
|
||||
await closeRoom(api, { roomId: room._id, visitorToken });
|
||||
return api.post('/livechat/rooms.delete', { roomId: room._id });
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const createVisitor = async (api: BaseTest['api'], { name, token, departmentId }: CreateVisitorParams) => {
|
||||
const fakeVisitor = createFakeVisitor();
|
||||
const response = await api.post('/livechat/visitor', {
|
||||
visitor: {
|
||||
name: name || fakeVisitor.name,
|
||||
email: fakeVisitor.email,
|
||||
token,
|
||||
...(departmentId && { department: departmentId }),
|
||||
},
|
||||
});
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw Error(`Unable to create visitor [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const { visitor } = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data: visitor,
|
||||
delete: async () => api.delete(`/livechat/visitor/${token}`),
|
||||
};
|
||||
};
|
||||
|
||||
export const sendMessageToRoom = async (
|
||||
api: BaseTest['api'],
|
||||
{ visitorToken, roomId, message }: { visitorToken: string; roomId: string; message?: string },
|
||||
) => {
|
||||
const response = await api.post(`/livechat/message`, {
|
||||
token: visitorToken,
|
||||
rid: roomId,
|
||||
msg: message || faker.lorem.sentence(),
|
||||
});
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw Error(`Unable to send message to room [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
export const createConversation = async (
|
||||
api: BaseTest['api'],
|
||||
{ visitorName, visitorToken, agentId, departmentId }: CreateConversationParams = {},
|
||||
) => {
|
||||
const token = visitorToken || faker.string.uuid();
|
||||
|
||||
const { data: visitor, delete: deleteVisitor } = await createVisitor(api, { token, name: visitorName, departmentId });
|
||||
const { data: room, delete: deleteRoom } = await createRoom(api, { visitorToken: token, agentId });
|
||||
await sendMessageToRoom(api, { visitorToken: token, roomId: room._id });
|
||||
|
||||
return {
|
||||
data: {
|
||||
room,
|
||||
visitor,
|
||||
},
|
||||
delete: async () => {
|
||||
await deleteRoom();
|
||||
await deleteVisitor();
|
||||
},
|
||||
};
|
||||
};
|
||||
22
apps/meteor/tests/e2e/utils/omnichannel/sla.ts
Normal file
22
apps/meteor/tests/e2e/utils/omnichannel/sla.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { type IOmnichannelServiceLevelAgreements, DEFAULT_SLA_CONFIG } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { BaseTest } from '../test';
|
||||
import { expect } from '../test';
|
||||
|
||||
export const generateRandomSLAData = (): Omit<IOmnichannelServiceLevelAgreements, '_updatedAt' | '_id'> => ({
|
||||
name: `${faker.person.firstName()}-${faker.database.mongodbObjectId()}`,
|
||||
description: faker.lorem.sentence(),
|
||||
dueTimeInMinutes: faker.number.int({ min: 10, max: DEFAULT_SLA_CONFIG.ESTIMATED_WAITING_TIME_QUEUE }),
|
||||
});
|
||||
|
||||
export const createSLA = async (
|
||||
api: BaseTest['api'],
|
||||
slaData?: Omit<IOmnichannelServiceLevelAgreements, '_updatedAt' | '_id'>,
|
||||
): Promise<Omit<IOmnichannelServiceLevelAgreements, '_updated'>> => {
|
||||
const response = await api.post('/livechat/sla', slaData ?? generateRandomSLAData());
|
||||
expect(response.status()).toBe(200);
|
||||
|
||||
const { sla } = (await response.json()) as { sla: Omit<IOmnichannelServiceLevelAgreements, '_updated'> };
|
||||
return sla;
|
||||
};
|
||||
36
apps/meteor/tests/e2e/utils/omnichannel/tags.ts
Normal file
36
apps/meteor/tests/e2e/utils/omnichannel/tags.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import type { ILivechatTag } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
type CreateTagParams = {
|
||||
id?: string | null;
|
||||
name?: string;
|
||||
description?: string;
|
||||
departments?: string[];
|
||||
};
|
||||
|
||||
const removeTag = async (api: BaseTest['api'], id: string) => api.post('/livechat/tags.delete', { id });
|
||||
|
||||
export const createTag = async (api: BaseTest['api'], { id = null, name, description, departments = [] }: CreateTagParams = {}) => {
|
||||
const response = await api.post('/livechat/tags.save', {
|
||||
_id: id,
|
||||
tagData: {
|
||||
name: name ?? faker.string.alpha({ length: 8 }),
|
||||
description: description ?? faker.string.alpha({ length: 16 }),
|
||||
},
|
||||
...(departments.length > 0 && { tagDepartments: departments }),
|
||||
});
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw new Error(`Failed to create tag [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const data: ILivechatTag = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data,
|
||||
delete: async () => removeTag(api, data._id),
|
||||
};
|
||||
};
|
||||
56
apps/meteor/tests/e2e/utils/omnichannel/units.ts
Normal file
56
apps/meteor/tests/e2e/utils/omnichannel/units.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
import type { BaseTest } from '../test';
|
||||
|
||||
type CreateUnitParams = {
|
||||
id?: string | null;
|
||||
name?: string;
|
||||
visibility?: 'public' | 'private';
|
||||
monitors?: { monitorId: string; username: string }[];
|
||||
departments?: { departmentId: string }[];
|
||||
};
|
||||
|
||||
const removeUnit = async (api: BaseTest['api'], id: string) => api.delete(`/livechat/units/${id}`);
|
||||
|
||||
export const createOrUpdateUnit = async (
|
||||
api: BaseTest['api'],
|
||||
{ id = null, name, visibility, monitors, departments }: CreateUnitParams = {},
|
||||
) => {
|
||||
const unitPayload = {
|
||||
unitData: {
|
||||
name: name ?? faker.string.uuid(),
|
||||
visibility: visibility ?? 'public',
|
||||
},
|
||||
unitMonitors: monitors,
|
||||
unitDepartments: departments,
|
||||
};
|
||||
|
||||
const response = id ? await api.post(`/livechat/units/${id}`, unitPayload) : await api.post('/livechat/units', unitPayload);
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw new Error(`Failed to create or update unit [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data,
|
||||
delete: async () => removeUnit(api, data?._id),
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchUnitMonitors = async (api: BaseTest['api'], unitId: string) => {
|
||||
const response = await api.get(`/livechat/units/${unitId}/monitors`);
|
||||
|
||||
if (response.status() !== 200) {
|
||||
throw new Error(`Failed to fetch unit monitors [http status: ${response.status()}]`);
|
||||
}
|
||||
|
||||
const { monitors } = await response.json();
|
||||
|
||||
return {
|
||||
response,
|
||||
data: monitors,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user