Skip to content

Commit

Permalink
chore: remove feature flag for GET /requests API
Browse files Browse the repository at this point in the history
  • Loading branch information
samarpan1738 committed Sep 20, 2024
1 parent 0d6d058 commit 0fef690
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion controllers/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const getRequestsController = async (req: any, res: any) => {
}

if (page) {
const pageLink = `/requests?page=${page}&dev=${query.dev}`;
const pageLink = `/requests?page=${page}`;
return res.status(200).json({
message: REQUEST_FETCHED_SUCCESSFULLY,
data: allRequests,
Expand Down
2 changes: 1 addition & 1 deletion middlewares/validators/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const updateRequestsMiddleware = async (

export const getRequestsMiddleware = async (req: OooRequestCreateRequest, res: OooRequestResponse, next: NextFunction) => {
const schema = joi.object().keys({
dev: joi.bool().sensitive(), // TODO: Remove this validator once feature is tested and ready to be used
dev: joi.bool().sensitive().optional(), // TODO: Remove this validator once feature is tested and ready to be used
id: joi.string().optional(),
type: joi
.string()
Expand Down
18 changes: 9 additions & 9 deletions test/integration/requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ describe("/requests OOO", function () {
it("should return all requests", function (done) {
chai
.request(app)
.get("/requests?dev=true")
.get("/requests")
.end(function (err, res) {
expect(res).to.have.status(200);
expect(res.body.data).to.have.lengthOf(2);
Expand All @@ -304,7 +304,7 @@ describe("/requests OOO", function () {
it("should return all requests by specific user", function (done) {
chai
.request(app)
.get(`/requests?dev=true&requestedBy=${userData[16].username}`)
.get(`/requests?requestedBy=${userData[16].username}`)
.end(function (err, res) {
expect(res).to.have.status(200);
expect(res.body.data.every((request: any) => request.requestedBy === testUserId));
Expand All @@ -315,7 +315,7 @@ describe("/requests OOO", function () {
it("should return all requests by specific user and state", function (done) {
chai
.request(app)
.get(`/requests?dev=true&state=APPROVED&requestedBy=${userData[16].username}`)
.get(`/requests?state=APPROVED&requestedBy=${userData[16].username}`)
.end(function (err, res) {
expect(res).to.have.status(200);
expect(res.body.data.every((e: any) => e.state === "APPROVED"));
Expand All @@ -327,7 +327,7 @@ describe("/requests OOO", function () {
it("should return request of type OOO", function (done) {
chai
.request(app)
.get("/requests?dev=true&type=OOO")
.get("/requests?type=OOO")
.end(function (err, res) {
expect(res).to.have.status(200);
expect(res.body.data.every((e: any) => e.type === "OOO"));
Expand All @@ -338,7 +338,7 @@ describe("/requests OOO", function () {
it("should return empty array is no data is found, for specific state and user", function (done) {
chai
.request(app)
.get("/requests?dev=true&requestedBy=testUser2&state=APPROVED")
.get("/requests?requestedBy=testUser2&state=APPROVED")
.end(function (err, res) {
expect(res).to.have.status(204);
done();
Expand All @@ -348,7 +348,7 @@ describe("/requests OOO", function () {
it("should return empty array is no data is found", function (done) {
chai
.request(app)
.get("/requests?dev=true&requestedBy=testUserRandom")
.get("/requests?requestedBy=testUserRandom")
.end(function (err, res) {
expect(res).to.have.status(204);
done();
Expand All @@ -358,7 +358,7 @@ describe("/requests OOO", function () {
it("should throw error if request id doesn't match", function (done) {
chai
.request(app)
.get("/requests?dev=true&id=ramdonId1")
.get("/requests?id=ramdonId1")
.end(function (err, res) {
expect(res).to.have.status(204);
done();
Expand All @@ -368,7 +368,7 @@ describe("/requests OOO", function () {
it("should return error if not a valid state is passed", function (done) {
chai
.request(app)
.get("/requests?dev=true&state=ACTIVE")
.get("/requests?state=ACTIVE")
.end(function (err, res) {
expect(res).to.have.status(400);
expect(res.body.error).to.equal("Bad Request");
Expand All @@ -380,7 +380,7 @@ describe("/requests OOO", function () {
it("should return error if not a valid type is passed", function (done) {
chai
.request(app)
.get("/requests?dev=true&type=RANDOM")
.get("/requests?type=RANDOM")
.end(function (err, res) {
expect(res).to.have.status(400);
expect(res.body.error).to.equal("Bad Request");
Expand Down
5 changes: 1 addition & 4 deletions test/unit/middlewares/requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ describe("Create Request Validators", function () {
describe("Get Request Validator", function () {
it("Should pass validation for a valid get request", async function () {
req = {
query: {
dev: "true",
},
query: {},
};
res = {};
await getRequestsMiddleware(req as any, res as any, nextSpy);
Expand All @@ -105,7 +103,6 @@ describe("Create Request Validators", function () {
it("Should throw an error for an invalid get request", async function () {
req = {
query: {
dev: "true",
type: "RANDOM",
state: "RANDOM",
},
Expand Down

0 comments on commit 0fef690

Please sign in to comment.