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:
821
apps/meteor/tests/end-to-end/api/livechat/17-dashboards-ee.ts
Normal file
821
apps/meteor/tests/end-to-end/api/livechat/17-dashboards-ee.ts
Normal file
@@ -0,0 +1,821 @@
|
||||
import type { ILivechatDepartment, ILivechatVisitor } from '@rocket.chat/core-typings';
|
||||
import { expect } from 'chai';
|
||||
import { before, describe, it, after } from 'mocha';
|
||||
|
||||
import { getCredentials, api, request, credentials } from '../../../data/api-data';
|
||||
import { createDepartment, deleteDepartment } from '../../../data/livechat/department';
|
||||
import {
|
||||
createVisitor,
|
||||
createLivechatRoom,
|
||||
takeInquiry,
|
||||
closeOmnichannelRoom,
|
||||
makeAgentUnavailable,
|
||||
makeAgentAvailable,
|
||||
createAgent,
|
||||
sendAgentMessage,
|
||||
sendMessage,
|
||||
fetchInquiry,
|
||||
deleteVisitor,
|
||||
} from '../../../data/livechat/rooms';
|
||||
import { updateEESetting, updatePermission, updateSetting } from '../../../data/permissions.helper';
|
||||
import { pagination } from '../../../data/utils';
|
||||
import { IS_EE } from '../../../e2e/config/constants';
|
||||
|
||||
(IS_EE ? describe : describe.skip)('[EE] LIVECHAT - dashboards', () => {
|
||||
before((done) => getCredentials(done));
|
||||
|
||||
before(async () => {
|
||||
await updateSetting('Livechat_enabled', true);
|
||||
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
|
||||
await updateSetting('Omnichannel_enable_department_removal', true);
|
||||
await createAgent();
|
||||
await makeAgentAvailable();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await updateSetting('Omnichannel_enable_department_removal', false);
|
||||
});
|
||||
|
||||
describe('livechat/analytics/agents/average-service-time', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/agents/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of agents', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const visitor = await createVisitor();
|
||||
const room = await createLivechatRoom(visitor.token);
|
||||
const inq = await fetchInquiry(room._id);
|
||||
await takeInquiry(inq._id);
|
||||
await closeOmnichannelRoom(room._id);
|
||||
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/agents/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.agents).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.agents[0]).to.have.a.property('_id');
|
||||
expect(body.agents[0]).to.have.a.property('username');
|
||||
expect(body.agents[0]).to.have.a.property('averageServiceTimeInSeconds').that.is.a('number');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/agents/average-service-time', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/agents/total-service-time', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/agents/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of agents', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/agents/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.agents).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.agents[0]).to.have.a.property('_id');
|
||||
expect(body.agents[0]).to.have.a.property('username');
|
||||
expect(body.agents[0]).to.have.a.property('serviceTimeDuration').that.is.a('number');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/agents/total-service-time', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/agents/available-for-service-history', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/agents/available-for-service-history'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/available-for-service-history'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/available-for-service-history'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/available-for-service-history'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/agents/available-for-service-history'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of agents', async () => {
|
||||
// Toggling to populate agent activity collection
|
||||
await createAgent();
|
||||
await makeAgentUnavailable();
|
||||
await makeAgentAvailable();
|
||||
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/agents/available-for-service-history'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.agents).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.agents[0]).to.have.a.property('username');
|
||||
expect(body.agents[0]).to.have.a.property('availableTimeInSeconds').that.is.a('number');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/agents/available-for-service-history', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/departments/amount-of-chats', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/departments/amount-of-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/amount-of-chats'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/amount-of-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/amount-of-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/amount-of-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of departments', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/departments/amount-of-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.departments).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.departments[0]).to.have.a.property('rooms').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('_id');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/departments/amount-of-chats', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/departments/average-service-time', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/departments/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
describe('with data', () => {
|
||||
let department: ILivechatDepartment;
|
||||
let visitor: ILivechatVisitor;
|
||||
|
||||
before(async () => {
|
||||
department = await createDepartment({}, [{ agentId: credentials['X-User-Id'] }]);
|
||||
|
||||
visitor = await createVisitor(department._id);
|
||||
const room = await createLivechatRoom(visitor.token);
|
||||
const inq = await fetchInquiry(room._id);
|
||||
await takeInquiry(inq._id);
|
||||
await sendAgentMessage(room._id);
|
||||
await closeOmnichannelRoom(room._id);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await deleteVisitor(visitor.token);
|
||||
await deleteDepartment(department._id);
|
||||
});
|
||||
|
||||
it('should return an array of departments', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/departments/average-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.departments).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.departments[0]).to.have.a.property('averageServiceTimeInSeconds').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('_id');
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/departments/average-service-time', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/departments/average-chat-duration-time', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/departments/average-chat-duration-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-chat-duration-time'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-chat-duration-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-chat-duration-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-chat-duration-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of departments', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/departments/average-chat-duration-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.departments).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.departments[0]).to.have.a.property('averageChatDurationTimeInSeconds').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('_id');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/departments/average-chat-duration-time', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/departments/total-service-time', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/departments/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of departments', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/departments/total-service-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.departments).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.departments[0]).to.have.a.property('chats').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('serviceTimeDuration').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('_id');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/departments/total-service-time', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/departments/average-waiting-time', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/departments/average-waiting-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-waiting-time'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-waiting-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-waiting-time'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/average-waiting-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
describe('with data', () => {
|
||||
let department: ILivechatDepartment;
|
||||
let visitor: ILivechatVisitor;
|
||||
|
||||
before(async () => {
|
||||
department = await createDepartment({}, [{ agentId: credentials['X-User-Id'] }]);
|
||||
visitor = await createVisitor(department._id);
|
||||
const room = await createLivechatRoom(visitor.token);
|
||||
const inq = await fetchInquiry(room._id);
|
||||
await takeInquiry(inq._id);
|
||||
await sendAgentMessage(room._id);
|
||||
await closeOmnichannelRoom(room._id);
|
||||
});
|
||||
after(async () => {
|
||||
await deleteVisitor(visitor.token);
|
||||
await deleteDepartment(department._id);
|
||||
});
|
||||
|
||||
it('should return an array of departments', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/departments/average-waiting-time'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.departments).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.departments[0]).to.have.a.property('averageWaitingTimeInSeconds').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('_id');
|
||||
});
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/departments/average-waiting-time', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/departments/total-transferred-chats', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/departments/total-transferred-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-transferred-chats'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-transferred-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-transferred-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-transferred-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of departments', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/departments/total-transferred-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.departments).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.departments[0]).to.have.a.property('numberOfTransferredRooms').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('_id');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/departments/total-transferred-chats', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/departments/total-abandoned-chats', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/departments/total-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/total-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of departments', async () => {
|
||||
await updateSetting('Livechat_visitor_inactivity_timeout', 0);
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const visitor = await createVisitor();
|
||||
const room = await createLivechatRoom(visitor.token);
|
||||
const inq = await fetchInquiry(room._id);
|
||||
await takeInquiry(inq._id);
|
||||
await sendMessage(room._id, 'first message', visitor.token);
|
||||
await sendAgentMessage(room._id);
|
||||
await closeOmnichannelRoom(room._id);
|
||||
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/departments/total-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.departments).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.departments[0]).to.have.a.property('abandonedRooms').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('_id');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/departments/total-abandoned-chats', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('livechat/analytics/departments/percentage-abandoned-chats', () => {
|
||||
it('should return an "unauthorized error" when the user does not have the necessary permission', async () => {
|
||||
await updatePermission('view-livechat-manager', []);
|
||||
await request
|
||||
.get(api('livechat/analytics/departments/percentage-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01', end: '2020-01-02' })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(403);
|
||||
});
|
||||
it('should fail if start is not present as query param', async () => {
|
||||
await updatePermission('view-livechat-manager', ['admin']);
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/percentage-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ end: '2020-01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not present as query param', async () => {
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/percentage-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if start is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/percentage-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: '2020-01-01x', end: date })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should fail if end is not a valid date', async () => {
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
const response = await request
|
||||
.get(api('livechat/analytics/departments/percentage-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: '2020-x01-02' })
|
||||
.expect(400);
|
||||
expect(response.body).to.have.property('success', false);
|
||||
});
|
||||
it('should return an array of departments', async () => {
|
||||
await updateSetting('Livechat_visitor_inactivity_timeout', 0);
|
||||
const date = new Date(new Date().setDate(new Date().getDate() - 2)).toISOString();
|
||||
|
||||
const { body } = await request
|
||||
.get(api('livechat/analytics/departments/percentage-abandoned-chats'))
|
||||
.set(credentials)
|
||||
.query({ start: date, end: new Date().toISOString() })
|
||||
.expect('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
expect(body).to.have.property('success', true);
|
||||
expect(body.departments).to.be.an('array').with.lengthOf.greaterThan(0);
|
||||
expect(body.departments[0]).to.have.a.property('percentageOfAbandonedChats').that.is.a('number');
|
||||
expect(body.departments[0]).to.have.a.property('_id');
|
||||
});
|
||||
it('should accept pagination', async () => {
|
||||
await pagination('livechat/analytics/departments/percentage-abandoned-chats', credentials, {
|
||||
start: new Date().toISOString(),
|
||||
end: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user