Skip to content

Commit

Permalink
Merge branch 'develop' into fix/fed-116
Browse files Browse the repository at this point in the history
  • Loading branch information
lmauromb authored Oct 27, 2023
2 parents 7eb4bc0 + 270d16a commit 3e3dfab
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 16 deletions.
4 changes: 4 additions & 0 deletions apps/meteor/app/api/server/v1/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ API.v1.addRoute(
return API.v1.unauthorized();
}

if (process.env.NODE_ENV === 'development') {
return API.v1.success({ offline: true });
}

return API.v1.success({ offline: !(await registerPreIntentWorkspaceWizard()) });
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/components/AutoCompleteAgent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const AutoCompleteAgent = ({
haveAll = false,
haveNoAgentsSelectedOption = false,
excludeId,
showIdleAgents = false,
showIdleAgents = true,
onlyAvailable = false,
withTitle = false,
onChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useAgentsList = (
const reload = useCallback(() => setItemsList(new RecordList<AgentOption>()), []);

const getAgents = useEndpoint('GET', '/v1/livechat/users/agent');
const { text, onlyAvailable = false, showIdleAgents = false, excludeId, haveAll, haveNoAgentsSelectedOption } = options;
const { text, onlyAvailable = false, showIdleAgents = true, excludeId, haveAll, haveNoAgentsSelectedOption } = options;

useComponentDidUpdate(() => {
options && reload();
Expand Down
12 changes: 7 additions & 5 deletions apps/meteor/client/views/marketplace/hooks/useCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export const useCategories = (): [CategoryDropDownGroups, selectedCategoriesList
try {
const fetchedCategories = await AppClientOrchestratorInstance.getCategories();

const mappedCategories = fetchedCategories.map((currentCategory) => ({
id: currentCategory.id,
label: currentCategory.title,
checked: false,
}));
const mappedCategories = fetchedCategories
.filter((currentCategory) => !currentCategory.hidden)
.map((currentCategory) => ({
id: currentCategory.id,
label: currentCategory.title,
checked: false,
}));

setCategories([
{
Expand Down
2 changes: 2 additions & 0 deletions apps/meteor/client/views/setupWizard/SetupWizardRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ReactElement } from 'react';
import React from 'react';
import { useTranslation, I18nextProvider } from 'react-i18next';

import ModalRegion from '../modal/ModalRegion';
import SetupWizardPage from './SetupWizardPage';
import { useBodyPosition } from './hooks/useBodyPosition';
import { useRouteLock } from './hooks/useRouteLock';
Expand All @@ -26,6 +27,7 @@ export const SetupWizardRoute = (): ReactElement | null => {
<SetupWizardProvider>
<DarkModeProvider.default>
<SetupWizardPage />
<ModalRegion />
</DarkModeProvider.default>
</SetupWizardProvider>
</I18nextProvider>
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/ee/client/apps/@types/IOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface IAppExternalURL {
export interface ICategory {
createdDate: Date;
description: string;
hidden: boolean;
id: string;
modifiedDate: Date;
title: string;
Expand Down
16 changes: 10 additions & 6 deletions apps/meteor/tests/data/users.helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UserStatus } from '@rocket.chat/core-typings';
import { api, credentials, request } from './api-data';
import { password } from './user';

Expand Down Expand Up @@ -34,12 +35,9 @@ export const login = (username, password) =>
});

export const deleteUser = async (user) =>
request
.post(api('users.delete'))
.set(credentials)
.send({
userId: user._id,
});
request.post(api('users.delete')).set(credentials).send({
userId: user._id,
});

export const getUserByUsername = (username) =>
new Promise((resolve) => {
Expand Down Expand Up @@ -86,3 +84,9 @@ export const setUserActiveStatus = (userId, activeStatus = true) =>
})
.end(resolve);
});

export const setUserStatus = (overrideCredentials = credentials, status = UserStatus.ONLINE) =>
request.post(api('users.setStatus')).set(overrideCredentials).send({
message: '',
status,
});
66 changes: 64 additions & 2 deletions apps/meteor/tests/end-to-end/api/livechat/01-agents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ILivechatAgent, ILivechatDepartment, IUser } from '@rocket.chat/core-typings';
import { UserStatus, type ILivechatAgent, type ILivechatDepartment, type IUser } from '@rocket.chat/core-typings';
import { expect } from 'chai';
import { after, before, describe, it } from 'mocha';
import type { Response } from 'supertest';
Expand All @@ -16,7 +16,7 @@ import {
} from '../../../data/livechat/rooms';
import { updatePermission, updateSetting } from '../../../data/permissions.helper';
import { password } from '../../../data/user';
import { createUser, deleteUser, getMe, login } from '../../../data/users.helper';
import { createUser, deleteUser, getMe, login, setUserStatus } from '../../../data/users.helper';

describe('LIVECHAT - Agents', function () {
this.retries(0);
Expand Down Expand Up @@ -114,6 +114,68 @@ describe('LIVECHAT - Agents', function () {
expect(res.body.users.every((u: { statusLivechat: string }) => u.statusLivechat === 'available')).to.be.true;
});
});
it('should return an array of available/unavailable agents when onlyAvailable is false', async () => {
await request
.get(api('livechat/users/agent'))
.set(credentials)
.expect('Content-Type', 'application/json')
.query({ onlyAvailable: false })
.expect(200)
.expect((res: Response) => {
expect(res.body).to.have.property('success', true);
expect(res.body.users).to.be.an('array');
expect(res.body).to.have.property('offset');
expect(res.body).to.have.property('total');
expect(res.body).to.have.property('count');
expect(
res.body.users.every(
(u: { statusLivechat: string }) => !u.statusLivechat || ['available', 'not-available'].includes(u.statusLivechat),
),
).to.be.true;
});
});

it('should return offline agents when showIdleAgents is true', async () => {
await setUserStatus(agent2.credentials, UserStatus.OFFLINE);
await request
.get(api('livechat/users/agent'))
.set(credentials)
.expect('Content-Type', 'application/json')
.query({ showIdleAgents: true })
.expect(200)
.expect((res: Response) => {
expect(res.body).to.have.property('success', true);
expect(res.body.users).to.be.an('array');
expect(res.body).to.have.property('offset');
expect(res.body).to.have.property('total');
expect(res.body).to.have.property('count');
expect(
res.body.users.every(
(u: { status: UserStatus }) =>
!u.status || [UserStatus.ONLINE, UserStatus.OFFLINE, UserStatus.AWAY, UserStatus.BUSY].includes(u.status),
),
).to.be.true;
});
});

it('should return only online agents when showIdleAgents is false', async () => {
await setUserStatus(agent2.credentials, UserStatus.ONLINE);
await request
.get(api('livechat/users/agent'))
.set(credentials)
.expect('Content-Type', 'application/json')
.query({ showIdleAgents: false })
.expect(200)
.expect((res: Response) => {
expect(res.body).to.have.property('success', true);
expect(res.body.users).to.be.an('array');
expect(res.body).to.have.property('offset');
expect(res.body).to.have.property('total');
expect(res.body).to.have.property('count');
expect(res.body.users.every((u: { status: UserStatus }) => u.status !== UserStatus.OFFLINE)).to.be.true;
});
});

it('should return an array of managers', async () => {
await updatePermission('view-livechat-manager', ['admin']);
await updatePermission('manage-livechat-agents', ['admin']);
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-typings/src/v1/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ const LivechatUsersManagerGETSchema = {
nullable: true,
},
onlyAvailable: {
type: 'string',
type: 'boolean',
nullable: true,
},
excludeId: {
Expand Down

0 comments on commit 3e3dfab

Please sign in to comment.