diff --git a/controllers/requests.ts b/controllers/requests.ts index 9d7d7eacb..fd8974ea0 100644 --- a/controllers/requests.ts +++ b/controllers/requests.ts @@ -60,6 +60,13 @@ export const getRequestsController = async (req: any, res: any) => { return res.status(204).send(); } + if (query.id) { + return res.status(200).json({ + message: REQUEST_FETCHED_SUCCESSFULLY, + data: requests, + }); + } + const { allRequests, next, prev, page } = requests; if (allRequests.length === 0) { return res.status(204).send(); diff --git a/test/integration/requests.test.ts b/test/integration/requests.test.ts index faa96ef82..0d6fe74c2 100644 --- a/test/integration/requests.test.ts +++ b/test/integration/requests.test.ts @@ -273,6 +273,17 @@ describe("/requests OOO", function () { }); }); + it("should return the request by Id query", function (done) { + chai + .request(app) + .get(`/requests?id=${oooRequestId}`) + .end(function (err, res) { + expect(res).to.have.status(200); + expect(res.body.data.id === oooRequestId); + done(); + }); + }); + it("should return all requests by specific user", function (done) { chai .request(app)