Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dev feature flag for GET /requests API #2151

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 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
7 changes: 1 addition & 6 deletions test/unit/middlewares/requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,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",
},
};
req = {};
samarpan1738 marked this conversation as resolved.
Show resolved Hide resolved
res = {};
await getRequestsMiddleware(req as any, res as any, nextSpy);
expect(nextSpy.calledOnce).to.equal(true);
Expand All @@ -105,7 +101,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
Loading