Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/perfect-gorillas-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/rest-typings": patch
---

Fixes Omnichannel Rest API validation schemas that were flagging `Pagination` properties as invalid
2 changes: 1 addition & 1 deletion apps/meteor/tests/data/api-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const credentials: Credentials = {
'X-User-Id': undefined,
} as unknown as Credentials; // FIXME

type PathWithoutPrefix<TPath> = TPath extends `/v1/${infer U}` ? U : never;
export type PathWithoutPrefix<TPath> = TPath extends `/v1/${infer U}` ? U : never;

export function api<TPath extends PathWithoutPrefix<Path>>(path: TPath) {
return `${prefix}${path}` as const;
Expand Down
28 changes: 28 additions & 0 deletions apps/meteor/tests/data/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Credentials } from '@rocket.chat/api-client';
import type { Path } from '@rocket.chat/rest-typings';
import { expect } from 'chai';

import { api, request, type PathWithoutPrefix } from './api-data';

export const pagination = <TPath extends PathWithoutPrefix<Path>>(
apiEndpoint: TPath,
credentials: Credentials,
extraQueryParams: Record<string, any> = {},
) => {
return request
.get(api(apiEndpoint))
.set(credentials)
.query({
...extraQueryParams,
count: 10,
offset: 1,
sort: JSON.stringify({ _updatedAt: -1 }),
})
.expect('content-type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('count').that.is.a('number');
expect(res.body).to.have.property('offset').that.is.a('number');
expect(res.body).to.have.property('total').that.is.a('number');
});
};
67 changes: 67 additions & 0 deletions apps/meteor/tests/end-to-end/api/livechat/17-dashboards-ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
fetchInquiry,
} 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', () => {
Expand Down Expand Up @@ -91,6 +92,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -151,6 +158,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -215,6 +228,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -274,6 +293,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -333,6 +358,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -392,6 +423,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -452,6 +489,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -511,6 +554,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -570,6 +619,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -638,6 +693,12 @@ import { IS_EE } from '../../../e2e/config/constants';
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 () => {
Expand Down Expand Up @@ -699,5 +760,11 @@ import { IS_EE } from '../../../e2e/config/constants';
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(),
});
});
});
});
103 changes: 99 additions & 4 deletions packages/rest-typings/src/v1/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,6 @@ type LivechatDepartmentsByUnitIdProps = PaginatedRequest;
const LivechatDepartmentsByUnitIdSchema = {
type: 'object',
properties: {
text: {
type: 'string',
},
count: {
type: 'number',
nullable: true,
Expand Down Expand Up @@ -1626,6 +1623,15 @@ const LivechatAnalyticsAgentsAverageServiceTimeSchema = {
end: {
type: 'string',
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1696,6 +1702,15 @@ const LivechatAnalyticsAgentsTotalServiceTimeSchema = {
end: {
type: 'string',
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1724,6 +1739,15 @@ const LivechatAnalyticsAgentsAvailableForServiceHistorySchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1757,6 +1781,15 @@ const LivechatAnalyticsDepartmentsAmountOfChatsSchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1785,6 +1818,15 @@ const LivechatAnalyticsDepartmentsAverageServiceTimeSchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1813,6 +1855,15 @@ const LivechatAnalyticsDepartmentsAverageChatDurationTimeSchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1840,6 +1891,15 @@ const LivechatAnalyticsDepartmentsTotalServiceTimeSchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1868,6 +1928,15 @@ const LivechatAnalyticsDepartmentsAverageWaitingTimeSchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1896,6 +1965,15 @@ const LivechatAnalyticsDepartmentsTotalTransferredChatsSchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1924,6 +2002,15 @@ const LivechatAnalyticsDepartmentsTotalAbandonedChatsSchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -1952,6 +2039,15 @@ const LivechatAnalyticsDepartmentsPercentageAbandonedChatsSchema = {
type: 'string',
nullable: true,
},
count: {
type: 'number',
},
offset: {
type: 'number',
},
sort: {
type: 'string',
},
},
required: ['start', 'end'],
additionalProperties: false,
Expand Down Expand Up @@ -2837,7 +2933,6 @@ const GETLivechatVisitorsSearchSchema = {
},
term: {
type: 'string',
nullable: true,
},
},
required: ['term'],
Expand Down
Loading