From f5558892d479213facc494cc82d93e92c6b5707d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Albuquerque?= Date: Tue, 2 Aug 2022 12:17:45 -0300 Subject: [PATCH] [FIX] Empty results on `im.list` endpoint (#26438) Co-authored-by: Diego Sampaio <8591547+sampaiodiego@users.noreply.github.com> --- apps/meteor/app/api/server/v1/im.ts | 4 +-- .../tests/end-to-end/api/04-direct-message.js | 29 ++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/apps/meteor/app/api/server/v1/im.ts b/apps/meteor/app/api/server/v1/im.ts index a749a2da9b1..509713cb289 100644 --- a/apps/meteor/app/api/server/v1/im.ts +++ b/apps/meteor/app/api/server/v1/im.ts @@ -434,7 +434,7 @@ API.v1.addRoute( .toArray(); const { cursor, totalCount } = Rooms.findPaginated( - { type: 'd', _id: { $in: subscriptions } }, + { t: 'd', _id: { $in: subscriptions } }, { sort, skip: offset, @@ -451,7 +451,7 @@ API.v1.addRoute( return API.v1.success({ ims, offset, - count, + count: ims.length, total, }); }, diff --git a/apps/meteor/tests/end-to-end/api/04-direct-message.js b/apps/meteor/tests/end-to-end/api/04-direct-message.js index 3610b073c34..cc041ee030e 100644 --- a/apps/meteor/tests/end-to-end/api/04-direct-message.js +++ b/apps/meteor/tests/end-to-end/api/04-direct-message.js @@ -188,8 +188,18 @@ describe('[Direct Messages]', function () { .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('count', 1); + expect(res.body).to.have.property('total', 1); + expect(res.body).to.have.property('ims').and.to.be.an('array'); + const im = res.body.ims[0]; + expect(im).to.have.property('_id'); + expect(im).to.have.property('t').and.to.be.eq('d'); + expect(im).to.have.property('msgs').and.to.be.a('number'); + expect(im).to.have.property('usernames').and.to.be.an('array'); + expect(im).to.have.property('lm'); + expect(im).to.have.property('_updatedAt'); + expect(im).to.have.property('ts'); + expect(im).to.have.property('lastMessage'); }) .end(done); }); @@ -202,8 +212,19 @@ describe('[Direct Messages]', function () { .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('count', 1); + expect(res.body).to.have.property('total', 1); + expect(res.body).to.have.property('ims').and.to.be.an('array'); + const im = res.body.ims[0]; + expect(im).to.have.property('_id'); + expect(im).to.have.property('t').and.to.be.eq('d'); + expect(im).to.have.property('msgs').and.to.be.a('number'); + expect(im).to.have.property('usernames').and.to.be.an('array'); + expect(im).to.have.property('ro'); + expect(im).to.have.property('sysMes'); + expect(im).to.have.property('_updatedAt'); + expect(im).to.have.property('ts'); + expect(im).to.have.property('lastMessage'); }) .end(done); });