Skip to content

Commit

Permalink
fix: send 404 response when request does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajjs committed Jan 9, 2025
1 parent 10e2497 commit e548f24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions controllers/onboardingExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ONBOARDING_REQUEST_CREATED_SUCCESSFULLY,
REQUEST_ALREADY_PENDING,
REQUEST_APPROVED_SUCCESSFULLY,
REQUEST_DOES_NOT_EXIST,
REQUEST_LOG_TYPE,
REQUEST_REJECTED_SUCCESSFULLY,
REQUEST_STATE,
Expand Down Expand Up @@ -165,6 +166,9 @@ export const updateOnboardingExtensionRequestState = async (
const response = await updateRequest(extensionId, requestBody, lastModifiedBy, REQUEST_TYPE.ONBOARDING);

if ("error" in response) {
if (response.error === REQUEST_DOES_NOT_EXIST) {
return res.boom.notFound(response.error);
}
return res.boom.badRequest(response.error);
}

Expand Down
6 changes: 3 additions & 3 deletions test/integration/onboardingExtension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,16 @@ describe("/requests Onboarding Extension", () => {
})
})

it("should return 400 response for invalid extension id", (done) => {
it("should return 404 response for invalid extension id", (done) => {
chai.request(app)
.put(`/requests/1111?dev=true`)
.set("authorization", `Bearer ${authToken}`)
.send(body)
.end((err, res) => {
if (err) return done(err);
expect(res.statusCode).to.equal(400);
expect(res.statusCode).to.equal(404);
expect(res.body.message).to.equal("Request does not exist");
expect(res.body.error).to.equal("Bad Request");
expect(res.body.error).to.equal("Not Found");
done();
})
})
Expand Down

0 comments on commit e548f24

Please sign in to comment.