Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
17b1770
initial commit
RishiChaubey31 Aug 27, 2025
6269355
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Aug 30, 2025
4283cb5
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Aug 30, 2025
68b1b0e
added-more-test
RishiChaubey31 Aug 30, 2025
5e8bf8b
fix-test-title
RishiChaubey31 Aug 30, 2025
4c3af80
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Aug 31, 2025
59129c8
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 2, 2025
aa7c5b4
removed-try/catch-block
RishiChaubey31 Sep 2, 2025
b7006be
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 3, 2025
0c5e667
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 3, 2025
670ce52
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 3, 2025
1be02b9
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
MayankBansal12 Sep 3, 2025
aee173d
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 3, 2025
ea7d45c
fix-try-catch-cases
RishiChaubey31 Sep 3, 2025
d33fb0d
Merge branch 'test/ooo-req-acknowledgement' of https://github.com/Rea…
RishiChaubey31 Sep 3, 2025
799d37f
added-try-catch
RishiChaubey31 Sep 3, 2025
0b24360
removed-functon
RishiChaubey31 Sep 3, 2025
c1e3726
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
MayankBansal12 Sep 3, 2025
5237b38
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 3, 2025
e86ba92
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 4, 2025
6a811a7
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 4, 2025
3c566a2
test: update assertions in oooRequest tests to use include for respon…
RishiChaubey31 Sep 4, 2025
d1b4465
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 4, 2025
8c4b8be
Merge branch 'feature/ooo-req-acknowledgement' into test/ooo-req-ackn…
RishiChaubey31 Sep 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/fixtures/oooRequest/oooRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const createOooRequests3 = {
status: REQUEST_STATE.PENDING
};

