Skip to content

Commit 987a643

Browse files
intyrocharitymarani
authored andcommitted
fix(incident): fix assignee on incident timeline
1 parent c799317 commit 987a643

2 files changed

Lines changed: 55 additions & 8 deletions

File tree

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: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,61 @@ 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 => {
84+
sendRequest('post', incidentsEndpoint, testIncident, (err, res) => {
85+
const { id } = res.body.data;
86+
const updateIncidentUrl = '/api/incidents/' + id;
87+
sendRequest(
88+
'put',
89+
updateIncidentUrl,
90+
{
91+
...testIncident,
92+
assignee: {
93+
userId: 'cjl6egyei00005dnytqp4a06l',
94+
incidentId: id,
95+
},
96+
},
97+
(error, response) => {
98+
expect(response.body.status).toEqual('success');
99+
done();
100+
}
101+
);
102+
});
103+
});
104+
it('should update an incident when someone gets ccd to the incident', done => {
105+
sendRequest('post', incidentsEndpoint, testIncident, (err, res) => {
106+
const { id } = res.body.data;
107+
const updateIncidentUrl = '/api/incidents/' + id;
108+
sendRequest(
109+
'put',
110+
updateIncidentUrl,
111+
{
112+
...testIncident,
113+
ccd: [
114+
{
115+
userId: 'cjl6fecrb11115vf09xly2f65',
116+
incidentId: id,
117+
},
118+
],
119+
},
120+
(error, response) => {
121+
expect(response.body.status).toEqual('success');
122+
done();
123+
}
124+
);
125+
});
126+
});
127+
it('should update an incident when the status is updated', done => {
85128
sendRequest('post', incidentsEndpoint, testIncident, (err, res) => {
86-
const updateIncidentUrl = '/api/incidents/' + res.body.data.id;
129+
const { id } = res.body.data;
130+
const updateIncidentUrl = '/api/incidents/' + id;
87131
sendRequest(
88132
'put',
89133
updateIncidentUrl,
90-
{ ...testIncident, statusId: 3 },
134+
{
135+
...testIncident,
136+
statusId: 3,
137+
},
91138
(error, response) => {
92139
expect(response.body.data.statusId).toEqual(3);
93140
done();
@@ -96,10 +143,9 @@ describe('Incident Tests', () => {
96143
});
97144
});
98145

99-
it('should update an incident when someone gets assigned to it', done => {
146+
it('should update an incident when someone gets ccd to it', done => {
100147
makeServerCall(assigneeRequestBody, done, 'put');
101148
});
102-
103149
it('should update an incident when someone gets ccd to it', done => {
104150
makeServerCall(ccdRequestBody, done, 'put');
105151
});

0 commit comments

Comments
 (0)