diff --git a/apps/meteor/tests/end-to-end/api/02-channels.js b/apps/meteor/tests/end-to-end/api/02-channels.js index c049602aad99..80e7435c8e8f 100644 --- a/apps/meteor/tests/end-to-end/api/02-channels.js +++ b/apps/meteor/tests/end-to-end/api/02-channels.js @@ -184,6 +184,27 @@ describe('[Channels]', function () { }) .end(done); }); + it('should return all channels messages where the last message of array should have the "star" array with USERS star ONLY even requested with count and offset params', (done) => { + request + .get(api('channels.messages')) + .set(credentials) + .query({ + roomId: testChannel._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('messages').and.to.be.an('array'); + const { messages } = res.body; + const lastMessage = messages.filter((message) => message._id === channelMessage._id)[0]; + expect(lastMessage).to.have.property('starred').and.to.be.an('array'); + expect(lastMessage.starred[0]._id).to.be.equal(adminUsername); + }) + .end(done); + }); }); describe('[/channels.online]', () => { @@ -340,6 +361,24 @@ describe('[Channels]', function () { .end(done); }); + it('should succeed when searching by roomId even requested with count and offset params', (done) => { + request + .get(api('channels.files')) + .set(credentials) + .query({ + roomId: 'GENERAL', + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('files').and.to.be.an('array'); + }) + .end(done); + }); + it('should succeed when searching by roomName', (done) => { request .get(api('channels.files')) @@ -355,6 +394,24 @@ describe('[Channels]', function () { }) .end(done); }); + + it('should succeed when searching by roomName even requested with count and offset params', (done) => { + request + .get(api('channels.files')) + .set(credentials) + .query({ + roomName: 'general', + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('files').and.to.be.an('array'); + }) + .end(done); + }); }); describe('[/channels.join]', () => { @@ -818,20 +875,40 @@ describe('[Channels]', function () { }); }); - it('/channels.history', (done) => { - request - .get(api('channels.history')) - .set(credentials) - .query({ - roomId: channel._id, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - expect(res.body).to.have.property('messages'); - }) - .end(done); + describe('/channels.history', () => { + it('should return an array of members by channel', (done) => { + request + .get(api('channels.history')) + .set(credentials) + .query({ + roomId: channel._id, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('messages'); + }) + .end(done); + }); + + it('should return an array of members by channel even requested with count and offset params', (done) => { + request + .get(api('channels.history')) + .set(credentials) + .query({ + roomId: channel._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('messages'); + }) + .end(done); + }); }); it('/channels.archive', (done) => { @@ -964,23 +1041,45 @@ describe('[Channels]', function () { }) .end(done); }); - it('/channels.members', (done) => { - request - .get(api('channels.members')) - .set(credentials) - .query({ - roomId: channel._id, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - expect(res.body).to.have.property('members').and.to.be.an('array'); - expect(res.body).to.have.property('count'); - expect(res.body).to.have.property('total'); - expect(res.body).to.have.property('offset'); - }) - .end(done); + describe('/channels.members', () => { + it('should return an array of members by channel', (done) => { + request + .get(api('channels.members')) + .set(credentials) + .query({ + roomId: channel._id, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('members').and.to.be.an('array'); + expect(res.body).to.have.property('count'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + }) + .end(done); + }); + it('should return an array of members by channel even requested with count and offset params', (done) => { + request + .get(api('channels.members')) + .set(credentials) + .query({ + roomId: channel._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('members').and.to.be.an('array'); + expect(res.body).to.have.property('count'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + }) + .end(done); + }); }); it('/channels.rename', async () => { @@ -1531,7 +1630,7 @@ describe('[Channels]', function () { }); describe('/channels.getAllUserMentionsByChannel', () => { - it('should return and array of mentions by channel', (done) => { + it('should return an array of mentions by channel', (done) => { request .get(api('channels.getAllUserMentionsByChannel')) .set(credentials) @@ -1549,6 +1648,26 @@ describe('[Channels]', function () { }) .end(done); }); + it('should return an array of mentions by channel even requested with count and offset params', (done) => { + request + .get(api('channels.getAllUserMentionsByChannel')) + .set(credentials) + .query({ + roomId: channel._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('mentions').and.to.be.an('array'); + expect(res.body).to.have.property('count'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('total'); + }) + .end(done); + }); }); describe('/channels.roles', () => { @@ -1714,6 +1833,24 @@ describe('[Channels]', function () { .end(done); }); }); + it('should return the messages list when the setting "Accounts_AllowAnonymousRead" is enabled even requested with count and offset params', (done) => { + updateSetting('Accounts_AllowAnonymousRead', true).then(() => { + request + .get(api('channels.anonymousread')) + .query({ + roomId: 'GENERAL', + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.a.property('success', true); + expect(res.body).to.have.a.property('messages').that.is.an('array'); + }) + .end(done); + }); + }); }); describe('/channels.convertToTeam', () => { diff --git a/apps/meteor/tests/end-to-end/api/03-groups.js b/apps/meteor/tests/end-to-end/api/03-groups.js index 9a7ffc64c3ad..3e5bd508dacb 100644 --- a/apps/meteor/tests/end-to-end/api/03-groups.js +++ b/apps/meteor/tests/end-to-end/api/03-groups.js @@ -227,6 +227,27 @@ describe('[Groups]', function () { }) .end(done); }); + it('should return all groups messages where the last message of array should have the "star" array with USERS star ONLY even requested with count and offset params', (done) => { + request + .get(api('groups.messages')) + .set(credentials) + .query({ + roomId: testGroup._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('messages').and.to.be.an('array'); + const { messages } = res.body; + const lastMessage = messages.filter((message) => message._id === groupMessage._id)[0]; + expect(lastMessage).to.have.property('starred').and.to.be.an('array'); + expect(lastMessage.starred[0]._id).to.be.equal(adminUsername); + }) + .end(done); + }); }); it('/groups.invite', async () => { @@ -503,20 +524,39 @@ describe('[Groups]', function () { }); }); - it('/groups.history', (done) => { - request - .get(api('groups.history')) - .set(credentials) - .query({ - roomId: group._id, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - expect(res.body).to.have.property('messages'); - }) - .end(done); + describe('/groups.history', () => { + it('should return groups history when searching by roomId', (done) => { + request + .get(api('groups.history')) + .set(credentials) + .query({ + roomId: group._id, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('messages'); + }) + .end(done); + }); + it('should return groups history when searching by roomId even requested with count and offset params', (done) => { + request + .get(api('groups.history')) + .set(credentials) + .query({ + roomId: group._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('messages'); + }) + .end(done); + }); }); it('/groups.archive', (done) => { @@ -705,43 +745,86 @@ describe('[Groups]', function () { }); }); }); - - it('/groups.members', (done) => { - request - .get(api('groups.members')) - .set(credentials) - .query({ - roomId: group._id, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - expect(res.body).to.have.property('count'); - expect(res.body).to.have.property('total'); - expect(res.body).to.have.property('offset'); - expect(res.body).to.have.property('members').and.to.be.an('array'); - }) - .end(done); + describe('/groups.files', () => { + it('should return group members when searching by roomId', (done) => { + request + .get(api('groups.members')) + .set(credentials) + .query({ + roomId: group._id, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('count'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('members').and.to.be.an('array'); + }) + .end(done); + }); + it('should return group members when searching by roomId even requested with count and offset params', (done) => { + request + .get(api('groups.members')) + .set(credentials) + .query({ + roomId: group._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('count'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('members').and.to.be.an('array'); + }) + .end(done); + }); }); - it('/groups.files', (done) => { - request - .get(api('groups.files')) - .set(credentials) - .query({ - roomId: group._id, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - expect(res.body).to.have.property('count'); - expect(res.body).to.have.property('total'); - expect(res.body).to.have.property('offset'); - expect(res.body).to.have.property('files').and.to.be.an('array'); - }) - .end(done); + describe('/groups.files', () => { + it('should return group files when searching by roomId', (done) => { + request + .get(api('groups.files')) + .set(credentials) + .query({ + roomId: group._id, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('count'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('files').and.to.be.an('array'); + }) + .end(done); + }); + it('should return group files when searching by roomId even requested with count and offset params', (done) => { + request + .get(api('groups.files')) + .set(credentials) + .query({ + roomId: group._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('count'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('files').and.to.be.an('array'); + }) + .end(done); + }); }); describe('/groups.listAll', () => { diff --git a/apps/meteor/tests/end-to-end/api/05-chat.js b/apps/meteor/tests/end-to-end/api/05-chat.js index de689e8bfef6..4b7720913ad1 100644 --- a/apps/meteor/tests/end-to-end/api/05-chat.js +++ b/apps/meteor/tests/end-to-end/api/05-chat.js @@ -2153,6 +2153,26 @@ describe('[Chat]', function () { }) .end(done); }); + it('should return the discussions of a room even requested with count and offset params', (done) => { + request + .get(api('chat.getDiscussions')) + .set(credentials) + .query({ + roomId: 'GENERAL', + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body.messages).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'); + }) + .end(done); + }); function filterDiscussionsByText(text) { it(`should return the room's discussion list filtered by the text '${text}'`, (done) => { @@ -2176,6 +2196,30 @@ describe('[Chat]', function () { }) .end(done); }); + + it(`should return the room's discussion list filtered by the text '${text}' even requested with count and offset params`, (done) => { + request + .get(api('chat.getDiscussions')) + .set(credentials) + .query({ + roomId: testChannel._id, + text, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('messages').and.to.be.an('array'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('count'); + expect(res.body.messages).to.have.lengthOf(1); + expect(res.body.messages[0].drid).to.be.equal(discussionRoom.rid); + }) + .end(done); + }); } messageWords.forEach((text) => { @@ -2318,6 +2362,31 @@ describe('Threads', () => { }); }); + it("should return the room's thread list even requested with count and offset params", (done) => { + updatePermission('view-c-room', ['admin', 'user']).then(() => { + request + .get(api('chat.getThreadsList')) + .set(credentials) + .query({ + rid: testChannel._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('threads').and.to.be.an('array'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('count'); + expect(res.body.threads).to.have.lengthOf(1); + expect(res.body.threads[0]._id).to.be.equal(threadMessage.tmid); + }) + .end(done); + }); + }); + function filterThreadsByText(text) { it(`should return the room's thread list filtered by the text '${text}'`, (done) => { request @@ -2340,6 +2409,29 @@ describe('Threads', () => { }) .end(done); }); + it(`should return the room's thread list filtered by the text '${text}' even requested with count and offset params`, (done) => { + request + .get(api('chat.getThreadsList')) + .set(credentials) + .query({ + rid: testChannel._id, + text, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('threads').and.to.be.an('array'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('count'); + expect(res.body.threads).to.have.lengthOf(1); + expect(res.body.threads[0]._id).to.be.equal(threadMessage.tmid); + }) + .end(done); + }); } messageWords.forEach((text) => { diff --git a/apps/meteor/tests/end-to-end/api/08-settings.js b/apps/meteor/tests/end-to-end/api/08-settings.js index 61e48cd8e456..3753e9e4394e 100644 --- a/apps/meteor/tests/end-to-end/api/08-settings.js +++ b/apps/meteor/tests/end-to-end/api/08-settings.js @@ -20,6 +20,22 @@ describe('[Settings]', function () { }) .end(done); }); + it('should return public settings even requested with count and offset params', (done) => { + request + .get(api('settings.public')) + .query({ + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('settings'); + expect(res.body).to.have.property('count'); + }) + .end(done); + }); }); describe('[/settings]', () => { diff --git a/apps/meteor/tests/end-to-end/api/09-rooms.js b/apps/meteor/tests/end-to-end/api/09-rooms.js index 0bc97d9bbf65..ec168a7104ce 100644 --- a/apps/meteor/tests/end-to-end/api/09-rooms.js +++ b/apps/meteor/tests/end-to-end/api/09-rooms.js @@ -954,6 +954,52 @@ describe('[Rooms]', function () { .end(done); }); }); + describe('[/rooms.autocomplete.channelAndPrivate.withPagination]', () => { + it('should return an error when the required parameter "selector" is not provided', (done) => { + request + .get(api('rooms.autocomplete.channelAndPrivate.withPagination')) + .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.withPagination?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'); + expect(res.body).to.have.property('total'); + }) + .end(done); + }); + it('should return the rooms to fill auto complete even requested with count and offset params', (done) => { + request + .get(api('rooms.autocomplete.channelAndPrivate.withPagination?selector={}')) + .set(credentials) + .query({ + count: 5, + offset: 0, + }) + .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('total'); + }) + .end(done); + }); + }); + describe('[/rooms.autocomplete.availableForTeams]', () => { it('should return the rooms to fill auto complete', (done) => { request @@ -1071,6 +1117,24 @@ describe('[Rooms]', function () { }) .end(done); }); + it('should return a list of admin rooms even requested with count and offset params', (done) => { + request + .get(api('rooms.adminRooms')) + .set(credentials) + .query({ + count: 5, + offset: 0, + }) + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('rooms').and.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'); + }) + .end(done); + }); }); describe('update group dms name', () => { diff --git a/apps/meteor/tests/end-to-end/api/12-emoji-custom.js b/apps/meteor/tests/end-to-end/api/12-emoji-custom.js index f4fc4df56470..a9a088985ae7 100644 --- a/apps/meteor/tests/end-to-end/api/12-emoji-custom.js +++ b/apps/meteor/tests/end-to-end/api/12-emoji-custom.js @@ -263,6 +263,23 @@ describe('[EmojiCustom]', function () { }) .end(done); }); + it('should return emojis even requested with count and offset params', (done) => { + request + .get(api('emoji-custom.all')) + .set(credentials) + .query({ + count: 5, + offset: 0, + }) + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('emojis').and.to.be.an('array'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('count'); + }) + .end(done); + }); }); describe('[/emoji-custom.delete]', () => { diff --git a/apps/meteor/tests/end-to-end/api/16-commands.js b/apps/meteor/tests/end-to-end/api/16-commands.js index 1671abda739f..70c0e90f0dae 100644 --- a/apps/meteor/tests/end-to-end/api/16-commands.js +++ b/apps/meteor/tests/end-to-end/api/16-commands.js @@ -70,6 +70,24 @@ describe('[Commands]', function () { }) .end(done); }); + it('should return a list of commands even requested with count and offset params', (done) => { + request + .get(api('commands.list')) + .set(credentials) + .query({ + count: 5, + offset: 0, + }) + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('count'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('commands').and.to.be.an('array'); + }) + .end(done); + }); }); describe('[/commands.run]', () => { diff --git a/apps/meteor/tests/end-to-end/api/17-custom-sounds.js b/apps/meteor/tests/end-to-end/api/17-custom-sounds.js index 34eca545f3f8..b0b2ba7e1029 100644 --- a/apps/meteor/tests/end-to-end/api/17-custom-sounds.js +++ b/apps/meteor/tests/end-to-end/api/17-custom-sounds.js @@ -21,5 +21,22 @@ describe('[CustomSounds]', function () { }) .end(done); }); + it('should return custom sounds even requested with count and offset params', (done) => { + request + .get(api('custom-sounds.list')) + .set(credentials) + .expect(200) + .query({ + count: 5, + offset: 0, + }) + .expect((res) => { + expect(res.body).to.have.property('sounds').and.to.be.an('array'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('count'); + }) + .end(done); + }); }); }); diff --git a/apps/meteor/tests/end-to-end/api/17-custom-user-status.js b/apps/meteor/tests/end-to-end/api/17-custom-user-status.js index 30734c90a526..d5d8951f2050 100644 --- a/apps/meteor/tests/end-to-end/api/17-custom-user-status.js +++ b/apps/meteor/tests/end-to-end/api/17-custom-user-status.js @@ -21,5 +21,22 @@ describe('[CustomUserStatus]', function () { }) .end(done); }); + it('should return custom user status even requested with count and offset params', (done) => { + request + .get(api('custom-user-status.list')) + .set(credentials) + .expect(200) + .query({ + count: 5, + offset: 0, + }) + .expect((res) => { + expect(res.body).to.have.property('statuses').and.to.be.an('array'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('count'); + }) + .end(done); + }); }); }); diff --git a/apps/meteor/tests/end-to-end/api/19-statistics.js b/apps/meteor/tests/end-to-end/api/19-statistics.js index 82ba16dc44a6..9f59936c807a 100644 --- a/apps/meteor/tests/end-to-end/api/19-statistics.js +++ b/apps/meteor/tests/end-to-end/api/19-statistics.js @@ -83,5 +83,25 @@ describe('[Statistics]', function () { .end(done); }); }); + it('should return an array with the statistics even requested with count and offset params', (done) => { + updatePermission('view-statistics', ['admin']).then(() => { + request + .get(api('statistics.list')) + .set(credentials) + .query({ + count: 5, + offset: 0, + }) + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('statistics').and.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'); + }) + .end(done); + }); + }); }); }); diff --git a/apps/meteor/tests/end-to-end/api/25-teams.js b/apps/meteor/tests/end-to-end/api/25-teams.js index 4b45f73ef5da..41722083e608 100644 --- a/apps/meteor/tests/end-to-end/api/25-teams.js +++ b/apps/meteor/tests/end-to-end/api/25-teams.js @@ -1350,6 +1350,27 @@ describe('[Teams]', () => { .end(done); }); }); + it('should return all rooms for public team even requested with count and offset params', (done) => { + updatePermission('view-all-team-channels', ['user']).then(() => { + request + .get(api('teams.listRooms')) + .set(testUserCredentials) + .query({ + teamId: publicTeam._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('rooms'); + expect(res.body.rooms).to.be.an('array'); + expect(res.body.rooms.length).to.equal(2); + }) + .end(done); + }); + }); it('should return public rooms for private team', (done) => { updatePermission('view-all-team-channels', []).then(() => { @@ -1372,6 +1393,29 @@ describe('[Teams]', () => { }); }); }); + it('should return public rooms for private team even requested with count and offset params', (done) => { + updatePermission('view-all-team-channels', []).then(() => { + updatePermission('view-all-teams', ['admin']).then(() => { + request + .get(api('teams.listRooms')) + .set(credentials) + .query({ + teamId: privateTeam._id, + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('rooms'); + expect(res.body.rooms).to.be.an('array'); + expect(res.body.rooms.length).to.equal(2); + }) + .end(done); + }); + }); + }); }); describe('/teams.updateRoom', () => { diff --git a/apps/meteor/tests/end-to-end/api/livechat/01-department.js b/apps/meteor/tests/end-to-end/api/livechat/01-department.js index a38baa5c716f..84822885ec63 100644 --- a/apps/meteor/tests/end-to-end/api/livechat/01-department.js +++ b/apps/meteor/tests/end-to-end/api/livechat/01-department.js @@ -56,6 +56,29 @@ describe('LIVECHAT - departments', function () { .end(done); }); }); + it('should return an array of departments even requested with count and offset params', (done) => { + updatePermission('view-l-room', ['admin']) + .then(() => updatePermission('view-livechat-departments', ['admin'])) + .then(() => { + request + .get(api('livechat/department')) + .set(credentials) + .query({ + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body.departments).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'); + }) + .end(done); + }); + }); }); describe('livechat/department/id', () => { diff --git a/apps/meteor/tests/end-to-end/api/livechat/custom-fields.js b/apps/meteor/tests/end-to-end/api/livechat/custom-fields.js index 50adcff68712..a9ef318921d2 100644 --- a/apps/meteor/tests/end-to-end/api/livechat/custom-fields.js +++ b/apps/meteor/tests/end-to-end/api/livechat/custom-fields.js @@ -44,6 +44,27 @@ describe('LIVECHAT - custom fields', function () { .end(done); }); }); + it('should return an array of custom fields even requested with count and offset params', (done) => { + updatePermission('view-l-room', ['admin']).then(() => { + request + .get(api('livechat/custom-fields')) + .set(credentials) + .query({ + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body.customFields).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'); + }) + .end(done); + }); + }); }); describe('livechat/custom-fields/id', () => { diff --git a/apps/meteor/tests/end-to-end/api/livechat/queue.js b/apps/meteor/tests/end-to-end/api/livechat/queue.js index c373af585c8a..1340517a0db7 100644 --- a/apps/meteor/tests/end-to-end/api/livechat/queue.js +++ b/apps/meteor/tests/end-to-end/api/livechat/queue.js @@ -44,5 +44,26 @@ describe('LIVECHAT - Queue', function () { .end(done); }); }); + it('should return an array of queued metrics even requested with count and offset params', (done) => { + updatePermission('view-l-room', ['admin']).then(() => { + request + .get(api('livechat/queue')) + .set(credentials) + .query({ + count: 5, + offset: 0, + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body.queue).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'); + }) + .end(done); + }); + }); }); });