Skip to content

Commit 9db5177

Browse files
Merge pull request #1726 from Real-Dev-Squad/develop
Dev to main sync
2 parents c7fe2bd + 7270586 commit 9db5177

File tree

2 files changed

+37
-61
lines changed

2 files changed

+37
-61
lines changed

models/tasks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const fetchPaginatedTasks = async ({
159159
}
160160
}
161161
} else {
162-
initialQuery = tasksModel.orderBy("updatedAt", "desc");
162+
initialQuery = tasksModel.orderBy("title");
163163
if (status) {
164164
initialQuery = initialQuery.where("status", "==", status);
165165
}

test/integration/tasks.test.js

Lines changed: 36 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,6 @@ const superUser = userData[4];
2424

2525
let jwt, superUserJwt;
2626

27-
const taskData = [
28-
{
29-
title: "Test task",
30-
type: "feature",
31-
endsOn: 1234,
32-
startedOn: 4567,
33-
status: "IN_PROGRESS",
34-
percentCompleted: 10,
35-
participants: [],
36-
assignee: appOwner.username,
37-
completionAward: { [DINERO]: 3, [NEELAM]: 300 },
38-
lossRate: { [DINERO]: 1 },
39-
isNoteworthy: true,
40-
isCollapsed: true,
41-
},
42-
{
43-
title: "Test task",
44-
purpose: "To Test mocha",
45-
featureUrl: "<testUrl>",
46-
type: "group",
47-
links: ["test1"],
48-
endsOn: 1234,
49-
startedOn: 54321,
50-
status: "completed",
51-
percentCompleted: 10,
52-
dependsOn: ["d12", "d23"],
53-
participants: [appOwner.username],
54-
completionAward: { [DINERO]: 3, [NEELAM]: 300 },
55-
lossRate: { [DINERO]: 1 },
56-
isNoteworthy: false,
57-
assignee: appOwner.username,
58-
},
59-
];
60-
6127
describe("Tasks", function () {
6228
let taskId1, taskId;
6329

@@ -67,6 +33,40 @@ describe("Tasks", function () {
6733
jwt = authService.generateAuthToken({ userId });
6834
superUserJwt = authService.generateAuthToken({ userId: superUserId });
6935

36+
const taskData = [
37+
{
38+
title: "Test task",
39+
type: "feature",
40+
endsOn: 1234,
41+
startedOn: 4567,
42+
status: "IN_PROGRESS",
43+
percentCompleted: 10,
44+
participants: [],
45+
assignee: appOwner.username,
46+
completionAward: { [DINERO]: 3, [NEELAM]: 300 },
47+
lossRate: { [DINERO]: 1 },
48+
isNoteworthy: true,
49+
isCollapsed: true,
50+
},
51+
{
52+
title: "Test task",
53+
purpose: "To Test mocha",
54+
featureUrl: "<testUrl>",
55+
type: "group",
56+
links: ["test1"],
57+
endsOn: 1234,
58+
startedOn: 54321,
59+
status: "completed",
60+
percentCompleted: 10,
61+
dependsOn: ["d12", "d23"],
62+
participants: [appOwner.username],
63+
completionAward: { [DINERO]: 3, [NEELAM]: 300 },
64+
lossRate: { [DINERO]: 1 },
65+
isNoteworthy: false,
66+
assignee: appOwner.username,
67+
},
68+
];
69+
7070
// Add the active task
7171
taskId = (await tasks.updateTask(taskData[0])).taskId;
7272
taskId1 = taskId;
@@ -184,11 +184,6 @@ describe("Tasks", function () {
184184
});
185185

186186
describe("GET /tasks", function () {
187-
before(async function () {
188-
await tasks.updateTask({ ...taskData[0], createdAt: 1621717694, updatedAt: 1700680830 });
189-
await tasks.updateTask({ ...taskData[1], createdAt: 1621717694, updatedAt: 1700775753 });
190-
});
191-
192187
it("Should get all the list of tasks", function (done) {
193188
chai
194189
.request(app)
@@ -353,6 +348,7 @@ describe("Tasks", function () {
353348
if (err) {
354349
return done(err);
355350
}
351+
356352
expect(res).to.have.status(200);
357353
expect(res.body).to.be.a("object");
358354
expect(res.body.message).to.equal("Tasks returned successfully!");
@@ -413,7 +409,7 @@ describe("Tasks", function () {
413409
matchingTasks.forEach((task) => {
414410
expect(task.title.toLowerCase()).to.include(searchTerm.toLowerCase());
415411
});
416-
expect(matchingTasks).to.have.length(6);
412+
expect(matchingTasks).to.have.length(4);
417413

418414
return done();
419415
});
@@ -452,26 +448,6 @@ describe("Tasks", function () {
452448
return done();
453449
});
454450
});
455-
it("Should get paginated tasks ordered by updatedAt in desc order ", function (done) {
456-
chai
457-
.request(app)
458-
.get("/tasks?dev=true&size=5&page=0")
459-
.end((err, res) => {
460-
if (err) {
461-
return done(err);
462-
}
463-
expect(res).to.have.status(200);
464-
expect(res.body).to.be.a("object");
465-
expect(res.body.message).to.equal("Tasks returned successfully!");
466-
expect(res.body.tasks).to.be.a("array");
467-
const tasks = res.body.tasks;
468-
// Check if Tasks are returned in desc order of updatedAt field
469-
for (let i = 0; i < tasks.length - 1; i++) {
470-
expect(tasks[+i].updatedAt).to.be.greaterThanOrEqual(tasks[i + 1].updatedAt);
471-
}
472-
return done();
473-
});
474-
});
475451
});
476452

477453
describe("GET /tasks/:id/details", function () {

0 commit comments

Comments
 (0)