Skip to content

Commit

Permalink
ci(cypress): Add Tests for Customer Deletion and Psync flows (#7158)
Browse files Browse the repository at this point in the history
  • Loading branch information
likhinbopanna authored Feb 7, 2025
1 parent 4693d21 commit 9772cb3
Show file tree
Hide file tree
Showing 5 changed files with 392 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
import * as fixtures from "../../../fixtures/imports";
import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";

let globalState;

describe("Card - Customer Deletion and Psync", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

context("Card - Psync after Customer Deletion for Automatic Capture", () => {
context("No3DS Card - Psync after Customer Deletion ", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails

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

it("Create Customer", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});

it("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];

cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("Confirm Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];

cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];

cy.retrievePaymentCallTest(globalState, data);
});

it("Delete Customer", () => {
cy.customerDeleteCall(globalState);
});

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];

cy.retrievePaymentCallTest(globalState, data);
});
});

context("3DS Card - Psync after Customer Deletion ", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails

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

before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

afterEach("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

it("Create Customer", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});

it("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];

cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"three_ds",
"automatic",
globalState
);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("Confirm Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];

cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

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

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];

cy.retrievePaymentCallTest(globalState, data);
});

it("Delete Customer", () => {
cy.customerDeleteCall(globalState);
});

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];

cy.retrievePaymentCallTest(globalState, data);
});
});
});

context("Card - Psync after Customer Deletion for Manual Capture", () => {
context("No3DS Card - Psync after Customer Deletion ", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails

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

it("Create Customer", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});

it("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];

cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"manual",
globalState
);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("Confirm Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];

cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];

cy.retrievePaymentCallTest(globalState, data);
});

it("Capture Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];

cy.captureCallTest(fixtures.captureBody, data, 6500, globalState);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];

cy.retrievePaymentCallTest(globalState, data);
});

it("Delete Customer", () => {
cy.customerDeleteCall(globalState);
});

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];

cy.retrievePaymentCallTest(globalState, data);
});
});

context("3DS Card - Psync after Customer Deletion ", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails

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

before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

afterEach("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

it("Create Customer", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});

it("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];

cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"three_ds",
"manual",
globalState
);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("Confirm Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];

cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

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

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];

cy.retrievePaymentCallTest(globalState, data);
});

it("Capture Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];

cy.captureCallTest(fixtures.captureBody, data, 6500, globalState);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];

cy.retrievePaymentCallTest(globalState, data);
});

it("Delete Customer", () => {
cy.customerDeleteCall(globalState);
});

it("Retrieve Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];

cy.retrievePaymentCallTest(globalState, data);
});
});
});
});
Loading

0 comments on commit 9772cb3

Please sign in to comment.