Skip to content

Commit bde2a97

Browse files
authored
Revert "Replace 'COMPLETED' with 'DONE' in Backend from 'updateTaskStatus' Function (#1644)" (#1652)
This reverts commit b66cc29.
1 parent 46623d1 commit bde2a97

File tree

2 files changed

+4
-69
lines changed

2 files changed

+4
-69
lines changed

controllers/tasks.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ const updateTaskStatus = async (req, res, next) => {
312312
try {
313313
let userStatusUpdate;
314314
const taskId = req.params.id;
315-
const { userStatusFlag } = req.query;
315+
const { dev } = req.query;
316316
const { id: userId, username } = req.userData;
317317
const task = await tasks.fetchSelfTask(taskId, userId);
318318

@@ -321,28 +321,12 @@ const updateTaskStatus = async (req, res, next) => {
321321
if (task.taskData.status === TASK_STATUS.VERIFIED || req.body.status === TASK_STATUS.MERGED)
322322
return res.boom.forbidden("Status cannot be updated. Please contact admin.");
323323

324-
if (userStatusFlag) {
325-
if (task.taskData.status === TASK_STATUS.DONE && req.body.percentCompleted < 100) {
326-
if (req.body.status === TASK_STATUS.DONE || !req.body.status) {
327-
return res.boom.badRequest("Task percentCompleted can't updated as status is DONE");
328-
}
329-
}
330-
331-
if (
332-
(req.body.status === TASK_STATUS.DONE || req.body.status === TASK_STATUS.VERIFIED) &&
333-
task.taskData.percentCompleted !== 100
334-
) {
335-
if (req.body.percentCompleted !== 100) {
336-
return res.boom.badRequest("Status cannot be updated. Task is not done yet");
337-
}
338-
}
339-
}
340-
341324
if (task.taskData.status === TASK_STATUS.COMPLETED && req.body.percentCompleted < 100) {
342325
if (req.body.status === TASK_STATUS.COMPLETED || !req.body.status) {
343326
return res.boom.badRequest("Task percentCompleted can't updated as status is COMPLETED");
344327
}
345328
}
329+
346330
if (
347331
(req.body.status === TASK_STATUS.COMPLETED || req.body.status === TASK_STATUS.VERIFIED) &&
348332
task.taskData.percentCompleted !== 100
@@ -383,8 +367,8 @@ const updateTaskStatus = async (req, res, next) => {
383367
]);
384368
taskLog.id = taskLogResult.id;
385369

386-
if (userStatusFlag) {
387-
if (req.body.percentCompleted === 100 && req.body.status === "DONE") {
370+
if (dev) {
371+
if (req.body.percentCompleted === 100) {
388372
return next();
389373
}
390374
}

test/integration/tasks.test.js

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -945,18 +945,6 @@ describe("Tasks", function () {
945945
expect(res.body.message).to.be.equal("Status cannot be updated. Task is not completed yet");
946946
});
947947

948-
it("Should give 400 if percentCompleted is not 100 and new status is DONE under feature flag ", async function () {
949-
taskId = (await tasks.updateTask({ ...taskData, status: "REVIEW", assignee: appOwner.username })).taskId;
950-
const res = await chai
951-
.request(app)
952-
.patch(`/tasks/self/${taskId}?userStatusFlag=true`)
953-
.set("cookie", `${cookieName}=${jwt}`)
954-
.send({ ...taskStatusData, status: "DONE" });
955-
956-
expect(res).to.have.status(400);
957-
expect(res.body.message).to.be.equal("Status cannot be updated. Task is not done yet");
958-
});
959-
960948
it("Should give 400 if percentCompleted is not 100 and new status is VERIFIED ", async function () {
961949
taskId = (await tasks.updateTask({ ...taskData, status: "REVIEW", assignee: appOwner.username })).taskId;
962950
const res = await chai
@@ -969,18 +957,6 @@ describe("Tasks", function () {
969957
expect(res.body.message).to.be.equal("Status cannot be updated. Task is not completed yet");
970958
});
971959

972-
it("Should give 400 if percentCompleted is not 100 and new status is VERIFIED under feature flag", async function () {
973-
taskId = (await tasks.updateTask({ ...taskData, status: "REVIEW", assignee: appOwner.username })).taskId;
974-
const res = await chai
975-
.request(app)
976-
.patch(`/tasks/self/${taskId}?userStatusFlag=true`)
977-
.set("cookie", `${cookieName}=${jwt}`)
978-
.send({ ...taskStatusData, status: "VERIFIED" });
979-
980-
expect(res).to.have.status(400);
981-
expect(res.body.message).to.be.equal("Status cannot be updated. Task is not done yet");
982-
});
983-
984960
it("Should give 400 if status is COMPLETED and newpercent is less than 100", async function () {
985961
const taskData = {
986962
title: "Test task",
@@ -1005,31 +981,6 @@ describe("Tasks", function () {
1005981
expect(res).to.have.status(400);
1006982
expect(res.body.message).to.be.equal("Task percentCompleted can't updated as status is COMPLETED");
1007983
});
1008-
1009-
it("Should give 400 if status is COMPLETED and newpercent is less than 100 under feature flag", async function () {
1010-
const taskData = {
1011-
title: "Test task",
1012-
type: "feature",
1013-
endsOn: 1234,
1014-
startedOn: 4567,
1015-
status: "DONE",
1016-
percentCompleted: 100,
1017-
participants: [],
1018-
assignee: appOwner.username,
1019-
completionAward: { [DINERO]: 3, [NEELAM]: 300 },
1020-
lossRate: { [DINERO]: 1 },
1021-
isNoteworthy: true,
1022-
};
1023-
taskId = (await tasks.updateTask(taskData)).taskId;
1024-
const res = await chai
1025-
.request(app)
1026-
.patch(`/tasks/self/${taskId}?userStatusFlag=true`)
1027-
.set("cookie", `${cookieName}=${jwt}`)
1028-
.send({ percentCompleted: 80 });
1029-
1030-
expect(res).to.have.status(400);
1031-
expect(res.body.message).to.be.equal("Task percentCompleted can't updated as status is DONE");
1032-
});
1033984
});
1034985

1035986
describe("GET /tasks/overdue", function () {

0 commit comments

Comments
 (0)