export const acknowledgeOooRequest = {
export const TestAcknowledgeOooRequest = {
type: REQUEST_TYPE.OOO,
status: REQUEST_STATE.APPROVED,
comment: "OOO request approved as it's emergency."
Expand Down
24 changes: 12 additions & 12 deletions test/integration/requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
validOooStatusRequests,
validOooStatusUpdate,
createOooRequests2,
acknowledgeOooRequest,
TestAcknowledgeOooRequest,
createOooRequests3,
} from "../fixtures/oooRequest/oooRequest";
import { createRequest, updateRequest } from "../../models/requests";
Expand Down Expand Up @@ -351,7 +351,7 @@ describe("/requests OOO", function () {
chai
.request(app)
.patch(`/requests/${testOooRequest.id}?dev=true`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
expect(res).to.have.status(401);
expect(res.body.error).to.equal("Unauthorized");
Expand All @@ -365,7 +365,7 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/${testOooRequest.id}?dev=false`)
.set("cookie", `${cookieName}=${superUserToken}`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
if (err) {
return done(err);
Expand All @@ -381,7 +381,7 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/11111111111111?dev=true`)
.set("cookie", `${cookieName}=${superUserToken}`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
if (err) {
return done(err);
Expand All @@ -397,13 +397,13 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/${testOooRequest.id}?dev=true`)
.set("cookie", `${cookieName}=${authToken}`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
if (err) {
return done(err);
}
expect(res.statusCode).to.equal(403);
// expect(res.body.message).to.equal(UNAUTHORIZED_TO_ACKNOWLEDGE_OOO_REQUEST);
expect(res.body.message).to.equal(UNAUTHORIZED_TO_CREATE_OOO_REQUEST);
done();
});
});
Expand All @@ -413,7 +413,7 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/${approvedOooRequest.id}?dev=true`)
.set("cookie", `${cookieName}=${superUserToken}`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
if (err) {
return done(err);
Expand All @@ -429,7 +429,7 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/${rejectedOooRequest.id}?dev=true`)
.set("cookie", `${cookieName}=${superUserToken}`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
if (err) {
return done(err);
Expand All @@ -445,7 +445,7 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/${onboardingRequest.id}?dev=true`)
.set("cookie", `${cookieName}=${superUserToken}`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
if (err) {
return done(err);
Expand All @@ -461,7 +461,7 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/${testOooRequest.id}?dev=true`)
.set("cookie", `${cookieName}=${superUserToken}`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
if (err) {
return done(err);
Expand All @@ -477,7 +477,7 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/${testOooRequest.id}?dev=true`)
.set("cookie", `${cookieName}=${superUserToken}`)
.send({...acknowledgeOooRequest, status: REQUEST_STATE.REJECTED})
.send({...TestAcknowledgeOooRequest, status: REQUEST_STATE.REJECTED})
.end(function (err, res) {
if (err) {
return done(err);
Expand All @@ -494,7 +494,7 @@ describe("/requests OOO", function () {
.request(app)
.patch(`/requests/${testOooRequest.id}?dev=true`)
.set("cookie", `${cookieName}=${superUserToken}`)
.send(acknowledgeOooRequest)
.send(TestAcknowledgeOooRequest)
.end(function (err, res) {
if (err) return done(err);
expect(res.statusCode).to.equal(500);
Expand Down
37 changes: 24 additions & 13 deletions test/unit/middlewares/oooRequests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const { expect } = chai;

import {
createOooStatusRequestValidator,
// acknowledgeOOORequestsValidator,
acknowledgeOooRequestValidator,
} from "./../../../middlewares/validators/oooRequests";
import { acknowledgeOooRequest, validOooStatusRequests, validOooStatusUpdate } from "../../fixtures/oooRequest/oooRequest";
import { TestAcknowledgeOooRequest, validOooStatusRequests, validOooStatusUpdate } from "../../fixtures/oooRequest/oooRequest";
import _ from "lodash";
import { AcknowledgeOooRequest, OooRequestResponse } from "../../../types/oooRequest";

describe("OOO Status Request Validators", function () {
let req: any;
Expand Down Expand Up @@ -91,40 +92,50 @@ describe("OOO Status Request Validators", function () {
});
});

describe.skip("acknowledgeOOORequestsValidator", function () {
describe("acknowledgeOOORequestsValidator", function () {
it("should not validate for an invalid request for invalid request type", async function () {
req = {
body: { ...acknowledgeOooRequest, type: "XYZ"}
body: { ...TestAcknowledgeOooRequest, type: "XYZ"},
params: { id: "test-id" }
};

// await acknowledgeOOORequestsValidator(req, res, nextSpy);
expect(nextSpy.notCalled).to.be.true;
try {
await acknowledgeOooRequestValidator(req as AcknowledgeOooRequest, res as OooRequestResponse, nextSpy);
} catch (error) {
expect(nextSpy.notCalled).to.be.true;
}
});

it("should not validate for an invalid request if status is incorrect", async function () {
req = {
body: { ...acknowledgeOooRequest, status: "PENDING"}
body: { ...TestAcknowledgeOooRequest, status: "PENDING"},
params: { id: "test-id" }
};

// await acknowledgeOOORequestsValidator(req, res, nextSpy);
expect(nextSpy.notCalled).to.be.true;
try {
await acknowledgeOooRequestValidator(req as AcknowledgeOooRequest, res as OooRequestResponse, nextSpy);
} catch (error) {
expect(nextSpy.notCalled).to.be.true;
}
});

it("should validate for a valid acknowledge OOO request if comment not provided by superusers", async function() {
req = {
body: _.omit(acknowledgeOooRequest, "comment")
body: _.omit(TestAcknowledgeOooRequest, "comment"),
params: { id: "test-id" }
};
res = {};
// await acknowledgeOOORequestsValidator(req, res, nextSpy);
await acknowledgeOooRequestValidator(req as AcknowledgeOooRequest, res as OooRequestResponse, nextSpy);
expect(nextSpy.calledOnce).to.be.true;
});

it("should validate for a valid acknowledge OOO request", async function() {
req = {
body: acknowledgeOooRequest
body: TestAcknowledgeOooRequest,
params: { id: "test-id" }
};
res = {};
// await acknowledgeOOORequestsValidator(req, res, nextSpy);
await acknowledgeOooRequestValidator(req as AcknowledgeOooRequest, res as OooRequestResponse, nextSpy);
expect(nextSpy.calledOnce).to.be.true;
});
});
Expand Down
Loading
Loading