Skip to content

Commit

Permalink
refactor(cypress): read creds from env instead of hardcoding the path (
Browse files Browse the repository at this point in the history
…#4430)

Co-authored-by: gnanasundarig <gnanasundari.gopal@juspay.in>
  • Loading branch information
Pa1NarK and Gnanasundari24 committed Apr 30, 2024
1 parent 4718c17 commit 0c9ba1e
Show file tree
Hide file tree
Showing 43 changed files with 530 additions and 638 deletions.
2 changes: 1 addition & 1 deletion cypress-tests/.gitignore
@@ -1,2 +1,2 @@
creds.json
screenshots
screenshots
2 changes: 1 addition & 1 deletion cypress-tests/cypress.env.json
@@ -1 +1 @@
{}
{}
@@ -1,5 +1,5 @@
import merchantCreateBody from "../../fixtures/merchant-create-body.json";
import apiKeyCreateBody from "../../fixtures/create-api-key-body.json";
import merchantCreateBody from "../../fixtures/merchant-create-body.json";
import State from "../../utils/State";

let globalState;
Expand Down
@@ -1,8 +1,8 @@
import createPaymentBody from "../../fixtures/create-payment-body.json";
import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json";
import confirmBody from "../../fixtures/confirm-body.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand Down
@@ -1,7 +1,7 @@
import createPaymentBody from "../../fixtures/create-payment-body.json";
import confirmBody from "../../fixtures/confirm-body.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand Down
@@ -1,9 +1,9 @@
import createPaymentBody from "../../fixtures/create-payment-body.json";
import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json";
import captureBody from "../../fixtures/capture-flow-body.json";
import confirmBody from "../../fixtures/confirm-body.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import State from "../../utils/State";
import captureBody from "../../fixtures/capture-flow-body.json";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand Down
@@ -1,8 +1,8 @@
import createPaymentBody from "../../fixtures/create-payment-body.json";
import confirmBody from "../../fixtures/confirm-body.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import State from "../../utils/State";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import voidBody from "../../fixtures/void-payment-body.json";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand Down
@@ -1,7 +1,7 @@
import createPaymentBody from "../../fixtures/create-payment-body.json";
import confirmBody from "../../fixtures/confirm-body.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand Down
59 changes: 30 additions & 29 deletions cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js
@@ -1,12 +1,13 @@
import createPaymentBody from "../../fixtures/create-payment-body.json";
import captureBody from "../../fixtures/capture-flow-body.json";
import confirmBody from "../../fixtures/confirm-body.json";
import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import captureBody from "../../fixtures/capture-flow-body.json";
import refundBody from "../../fixtures/refund-flow-body.json";
import citConfirmBody from "../../fixtures/create-mandate-cit.json";
import mitConfirmBody from "../../fixtures/create-mandate-mit.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import refundBody from "../../fixtures/refund-flow-body.json";
import listRefundCall from "../../fixtures/list-refund-call-body.json";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand Down Expand Up @@ -89,32 +90,32 @@ describe("Card - Refund flow test", () => {
context("Fully Refund Card-NoThreeDS payment flow test Create+Confirm", () => {

it("create+confirm-payment-call-test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState);
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState);
});
it("retrieve-payment-call-test", () => {
cy.retrievePaymentCallTest(globalState);

it("retrieve-payment-call-test", () => {
cy.retrievePaymentCallTest(globalState);
});

it("refund-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.refundCallTest(refundBody, 6540, det, globalState);
});

});

context("Partially Refund Card-NoThreeDS payment flow test Create+Confirm", () => {

it("create+confirm-payment-call-test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState);
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState);
});
it("retrieve-payment-call-test", () => {
cy.retrievePaymentCallTest(globalState);

it("retrieve-payment-call-test", () => {
cy.retrievePaymentCallTest(globalState);
});

it("refund-call-test", () => {
Expand All @@ -131,7 +132,7 @@ describe("Card - Refund flow test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.syncRefundCallTest(det, globalState);
});

});

context("Card - Full Refund for fully captured No-3DS payment", () => {
Expand Down Expand Up @@ -223,7 +224,7 @@ describe("Card - Refund flow test", () => {
cy.syncRefundCallTest(det, globalState);
});
it("list-refund-call-test", () => {
cy.listRefundCallTest(globalState);
cy.listRefundCallTest(listRefundCall, globalState);
});
});

Expand Down Expand Up @@ -276,37 +277,37 @@ describe("Card - Refund flow test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState);
});

it("payment_methods-call-test", () => {
cy.paymentMethodsCallTest(globalState);
});

it("confirm-call-test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
console.log("det -> " + det.card);
cy.confirmCallTest(confirmBody, det, true, globalState);
});

it("retrieve-payment-call-test", () => {
cy.retrievePaymentCallTest(globalState);
});

it("capture-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
console.log("det -> " + det.card);
cy.captureCallTest(captureBody, 4000, det.paymentSuccessfulStatus, globalState);
});

