Files
hyperswitch/cypress-tests/cypress/e2e/PaymentTest/00016-ThreeDSManualCapture.cy.js
Pa1NarK 64383915bd feat(cypress): add multiple creds and flags support (#6588)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
2024-12-03 10:48:29 +00:00

294 lines
8.5 KiB
JavaScript

import captureBody from "../../fixtures/capture-flow-body.json";
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import getConnectorDetails, * as utils from "../PaymentUtils/Utils";
let globalState;
describe("Card - ThreeDS Manual payment flow test", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});
afterEach("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});
context("Card - ThreeDS Manual Full Capture payment flow test", () => {
context("payment Create and Confirm", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("create-payment-call-test", () => {
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("payment_methods-call-test", () => {
cy.paymentMethodsCallTest(globalState);
});
it("confirm-call-test", () => {
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-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.retrievePaymentCallTest(globalState, data);
});
it("capture-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(captureBody, data, 6500, globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("retrieve-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.retrievePaymentCallTest(globalState, data);
});
});
context("Payment Create+Confirm", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("create+confirm-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
data,
"three_ds",
"manual",
globalState
);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("Handle redirection", () => {
const expected_redirection =
fixtures.createConfirmPaymentBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
it("retrieve-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.retrievePaymentCallTest(globalState, data);
});
it("capture-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(captureBody, data, 6500, globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("retrieve-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.retrievePaymentCallTest(globalState, data);
});
});
});
context(
"Card - ThreeDS Manual Partial Capture payment flow test - Create and Confirm",
() => {
context("payment Create and Payment Confirm", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("create-payment-call-test", () => {
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("payment_methods-call-test", () => {
cy.paymentMethodsCallTest(globalState);
});
it("confirm-call-test", () => {
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-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.retrievePaymentCallTest(globalState, data);
});
it("capture-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PartialCapture"];
cy.captureCallTest(captureBody, data, 100, globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("retrieve-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PartialCapture"];
cy.retrievePaymentCallTest(globalState, data);
});
});
context("payment + Confirm", () => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("create+confirm-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
data,
"three_ds",
"manual",
globalState
);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("Handle redirection", () => {
const expected_redirection =
fixtures.createConfirmPaymentBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
it("retrieve-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.retrievePaymentCallTest(globalState, data);
});
it("capture-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PartialCapture"];
cy.captureCallTest(captureBody, data, 100, globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("retrieve-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PartialCapture"];
cy.retrievePaymentCallTest(globalState, data);
});
});
}
);
});