Skip to content

Commit 3451f24

Browse files
Merge pull request #992 from Real-Dev-Squad/feat/cpllapsed-task
add isCollapsed field
2 parents 99c175c + cf1888c commit 3451f24

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

middlewares/validators/tasks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const createTask = async (req, res, next) => {
4242
})
4343
.optional(),
4444
isNoteworthy: joi.bool().optional(),
45+
isCollapsed: joi.bool().optional(),
4546
github: joi
4647
.object()
4748
.keys({
@@ -101,6 +102,7 @@ const updateTask = async (req, res, next) => {
101102
})
102103
.optional(),
103104
isNoteworthy: joi.bool().optional(),
105+
isCollapsed: joi.bool().optional(),
104106
});
105107
try {
106108
await schema.validateAsync(req.body);

services/contributions.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,19 @@ const extractPRdetails = (data) => {
103103
*/
104104

105105
const extractTaskdetails = (data) => {
106-
const { id, title, purpose, endsOn, startedOn, dependsOn, status, participants, featureUrl, isNoteworthy } = data;
106+
const {
107+
id,
108+
title,
109+
purpose,
110+
endsOn,
111+
startedOn,
112+
dependsOn,
113+
status,
114+
participants,
115+
featureUrl,
116+
isNoteworthy,
117+
isCollapsed,
118+
} = data;
107119
return {
108120
id,
109121
title,
@@ -115,6 +127,7 @@ const extractTaskdetails = (data) => {
115127
participants,
116128
featureUrl,
117129
isNoteworthy,
130+
isCollapsed,
118131
};
119132
};
120133

test/integration/tasks.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe("Tasks", function () {
4444
completionAward: { [DINERO]: 3, [NEELAM]: 300 },
4545
lossRate: { [DINERO]: 1 },
4646
isNoteworthy: true,
47+
isCollapsed: true,
4748
},
4849
{
4950
title: "Test task",
@@ -185,6 +186,19 @@ describe("Tasks", function () {
185186
return done();
186187
});
187188
});
189+
it("Should return isCollapsed property in response", function (done) {
190+
chai
191+
.request(app)
192+
.get(`/tasks/${taskId1}/details`)
193+
.end((err, res) => {
194+
if (err) {
195+
return done(err);
196+
}
197+
198+
expect(res.body.taskData).to.have.property("isCollapsed");
199+
return done();
200+
});
201+
});
188202
});
189203

190204
describe("GET /tasks/self", function () {
@@ -290,6 +304,23 @@ describe("Tasks", function () {
290304
return done();
291305
});
292306
});
307+
it("Should update the task status collapsed for the given taskid", function (done) {
308+
chai
309+
.request(app)
310+
.patch("/tasks/" + taskId1)
311+
.set("cookie", `${cookieName}=${jwt}`)
312+
.send({
313+
isCollapsed: true,
314+
})
315+
.end((err, res) => {
316+
if (err) {
317+
return done(err);
318+
}
319+
expect(res).to.have.status(204);
320+
321+
return done();
322+
});
323+
});
293324
it("Should return fail response if task data has a non-acceptable status value to update the task for the given taskid", function (done) {
294325
chai
295326
.request(app)

0 commit comments

Comments
 (0)