Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#167455129 fix incident assignment #208

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/server/helpers/incidentHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
};
Expand All @@ -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' });
};

Expand Down
58 changes: 52 additions & 6 deletions src/tests/incidents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,61 @@ 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 { id } = res.body.data;
const updateIncidentUrl = '/api/incidents/' + id;
sendRequest(
'put',
updateIncidentUrl,
{
...testIncident,
assignee: {
userId: 'cjl6egyei00005dnytqp4a06l',
incidentId: id,
},
},
(error, response) => {
expect(response.body.status).toEqual('success');
done();
}
);
});
});
it('should update an incident when someone gets ccd to the incident', done => {
sendRequest('post', incidentsEndpoint, testIncident, (err, res) => {
const { id } = res.body.data;
const updateIncidentUrl = '/api/incidents/' + id;
sendRequest(
'put',
updateIncidentUrl,
{
...testIncident,
ccd: [
{
userId: 'cjl6fecrb11115vf09xly2f65',
incidentId: id,
},
],
},
(error, response) => {
expect(response.body.status).toEqual('success');
done();
}
);
});
});
it('should update an incident when the status is updated', 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,
statusId: 3,
},
(error, response) => {
expect(response.body.data.statusId).toEqual(3);
done();
Expand All @@ -96,10 +143,9 @@ describe('Incident Tests', () => {
});
});

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');
});
Expand Down