Skip to content

Commit ac8edca

Browse files
authored
added test cases for dev = false or when dev is not present
1 parent 6935c53 commit ac8edca

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/integration/tasks.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,10 @@ describe("Tasks", function () {
583583
return done;
584584
}
585585
expect(res).to.have.status(200);
586+
expect(res).to.have.header(
587+
"X-Deprecation-Warning",
588+
"WARNING: This endpoint is deprecated and will be removed in the future. Please use /tasks/:userId?dev=true&completed=true to get the updated profile details."
589+
);
586590
expect(res.body).to.be.a("array");
587591
expect(res.body[0].status).to.equal(COMPLETED);
588592

@@ -630,6 +634,10 @@ describe("Tasks", function () {
630634
.get("/tasks/self")
631635
.set("cookie", `${cookieName}=${authService.generateAuthToken({ userId: assignedUser })}`);
632636
expect(res).to.have.status(200);
637+
expect(res).to.have.header(
638+
"X-Deprecation-Warning",
639+
"WARNING: This endpoint is deprecated and will be removed in the future. Please use /tasks/:userId?dev=true to get the updated profile details."
640+
);
633641
expect(res.body).to.be.a("array");
634642
expect([taskId1, taskId2]).to.include(taskId1);
635643
});
@@ -1803,5 +1811,32 @@ describe("Tasks", function () {
18031811
message: "Unauthenticated User",
18041812
});
18051813
});
1814+
1815+
it("Should return 500 if the requested user is not the authenticated user or dev is false", async function () {
1816+
const { userId: authenticatedUserId } = await userModel.addOrUpdate({
1817+
github_id: "authenticated_user",
1818+
username: "auth_user",
1819+
});
1820+
1821+
const { userId: requestedUserId } = await userModel.addOrUpdate({
1822+
github_id: "requested_user",
1823+
username: "req_user",
1824+
});
1825+
1826+
const authToken = authService.generateAuthToken({ userId: authenticatedUserId });
1827+
1828+
const res = await chai
1829+
.request(app)
1830+
.get(`/tasks/v1/${requestedUserId}`)
1831+
.set("cookie", `${cookieName}=${authToken}`);
1832+
1833+
expect(res).to.have.status(500);
1834+
expect(res.body).to.be.an("object");
1835+
expect(res.body).to.eql({
1836+
statusCode: 500,
1837+
error: "Internal Server Error",
1838+
message: "An internal server error occurred",
1839+
});
1840+
});
18061841
});
18071842
});

0 commit comments

Comments
 (0)