diff --git a/packages/component-invite/src/routes/collectionsInvitations/get.js b/packages/component-invite/src/routes/collectionsInvitations/get.js index b4031f89fb221f93140e6f2a6eea6551629bc090..091890fe1b902375ff70383978c5354679524a69 100644 --- a/packages/component-invite/src/routes/collectionsInvitations/get.js +++ b/packages/component-invite/src/routes/collectionsInvitations/get.js @@ -25,12 +25,7 @@ module.exports = models => async (req, res) => { models.Team, ) - if (members === undefined) { - res.status(400).json({ - error: `The requested collection does not have a ${role} Team`, - }) - return - } + if (members === undefined) return res.status(200).json([]) // TO DO: handle case for when the invitationID is provided const membersData = members.map(async member => { diff --git a/packages/component-invite/src/tests/collectionsInvitations/get.test.js b/packages/component-invite/src/tests/collectionsInvitations/get.test.js index b92e412bfcfa68fabe24fce66e7b292fa603da5a..02af456f586966bca3c108701feae086d28709bc 100644 --- a/packages/component-invite/src/tests/collectionsInvitations/get.test.js +++ b/packages/component-invite/src/tests/collectionsInvitations/get.test.js @@ -74,7 +74,7 @@ describe('Get collection invitations route handler', () => { const data = JSON.parse(res._getData()) expect(data.error).toEqual(`Role ${req.query.role} is invalid`) }) - it('should return an error when the collection does not have a the requested role team', async () => { + it('should return success with an empty array when the collection does not have a the requested role team', async () => { const { editorInChief, handlingEditor } = testFixtures.users const { collection } = testFixtures.collections const req = httpMocks.createRequest() @@ -87,10 +87,8 @@ describe('Get collection invitations route handler', () => { req.user = editorInChief.id const res = httpMocks.createResponse() await require(getPath)(models)(req, res) - expect(res.statusCode).toBe(400) + expect(res.statusCode).toBe(200) const data = JSON.parse(res._getData()) - expect(data.error).toEqual( - `The requested collection does not have a ${req.query.role} Team`, - ) + expect(data).toHaveLength(0) }) })