it("retrieve-payment-call-test", () => {
cy.retrievePaymentCallTest(globalState);
});

it("refund-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.refundCallTest(refundBody, 3000, det, globalState);
});

it("sync-refund-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.syncRefundCallTest(det, globalState);
Expand All @@ -333,10 +334,10 @@ describe("Card - Refund flow test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.refundCallTest(refundBody, 7000, det, globalState);
});

it("sync-refund-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.syncRefundCallTest(det, globalState);
let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"];
cy.syncRefundCallTest(det, globalState);
});
});

Expand Down
@@ -1,8 +1,8 @@
import createPaymentBody from "../../fixtures/create-payment-body.json";
import confirmBody from "../../fixtures/confirm-body.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import refundBody from "../../fixtures/refund-flow-body.json"
import createPaymentBody from "../../fixtures/create-payment-body.json";
import refundBody from "../../fixtures/refund-flow-body.json";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand Down
@@ -1,8 +1,8 @@
import captureBody from "../../fixtures/capture-flow-body.json";
import citConfirmBody from "../../fixtures/create-mandate-cit.json";
import mitConfirmBody from "../../fixtures/create-mandate-mit.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand All @@ -27,7 +27,7 @@ describe("Card - SingleUse Mandates flow test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUseNo3DS"];
console.log("det -> " + det.card);
cy.citForMandatesCallTest(citConfirmBody,7000, det, true, "automatic", "new_mandate", globalState);
cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState);
});

it("Confirm No 3DS MIT", () => {
Expand All @@ -41,7 +41,7 @@ describe("Card - SingleUse Mandates flow test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUseNo3DS"];
console.log("det -> " + det.card);
cy.citForMandatesCallTest(citConfirmBody,7000, det, true, "manual", "new_mandate", globalState);
cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "manual", "new_mandate", globalState);
});

it("cit-capture-call-test", () => {
Expand Down Expand Up @@ -71,7 +71,7 @@ describe("Card - SingleUse Mandates flow test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUse3DS"];
console.log("det -> " + det.card);
cy.citForMandatesCallTest(citConfirmBody,6500, det, true, "automatic", "new_mandate", globalState);
cy.citForMandatesCallTest(citConfirmBody, 6500, det, true, "automatic", "new_mandate", globalState);
});

it("cit-capture-call-test", () => {
Expand Down
@@ -1,9 +1,8 @@
import createPaymentBody from "../../fixtures/create-payment-body.json";
import captureBody from "../../fixtures/capture-flow-body.json";
import citConfirmBody from "../../fixtures/create-mandate-cit.json";
import mitConfirmBody from "../../fixtures/create-mandate-mit.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";

let globalState;

Expand All @@ -29,7 +28,7 @@ describe("Card - MultiUse Mandates flow test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["MandateMultiUseNo3DS"];
console.log("det -> " + det.card);
cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic","new_mandate", globalState);
cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState);
});

it("Confirm No 3DS MIT", () => {
Expand All @@ -46,7 +45,7 @@ describe("Card - MultiUse Mandates flow test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["MandateMultiUseNo3DS"];
console.log("det -> " + det.card);
cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "manual","new_mandate", globalState);
cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "manual", "new_mandate", globalState);
});

it("cit-capture-call-test", () => {
Expand Down
@@ -1,7 +1,6 @@
import citConfirmBody from "../../fixtures/create-mandate-cit.json";
import mitConfirmBody from "../../fixtures/create-mandate-mit.json";
import getConnectorDetails from "../ConnectorUtils/utils";
import customerCreateBody from "../../fixtures/create-customer-body.json";

import State from "../../utils/State";

Expand All @@ -28,7 +27,7 @@ describe("Card - SingleUse Mandates flow test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUseNo3DS"];
console.log("det -> " + det.card);
cy.citForMandatesCallTest(citConfirmBody,7000, det, true, "automatic", "new_mandate", globalState);
cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState);
});

it("Confirm No 3DS MIT", () => {
Expand Down

0 comments on commit 0c9ba1e

Please sign in to comment.