|
|
|
|
@ -923,6 +923,66 @@ describe('[Rooms]', function() { |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
describe('[/rooms.autocomplete.adminRooms]', () => { |
|
|
|
|
let testGroup; |
|
|
|
|
const testGroupName = `channel.test.adminRoom${ Date.now() }-${ Math.random() }`; |
|
|
|
|
const name = { |
|
|
|
|
name: testGroupName, |
|
|
|
|
}; |
|
|
|
|
before((done) => { |
|
|
|
|
createRoom({ type: 'p', name: testGroupName }) |
|
|
|
|
.end((err, res) => { |
|
|
|
|
testGroup = res.body.group; |
|
|
|
|
request.post(api('rooms.createDiscussion')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
prid: testGroup._id, |
|
|
|
|
t_name: `${ testGroupName }-discussion`, |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
it('should return an error when the required parameter "selector" is not provided', (done) => { |
|
|
|
|
updatePermission('can-audit', ['admin']).then(() => { |
|
|
|
|
request.get(api('rooms.autocomplete.adminRooms')) |
|
|
|
|
.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.adminRooms?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); |
|
|
|
|
}); |
|
|
|
|
it('should return FIX the rooms to fill auto complete', (done) => { |
|
|
|
|
request.get(api('rooms.autocomplete.adminRooms?')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.query({ |
|
|
|
|
selector: JSON.stringify(name), |
|
|
|
|
}) |
|
|
|
|
.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'); |
|
|
|
|
expect(res.body).to.have.property('items').that.have.lengthOf(2); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
describe('/rooms.adminRooms', () => { |
|
|
|
|
it('should throw an error when the user tries to gets a list of discussion and he cannot access the room', (done) => { |
|
|
|
|
updatePermission('view-room-administration', []).then(() => { |
|
|
|
|
|