The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/tests/data/livechat/units.ts

48 lines
1.7 KiB

import { faker } from "@faker-js/faker";
import type { IOmnichannelBusinessUnit } from "@rocket.chat/core-typings";
import { methodCall, credentials, request } from "../api-data";
import type { DummyResponse } from "./utils";
export const createMonitor = async (username: string): Promise<{ _id: string; username: string }> => {
return new Promise((resolve, reject) => {
request
.post(methodCall(`livechat:addMonitor`))
.set(credentials)
.send({
message: JSON.stringify({
method: 'livechat:addMonitor',
params: [username],
id: '101',
msg: 'method',
}),
})
.end((err: Error, res: DummyResponse<string, 'wrapped'>) => {
if (err) {
return reject(err);
}
resolve(JSON.parse(res.body.message).result);
});
});
};
export const createUnit = async (monitorId: string, username: string, departmentIds: string[]): Promise<IOmnichannelBusinessUnit> => {
return new Promise((resolve, reject) => {
request
.post(methodCall(`livechat:saveUnit`))
.set(credentials)
.send({
message: JSON.stringify({
method: 'livechat:saveUnit',
params: [null, { name: faker.person.firstName(), visibility: faker.helpers.arrayElement(['public', 'private']) }, [{ monitorId, username }], departmentIds.map((departmentId) => ({ departmentId }))],
id: '101',
msg: 'method',
}),
})
.end((err: Error, res: DummyResponse<string, 'wrapped'>) => {
if (err) {
return reject(err);
}
resolve(JSON.parse(res.body.message).result);
});
});
};