[IMPROVE] Replace userAutocomplete publication by REST (#15956)

pull/15901/head
Marcos Spessatto Defendi 6 years ago committed by Diego Sampaio
parent 5bd373c8d7
commit 1bac45960a
  1. 2
      .meteor/packages
  2. 1
      .meteor/versions
  3. 2
      .stylelintignore
  4. 24
      app/api/server/lib/rooms.js
  5. 27
      app/api/server/lib/users.js
  6. 15
      app/api/server/v1/rooms.js
  7. 15
      app/api/server/v1/users.js
  8. 4
      app/authorization/client/views/permissionsRole.js
  9. 6
      app/channel-settings-mail-messages/client/views/mailMessagesInstructions.js
  10. 2
      app/discussion/client/views/creationDialog/CreateDiscussion.html
  11. 6
      app/discussion/client/views/creationDialog/CreateDiscussion.js
  12. 2
      app/livechat/client/views/app/livechatAgents.html
  13. 6
      app/livechat/client/views/app/livechatAutocompleteUser.js
  14. 2
      app/livechat/client/views/app/livechatCurrentChats.html
  15. 2
      app/livechat/client/views/app/livechatDepartmentForm.html
  16. 2
      app/livechat/client/views/app/livechatManagers.html
  17. 2
      app/livechat/client/views/app/livechatQueue.html
  18. 2
      app/livechat/client/views/app/tabbar/visitorForward.html
  19. 14
      app/meteor-autocomplete/client/autocomplete-client.js
  20. 0
      app/meteor-autocomplete/client/autocomplete.css
  21. 3
      app/meteor-autocomplete/client/collection.js
  22. 0
      app/meteor-autocomplete/client/index.js
  23. 0
      app/meteor-autocomplete/client/inputs.html
  24. 0
      app/meteor-autocomplete/client/templates.js
  25. 1
      app/meteor-autocomplete/server/autocomplete-server.js
  26. 0
      app/meteor-autocomplete/server/index.js
  27. 15
      app/models/server/raw/Rooms.js
  28. 35
      app/models/server/raw/Users.js
  29. 28
      app/ui-clean-history/client/views/cleanHistory.js
  30. 4
      app/ui-flextab/client/tabs/inviteUsers.js
  31. 24
      app/ui-flextab/client/tabs/membersList.js
  32. 4
      app/ui/client/views/app/createChannel.js
  33. 2
      client/components/admin/settings/inputs/RoomPickSettingInput.js
  34. 1
      client/importPackages.js
  35. 1
      client/importsCss.js
  36. 3
      packages/meteor-autocomplete/client/collection.js
  37. 23
      packages/meteor-autocomplete/package.js
  38. 1
      server/importPackages.js
  39. 1
      server/publications/channelAndPrivateAutocomplete.js
  40. 1
      server/publications/userAutocomplete.js
  41. 41
      tests/end-to-end/api/01-users.js
  42. 41
      tests/end-to-end/api/09-rooms.js

@ -58,7 +58,6 @@ jparker:gravatar
kadira:blaze-layout
kadira:flow-router
keepnox:perfect-scrollbar
mizzao:autocomplete
mizzao:timesync
mrt:reactive-store
mystor:device-detection
@ -97,3 +96,4 @@ webapp@1.7.5
webapp-hashing@1.0.9
rocketchat:oauth2-server
rocketchat:i18n
dandv:caret-position

@ -86,7 +86,6 @@ meteorspark:util@0.2.0
minifier-css@1.4.3
minifier-js@2.5.1
minimongo@1.4.5
mizzao:autocomplete@0.5.1
mizzao:timesync@0.3.4
mobile-experience@1.0.5
mobile-status-bar@1.0.14

@ -1,4 +1,4 @@
app/theme/client/vendor/fontello/css/fontello.css
packages/meteor-autocomplete/client/autocomplete.css
app/meteor-autocomplete/client/autocomplete.css
app/katex/katex.min.css
app/emoji-emojione/client/*.css

@ -0,0 +1,24 @@
import { Rooms } from '../../../models/server/raw';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
export async function findChannelAndPrivateAutocomplete({ uid, selector }) {
if (!await hasPermissionAsync(uid, 'view-other-user-channels')) {
return { items: [] };
}
const options = {
fields: {
_id: 1,
name: 1,
},
limit: 10,
sort: {
name: 1,
},
};
const rooms = await Rooms.findChannelAndPrivateByNameStarting(selector.name, options).toArray();
return {
items: rooms,
};
}

@ -0,0 +1,27 @@
import { Users } from '../../../models/server/raw';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
export async function findUsersToAutocomplete({ uid, selector }) {
if (!await hasPermissionAsync(uid, 'view-outside-room')) {
return { items: [] };
}
const exceptions = selector.exceptions || [];
const conditions = selector.conditions || {};
const options = {
fields: {
name: 1,
username: 1,
status: 1,
},
sort: {
username: 1,
},
limit: 10,
};
const users = await Users.findActiveByUsernameOrNameRegexWithExceptionsAndConditions(selector.term, exceptions, conditions, options).toArray();
return {
items: users,
};
}

@ -4,6 +4,7 @@ import Busboy from 'busboy';
import { FileUpload } from '../../../file-upload';
import { Rooms, Messages } from '../../../models';
import { API } from '../api';
import { findChannelAndPrivateAutocomplete } from '../lib/rooms';
function findRoomByIdOrName({ params, checkedArchived = true }) {
if ((!params.roomId || !params.roomId.trim()) && (!params.roomName || !params.roomName.trim())) {
@ -274,3 +275,17 @@ API.v1.addRoute('rooms.getDiscussions', { authRequired: true }, {
});
},
});
API.v1.addRoute('rooms.autocomplete.channelAndPrivate', { authRequired: true }, {
get() {
const { selector } = this.queryParams;
if (!selector) {
return API.v1.failure('The \'selector\' param is required');
}
return API.v1.success(Promise.await(findChannelAndPrivateAutocomplete({
uid: this.userId,
selector: JSON.parse(selector),
})));
},
});

@ -19,6 +19,7 @@ import {
import { getFullUserData } from '../../../lib/server/functions/getFullUserData';
import { API } from '../api';
import { setStatusText } from '../../../lib/server';
import { findUsersToAutocomplete } from '../lib/users';
API.v1.addRoute('users.create', { authRequired: true }, {
post() {
@ -685,3 +686,17 @@ API.v1.addRoute('users.requestDataDownload', { authRequired: true }, {
});
},
});
API.v1.addRoute('users.autocomplete', { authRequired: true }, {
get() {
const { selector } = this.queryParams;
if (!selector) {
return API.v1.failure('The \'selector\' param is required');
}
return API.v1.success(Promise.await(findUsersToAutocomplete({
uid: this.userId,
selector: JSON.parse(selector),
})));
},
});

@ -95,7 +95,7 @@ Template.permissionsRole.helpers({
rules: [
{
collection: 'CachedChannelList',
subscription: 'channelAndPrivateAutocomplete',
endpoint: 'rooms.autocomplete.channelAndPrivate',
field: 'name',
template: Template.roomSearch,
noMatchTemplate: Template.roomSearchEmpty,
@ -118,7 +118,7 @@ Template.permissionsRole.helpers({
rules: [
{
collection: 'CachedUserList',
subscription: 'userAutocomplete',
endpoint: 'users.autocomplete',
field: 'username',
template: Template.userSearch,
noMatchTemplate: Template.userSearchEmpty,

@ -3,7 +3,6 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { Blaze } from 'meteor/blaze';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { AutoComplete } from 'meteor/mizzao:autocomplete';
import { Deps } from 'meteor/deps';
import toastr from 'toastr';
@ -11,6 +10,7 @@ import { ChatRoom } from '../../../models';
import { t, isEmail, handleError, roomTypes } from '../../../utils';
import { settings } from '../../../settings';
import resetSelection from '../resetSelection';
import { AutoComplete } from '../../../meteor-autocomplete/client';
const filterNames = (old) => {
const reg = new RegExp(`^${ settings.get('UTF8_Names_Validation') }$`);
@ -39,7 +39,7 @@ Template.mailMessagesInstructions.helpers({
rules: [
{
collection: 'CachedChannelList',
subscription: 'userAutocomplete',
endpoint: 'users.autocomplete',
field: 'username',
template: Template.userSearch,
noMatchTemplate: Template.userSearchEmpty,
@ -253,7 +253,7 @@ Template.mailMessagesInstructions.onCreated(function() {
rules: [
{
collection: 'UserAndRoom',
subscription: 'userAutocomplete',
endpoint: 'users.autocomplete',
field: 'username',
matchAll: true,
filter,

@ -52,7 +52,7 @@
list=selectedUsers
onSelect=onSelectUser
collection='UserAndRoom'
subscription='userAutocomplete'
endpoint='users.autocomplete'
field='username'
sort='username'
label="Invite_Users"

@ -1,7 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { AutoComplete } from 'meteor/mizzao:autocomplete';
import { Blaze } from 'meteor/blaze';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import toastr from 'toastr';
@ -10,6 +9,7 @@ import { roomTypes } from '../../../../utils/client';
import { callbacks } from '../../../../callbacks/client';
import { ChatRoom, ChatSubscription } from '../../../../models/client';
import { call } from '../../../../ui-utils/client';
import { AutoComplete } from '../../../../meteor-autocomplete/client';
import './CreateDiscussion.html';
@ -278,7 +278,7 @@ Template.SearchCreateDiscussion.onCreated(function() {
this.onClickTag = this.data.onClickTag;
this.deleteLastItem = this.data.deleteLastItem;
const { collection, subscription, field, sort, onSelect, selector = (match) => ({ term: match }) } = this.data;
const { collection, endpoint, field, sort, onSelect, selector = (match) => ({ term: match }) } = this.data;
this.ac = new AutoComplete(
{
selector: {
@ -293,7 +293,7 @@ Template.SearchCreateDiscussion.onCreated(function() {
rules: [
{
collection,
subscription,
endpoint,
field,
matchAll: true,
// filter,

@ -12,7 +12,7 @@
deleteLastItem=deleteLastAgent
onSelect=onSelectAgents
collection='UserAndRoom'
subscription='userAutocomplete'
endpoint='users.autocomplete'
field='username'
sort='username'
label="Search_by_username"

@ -1,8 +1,8 @@
import { Blaze } from 'meteor/blaze';
import { Template } from 'meteor/templating';
import { AutoComplete } from 'meteor/mizzao:autocomplete';
import { ReactiveVar } from 'meteor/reactive-var';
import { AutoComplete } from '../../../../meteor-autocomplete/client';
import './livechatAutocompleteUser.html';
Template.livechatAutocompleteUser.helpers({
@ -90,7 +90,7 @@ Template.livechatAutocompleteUser.onCreated(function() {
filter.conditions = conditions;
});
const { collection, subscription, field, sort, onSelect, selector = (match) => ({ term: match }) } = this.data;
const { collection, endpoint, field, sort, onSelect, selector = (match) => ({ term: match }) } = this.data;
this.ac = new AutoComplete({
selector: {
anchor: '.rc-input__label',
@ -105,7 +105,7 @@ Template.livechatAutocompleteUser.onCreated(function() {
{
filter,
collection,
subscription,
endpoint,
field,
matchAll: true,
doNotChangeWidth: false,

@ -19,7 +19,7 @@
list=selectedAgents
onSelect=onSelectAgents
collection='UserAndRoom'
subscription='userAutocomplete'
endpoint='users.autocomplete'
field='username'
sort='username'
label="Served_By"

@ -79,7 +79,7 @@
list=selectedAgents
onSelect=onSelectAgents
collection='UserAndRoom'
subscription='userAutocomplete'
endpoint='users.autocomplete'
field='username'
sort='username'
label="Search_by_username"

@ -8,7 +8,7 @@
deleteLastItem=deleteLastManager
onSelect=onSelectManagers
collection='UserAndRoom'
subscription='userAutocomplete'
endpoint='users.autocomplete'
field='username'
sort='username'
label="Search_by_username"

@ -11,7 +11,7 @@
list=selectedAgents
onSelect=onSelectAgents
collection='UserAndRoom'
subscription='userAutocomplete'
endpoint='users.autocomplete'
field='username'
sort='username'
label="Served_By"

@ -35,7 +35,7 @@
list=selectedAgents
onSelect=onSelectAgents
collection='UserAndRoom'
subscription='userAutocomplete'
endpoint='users.autocomplete'
field='username'
sort='username'
label="Select_a_user"

@ -6,6 +6,7 @@ import _ from 'underscore';
import { getCaretCoordinates } from 'meteor/dandv:caret-position';
import AutoCompleteRecords from './collection';
import { APIClient } from '../../utils/client';
const isServerSearch = function(rule) {
return _.isString(rule.collection);
@ -108,7 +109,7 @@ export default class AutoComplete {
// Autosubscribe to the record set published by the server based on the filter
// This will tear down server subscriptions when they are no longer being used.
this.sub = null;
this.comp = Deps.autorun(() => {
this.comp = Deps.autorun(async () => {
const rule = this.matchedRule();
const filter = this.getFilter();
if (this.sub) {
@ -124,14 +125,15 @@ export default class AutoComplete {
this.setLoaded(true);
return;
}
const [selector, options] = getFindParams(rule, filter, this.limit);
const [selector] = getFindParams(rule, filter, this.limit);
// console.debug 'Subscribing to <%s> in <%s>.<%s>', filter, rule.collection, rule.field
this.setLoaded(false);
const subName = rule.subscription || 'autocomplete-recordset';
this.sub = Meteor.subscribe(subName, selector, options, rule.collection, () => {
this.setLoaded(true);
});
const endpointName = rule.endpoint || 'users.autocomplete';
const { items } = await APIClient.v1.get(`${ endpointName }?selector=${ JSON.stringify(selector) }`);
AutoCompleteRecords.remove({});
items.forEach((item) => AutoCompleteRecords.insert(item));
this.setLoaded(true);
});
}

@ -0,0 +1,3 @@
import { Mongo } from 'meteor/mongo';
export default new Mongo.Collection(null);

@ -9,6 +9,7 @@ const Autocomplete = class {
};
Meteor.publish('autocomplete-recordset', function(selector, options, collName) {
console.warn('The publication "autocomplete-recordset" is deprecated and will be removed after version v3.0.0');
const collection = global[collName];
// This is a semi-documented Meteor feature:

@ -1,3 +1,5 @@
import s from 'underscore.string';
import { BaseRaw } from './BaseRaw';
export class RoomsRaw extends BaseRaw {
@ -30,4 +32,17 @@ export class RoomsRaw extends BaseRaw {
const [statistic] = await this.col.aggregate(aggregate).toArray();
return statistic;
}
findChannelAndPrivateByNameStarting(name, options) {
const nameRegex = new RegExp(`^${ s.escapeRegExp(name).trim() }`, 'i');
const query = {
t: {
$in: ['c', 'p'],
},
name: nameRegex,
};
return this.find(query, options);
}
}

@ -1,4 +1,5 @@
import moment from 'moment';
import s from 'underscore.string';
import { BaseRaw } from './BaseRaw';
@ -265,6 +266,40 @@ export class UsersRaw extends BaseRaw {
return this.col.aggregate(params).toArray();
}
findActiveByUsernameOrNameRegexWithExceptionsAndConditions(searchTerm, exceptions, conditions, options) {
if (exceptions == null) { exceptions = []; }
if (conditions == null) { conditions = {}; }
if (options == null) { options = {}; }
if (!Array.isArray(exceptions)) {
exceptions = [exceptions];
}
const termRegex = new RegExp(s.escapeRegExp(searchTerm), 'i');
const query = {
$or: [{
username: termRegex,
}, {
name: termRegex,
}],
active: true,
type: {
$in: ['user', 'bot'],
},
$and: [{
username: {
$exists: true,
},
}, {
username: {
$nin: exceptions,
},
}],
...conditions,
};
return this.find(query, options);
}
countAllAgentsStatus({ departmentId = undefined }) {
const match = {
$match: {

@ -3,13 +3,13 @@ import { Blaze } from 'meteor/blaze';
import { ReactiveVar } from 'meteor/reactive-var';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { AutoComplete } from 'meteor/mizzao:autocomplete';
import moment from 'moment';
import { ChatRoom } from '../../../models';
import { t, roomTypes } from '../../../utils';
import { settings } from '../../../settings';
import { modal, call } from '../../../ui-utils';
import { AutoComplete } from '../../../meteor-autocomplete/client';
const getRoomName = function() {
const room = ChatRoom.findOne(Session.get('openedRoom'));
@ -89,30 +89,6 @@ Template.cleanHistory.helpers({
},
};
},
autocompleteSettings() {
return {
limit: 10,
rules: [
{
collection: 'CachedChannelList',
subscription: 'userAutocomplete',
field: 'username',
template: Template.userSearch,
noMatchTemplate: Template.userSearchEmpty,
matchAll: true,
filter: {
exceptions: Template.instance().selectedUsers.get(),
},
selector(match) {
return {
term: match,
};
},
sort: 'username',
},
],
};
},
selectedUsers() {
return Template.instance().selectedUsers.get();
},
@ -160,7 +136,7 @@ Template.cleanHistory.onCreated(function() {
rules: [
{
collection: 'UserAndRoom',
subscription: 'userAutocomplete',
endpoint: 'users.autocomplete',
field: 'username',
matchAll: true,
doNotChangeWidth: false,

@ -3,12 +3,12 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { Blaze } from 'meteor/blaze';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { AutoComplete } from 'meteor/mizzao:autocomplete';
import { Deps } from 'meteor/deps';
import toastr from 'toastr';
import { settings } from '../../../settings';
import { t } from '../../../utils';
import { AutoComplete } from '../../../meteor-autocomplete/client';
const acEvents = {
'click .rc-popup-list__item'(e, t) {
@ -148,7 +148,7 @@ Template.inviteUsers.onCreated(function() {
{
// @TODO maybe change this 'collection' and/or template
collection: 'UserAndRoom',
subscription: 'userAutocomplete',
endpoint: 'users.autocomplete',
field: 'username',
matchAll: true,
filter,

@ -100,30 +100,6 @@ Template.membersList.helpers({
return (() => roomTypes.roomTypes[roomData.t].canAddUser(roomData))();
},
autocompleteSettingsAddUser() {
return {
limit: 10,
// inputDelay: 300
rules: [
{
collection: 'UserAndRoom',
subscription: 'userAutocomplete',
field: 'username',
template: Template.userSearch,
noMatchTemplate: Template.userSearchEmpty,
matchAll: true,
filter: {
exceptions: [Meteor.user().username],
},
selector(match) {
return { term: match };
},
sort: 'username',
},
],
};
},
showUserInfo() {
const webrtc = WebRTC.getInstanceByRoomId(this.rid);
let videoActive = undefined;

@ -4,7 +4,6 @@ import { Tracker } from 'meteor/tracker';
import { Blaze } from 'meteor/blaze';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { AutoComplete } from 'meteor/mizzao:autocomplete';
import toastr from 'toastr';
import _ from 'underscore';
@ -12,6 +11,7 @@ import { settings } from '../../../../settings';
import { callbacks } from '../../../../callbacks';
import { t, roomTypes } from '../../../../utils';
import { hasAllPermission } from '../../../../authorization';
import { AutoComplete } from '../../../../meteor-autocomplete/client';
const acEvents = {
'click .rc-popup-list__item'(e, t) {
@ -349,7 +349,7 @@ Template.createChannel.onCreated(function() {
// @TODO maybe change this 'collection' and/or template
collection: 'UserAndRoom',
subscription: 'userAutocomplete',
endpoint: 'users.autocomplete',
field: 'username',
matchAll: true,
filter,

@ -46,7 +46,7 @@ export function RoomPickSettingInput({
{
// @TODO maybe change this 'collection' and/or template
collection: 'CachedChannelList',
subscription: 'channelAndPrivateAutocomplete',
endpoint: 'rooms.autocomplete.channelAndPrivate',
field: 'name',
template: Template.roomSearch,
noMatchTemplate: Template.roomSearchEmpty,

@ -107,3 +107,4 @@ import '../app/ui-cached-collection';
import '../app/action-links';
import '../app/reactions/client';
import '../app/livechat/client';
import '../app/meteor-autocomplete/client';

@ -36,3 +36,4 @@ import '../app/ui-clean-history/client/views/stylesheets/cleanHistory.css';
import '../app/ui-vrecord/client/vrecord.css';
import '../app/videobridge/client/stylesheets/video.less';
import '../app/wordpress/client/wordpress-login-button.css';
import '../app/meteor-autocomplete/client/autocomplete.css';

@ -1,3 +0,0 @@
import { Mongo } from 'meteor/mongo';
export default new Mongo.Collection('autocompleteRecords');

@ -1,23 +0,0 @@
Package.describe({
name: 'mizzao:autocomplete',
summary: 'Client/server autocompletion designed for Meteor\'s collections and reactivity',
version: '0.5.1',
git: 'https://github.com/mizzao/meteor-autocomplete.git',
});
Package.onUse(function(api) {
api.use([
'ecmascript',
'mongo',
'ddp',
]);
api.use([
'blaze',
'templating',
'jquery',
'dandv:caret-position@2.1.0-3',
], 'client');
api.addFiles('client/autocomplete.css', 'client');
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});

@ -113,3 +113,4 @@ import '../app/ui-utils';
import '../app/action-links';
import '../app/reactions/server';
import '../app/livechat/server';
import '../app/meteor-autocomplete/server';

@ -4,6 +4,7 @@ import { hasPermission } from '../../app/authorization';
import { Rooms } from '../../app/models';
Meteor.publish('channelAndPrivateAutocomplete', function(selector) {
console.warn('The publication "channelAndPrivateAutocomplete" is deprecated and will be removed after version v3.0.0');
if (!this.userId) {
return this.ready();
}

@ -5,6 +5,7 @@ import { hasPermission } from '../../app/authorization/server';
import { Users } from '../../app/models/server';
Meteor.publish('userAutocomplete', function(selector) {
console.warn('The publication "userAutocomplete" is deprecated and will be removed after version v3.0.0');
const uid = this.userId;
if (!uid) {
return this.ready();

@ -1700,4 +1700,45 @@ describe('[Users]', function() {
.end(done);
});
});
describe('[/users.autocomplete]', () => {
it('should return an empty list when the user does not have the necessary permission', (done) => {
updatePermission('view-outside-room', []).then(() => {
request.get(api('users.autocomplete?selector={}'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('items').and.to.be.an('array').that.has.lengthOf(0);
})
.end(done);
});
});
it('should return an error when the required parameter "selector" is not provided', (done) => {
updatePermission('view-outside-room', ['admin', 'user']).then(() => {
request.get(api('users.autocomplete'))
.set(credentials)
.query({})
.expect('Content-Type', 'application/json')
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
expect(res.body.error).to.be.equal('The \'selector\' param is required');
})
.end(done);
});
});
it('should return the users to fill auto complete', (done) => {
request.get(api('users.autocomplete?selector={}'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('items').and.to.be.an('array');
})
.end(done);
});
});
});

@ -864,4 +864,45 @@ describe('[Rooms]', function() {
.end(done);
});
});
describe('[/rooms.autocomplete.channelAndPrivate]', () => {
it('should return an empty list when the user does not have the necessary permission', (done) => {
updatePermission('view-other-user-channels', []).then(() => {
request.get(api('rooms.autocomplete.channelAndPrivate?selector={}'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('items').and.to.be.an('array').that.has.lengthOf(0);
})
.end(done);
});
});
it('should return an error when the required parameter "selector" is not provided', (done) => {
updatePermission('view-other-user-channels', ['admin']).then(() => {
request.get(api('rooms.autocomplete.channelAndPrivate'))
.set(credentials)
.query({})
.expect('Content-Type', 'application/json')
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
expect(res.body.error).to.be.equal('The \'selector\' param is required');
})
.end(done);
});
});
it('should return the rooms to fill auto complete', (done) => {
request.get(api('rooms.autocomplete.channelAndPrivate?selector={}'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('items').and.to.be.an('array');
})
.end(done);
});
});
});

Loading…
Cancel
Save