Skip to content

Commit 1cddb3b

Browse files
intyrocharitymarani
authored andcommitted
fix(incident): fix assignee on incident timeline
1 parent 7c63683 commit 1cddb3b

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/server/helpers/incidentHelper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ const updateAssignedOrCcdUser = async (
193193
},
194194
});
195195

196-
await handleCCUpdateNotification(req, ccdUser, incident.id, '');
196+
if (ccdUser && ccdUser.length > 0) {
197+
await handleCCUpdateNotification(req, ccdUser, incident.id, '');
198+
}
197199

198200
return selectedUser.action({ ...selectedUser.arguments, incident, res });
199201
};
@@ -210,7 +212,6 @@ const updateIncident = async (incident, req, res) => {
210212
categoryId: req.body.categoryId || incident.categoryId,
211213
levelId: req.body.levelId || incident.levelId,
212214
});
213-
214215
return res.status(200).send({ data: incident, status: 'success' });
215216
};
216217

src/tests/incidents.spec.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,36 @@ describe('Incident Tests', () => {
8080
});
8181
});
8282
});
83-
84-
it('should update an incident provided an existing incident ID', done => {
83+
it('should update an incident when someone gets assigned to the incident', done => {
8584
sendRequest('post', incidentsEndpoint, testIncident, (err, res) => {
86-
const updateIncidentUrl = '/api/incidents/' + res.body.data.id;
85+
const { id } = res.body.data;
86+
const updateIncidentUrl = '/api/incidents/' + id;
8787
sendRequest(
8888
'put',
8989
updateIncidentUrl,
90-
{ ...testIncident, statusId: 3 },
90+
{
91+
...testIncident,
92+
ccd: [
93+
{
94+
userId: 'cjl6fecrb11115vf09xly2f65',
95+
incidentId: id,
96+
},
97+
],
98+
assignee: {
99+
userId: 'cjl6egyei00005dnytqp4a06l',
100+
incidentId: id,
101+
},
102+
},
91103
(error, response) => {
92-
expect(response.body.data.statusId).toEqual(3);
104+
expect(response.body.status).toEqual('success');
93105
done();
94106
}
95107
);
96108
});
97109
});
98-
99-
it('should update an incident when someone gets assigned to it', done => {
110+
it('should update an incident when someone gets ccd to it', done => {
100111
makeServerCall(assigneeRequestBody, done, 'put');
101112
});
102-
103113
it('should update an incident when someone gets ccd to it', done => {
104114
makeServerCall(ccdRequestBody, done, 'put');
105115
});

0 commit comments

Comments
 (0)