diff --git a/src/server/helpers/incidentHelper.js b/src/server/helpers/incidentHelper.js index 0857f3bf..1c996c20 100644 --- a/src/server/helpers/incidentHelper.js +++ b/src/server/helpers/incidentHelper.js @@ -193,7 +193,9 @@ const updateAssignedOrCcdUser = async ( }, }); - await handleCCUpdateNotification(req, ccdUser, incident.id, ''); + if (ccdUser && ccdUser.length > 0) { + await handleCCUpdateNotification(req, ccdUser, incident.id, ''); + } return selectedUser.action({ ...selectedUser.arguments, incident, res }); }; @@ -210,7 +212,6 @@ const updateIncident = async (incident, req, res) => { categoryId: req.body.categoryId || incident.categoryId, levelId: req.body.levelId || incident.levelId, }); - return res.status(200).send({ data: incident, status: 'success' }); }; diff --git a/src/tests/incidents.spec.js b/src/tests/incidents.spec.js index 86669b06..f2e8a353 100644 --- a/src/tests/incidents.spec.js +++ b/src/tests/incidents.spec.js @@ -80,26 +80,36 @@ describe('Incident Tests', () => { }); }); }); - - it('should update an incident provided an existing incident ID', done => { + it('should update an incident when someone gets assigned to the incident', done => { sendRequest('post', incidentsEndpoint, testIncident, (err, res) => { - const updateIncidentUrl = '/api/incidents/' + res.body.data.id; + const { id } = res.body.data; + const updateIncidentUrl = '/api/incidents/' + id; sendRequest( 'put', updateIncidentUrl, - { ...testIncident, statusId: 3 }, + { + ...testIncident, + ccd: [ + { + userId: 'cjl6fecrb11115vf09xly2f65', + incidentId: id, + }, + ], + assignee: { + userId: 'cjl6egyei00005dnytqp4a06l', + incidentId: id, + }, + }, (error, response) => { - expect(response.body.data.statusId).toEqual(3); + expect(response.body.status).toEqual('success'); done(); } ); }); }); - - it('should update an incident when someone gets assigned to it', done => { + it('should update an incident when someone gets ccd to it', done => { makeServerCall(assigneeRequestBody, done, 'put'); }); - it('should update an incident when someone gets ccd to it', done => { makeServerCall(ccdRequestBody, done, 'put'); });