Skip to content

Commit

Permalink
fix: queuedForUser endpoint not filtering by status (#29189)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman authored and aleksandernsilva committed Jun 6, 2023
1 parent 00d3cbb commit fbe6905
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-coins-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: `queuedForUser` endpoint not filtering by status
3 changes: 2 additions & 1 deletion apps/meteor/app/livechat/server/api/lib/inquiries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export async function findInquiries({
};

const filter: Filter<ILivechatInquiryRecord> = {
...(status && status in LivechatInquiryStatus && { status }),
// V in Enum only works for numeric enums
...(status && Object.values(LivechatInquiryStatus).includes(status) && { status }),
$or: [
{
$and: [{ defaultAgent: { $exists: true } }, { 'defaultAgent.agentId': userId }],
Expand Down
16 changes: 15 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/05-inquiries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('LIVECHAT - inquiries', function () {
it('should return an array of inquiries', async () => {
await updatePermission('view-l-room', ['admin']);
await request
.get(api('livechat/inquiries.queued'))
.get(api('livechat/inquiries.queuedForUser'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
Expand All @@ -198,5 +198,19 @@ describe('LIVECHAT - inquiries', function () {
expect(res.body).to.have.property('count');
});
});
it('should validate all returned inquiries are queued', async () => {
await request
.get(api('livechat/inquiries.queuedForUser'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect(async (res: Response) => {
expect(res.body).to.have.property('success', true);
expect(res.body.inquiries).to.be.an('array');
for (const inquiry of res.body.inquiries) {
expect(inquiry).to.have.property('status', 'queued');
}
});
});
});
});

0 comments on commit fbe6905

Please sign in to comment.