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

feat(Cypress): Add response handler for Connector Testing #4624

Merged
merged 19 commits into from
May 21, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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";
import * as utils from "../ConnectorUtils/utils";

let globalState;

Expand All @@ -22,19 +23,32 @@ describe("Card - NoThreeDS payment flow test", () => {
})

context("Card-NoThreeDS payment flow test Create and confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

beforeEach(function () {
if(!should_continue) {
this.skip();
}
});

it("create-payment-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "automatic", globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

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

it("Confirm No 3DS", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
cy.confirmCallTest(confirmBody, det, true, globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payment-call-test", () => {
Expand All @@ -44,11 +58,21 @@ describe("Card - NoThreeDS payment flow test", () => {
});

context("Card-NoThreeDS payment flow test Create+Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

beforeEach(function () {
if(!should_continue) {
this.skip();
}
});

it("create+confirm-payment-call-test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payment-call-test", () => {
Expand All @@ -57,4 +81,4 @@ describe("Card - NoThreeDS payment flow test", () => {


});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ import confirmBody from "../../fixtures/confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import State from "../../utils/State";
import getConnectorDetails from "../ConnectorUtils/utils";
import * as utils from "../ConnectorUtils/utils";

let globalState;

describe("Card - ThreeDS payment flow test", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

beforeEach(function () {
if(!should_continue) {
this.skip();
}
});

before("seed global state", () => {

Expand All @@ -25,8 +33,11 @@ describe("Card - ThreeDS payment flow test", () => {


it("create-payment-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
cy.createPaymentIntentTest(createPaymentBody, det, "three_ds", "automatic", globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("payment_methods-call-test", () => {
Expand All @@ -35,14 +46,17 @@ describe("Card - ThreeDS payment flow test", () => {
});

it("Confirm 3DS", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"];
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.task('cli_log', "GLOBAL STATE -> " + JSON.stringify(globalState.data));
cy.confirmCallTest(confirmBody, det, true, globalState);
cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("Handle redirection", () => {
let expected_redirection = confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
})

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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";
import * as utils from "../ConnectorUtils/utils";

let globalState;

Expand All @@ -25,10 +26,20 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
context("Card - NoThreeDS Manual Full Capture payment flow test", () => {

context("payment Create and Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

beforeEach(function () {
if(!should_continue) {
this.skip();
}
});

it("create-payment-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("payment_methods-call-test", () => {
Expand All @@ -37,19 +48,25 @@ describe("Card - NoThreeDS Manual payment flow test", () => {

it("confirm-call-test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
console.log("det -> " + det.card);
cy.confirmCallTest(confirmBody, det, true, globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the logs.

cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

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

it("capture-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
console.log("det -> " + det.card);
cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"];
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here.

cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payment-call-test", () => {
Expand All @@ -59,21 +76,35 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
});

context("Payment Create+Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

beforeEach(function () {
if(!should_continue) {
this.skip();
}
});

it("create+confirm-payment-call-test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
console.log("det -> " + det.card);
cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "manual", globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here.

cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

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

it("capture-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
console.log("det -> " + det.card);
cy.captureCallTest(captureBody, 6540, det.paymentSuccessfulStatus, globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"];
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prasunna09, You added these log lines, and they are present in all your initial commits. Removing them will take a significant amount of time. We'll address this issue later. For now, could you please approve this so we can proceed with the other changes? We are currently blocked by this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this can be taken up in separate pr

cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payment-call-test", () => {
Expand All @@ -87,10 +118,20 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
context("Card - NoThreeDS Manual Partial Capture payment flow test - Create and Confirm", () => {

context("payment Create and Payment Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

beforeEach(function () {
if(!should_continue) {
this.skip();
}
});

it("create-payment-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("payment_methods-call-test", () => {
Expand All @@ -99,18 +140,24 @@ describe("Card - NoThreeDS Manual payment flow test", () => {

it("confirm-call-test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
console.log("det -> " + det.card);
cy.confirmCallTest(confirmBody, det, true, globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here.

cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

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

it("capture-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
cy.captureCallTest(captureBody, 100, det.paymentSuccessfulStatus, globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.captureCallTest(captureBody, req_data, res_data, 100, globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payment-call-test", () => {
Expand All @@ -119,21 +166,35 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
});

context("payment + Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

beforeEach(function () {
if(!should_continue) {
this.skip();
}
});

it("create+confirm-payment-call-test", () => {
console.log("confirm -> " + globalState.get("connectorId"));
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
console.log("det -> " + det.card);
cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "manual", globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the log

cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

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

it("capture-call-test", () => {
let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"];
console.log("det -> " + det.card);
cy.captureCallTest(captureBody, 5000, det.paymentSuccessfulStatus, globalState);
let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here.

cy.captureCallTest(captureBody, req_data, res_data, 100, globalState);
if(should_continue) should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payment-call-test", () => {
Expand All @@ -144,4 +205,4 @@ describe("Card - NoThreeDS Manual payment flow test", () => {


});
});
});