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

refactor(cypress): unify fixtures in tests & follow conventions #5180

Merged
merged 9 commits into from
Jul 10, 2024
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import apiKeyCreateBody from "../../fixtures/create-api-key-body.json";
import merchantCreateBody from "../../fixtures/merchant-create-body.json";
import State from "../../utils/State";
import * as fixtures from "../../fixtures/imports";

let globalState;
describe("Account Create flow test", () => {
Expand All @@ -15,10 +14,10 @@ describe("Account Create flow test", () => {
});

it("merchant-create-call-test", () => {
cy.merchantCreateCallTest(merchantCreateBody, globalState);
cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState);
});

it("api-key-create-call-test", () => {
cy.apiKeyCreateTest(apiKeyCreateBody, globalState);
cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import customerCreateBody from "../../fixtures/create-customer-body.json";
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";

let globalState;
Expand All @@ -15,6 +15,6 @@ describe("Customer Create flow test", () => {
});

it("customer-create-call-test", () => {
cy.createCustomerCallTest(customerCreateBody, globalState);
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import createConnectorBody from "../../fixtures/create-connector-body.json";
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import { payment_methods_enabled } from "../PaymentUtils/Commons";

Expand All @@ -16,7 +16,7 @@ describe("Connector Account Create flow test", () => {

it("connector-create-call-test", () => {
cy.createConnectorCallTest(
createConnectorBody,
fixtures.createConnectorBody,
payment_methods_enabled,
globalState
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import confirmBody from "../../fixtures/confirm-body.json";
import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import getConnectorDetails from "../PaymentUtils/utils";
import * as utils from "../PaymentUtils/utils";
import getConnectorDetails, * as utils from "../PaymentUtils/Utils";

let globalState;

Expand Down Expand Up @@ -34,7 +31,7 @@ describe("Card - NoThreeDS payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
fixtures.createPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -55,7 +52,13 @@ describe("Card - NoThreeDS payment flow test", () => {
];
let req_data = data["Request"];
let res_data = data["Response"];
cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
cy.confirmCallTest(
fixtures.confirmBody,
req_data,
res_data,
true,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand All @@ -82,7 +85,7 @@ describe("Card - NoThreeDS payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createConfirmPaymentTest(
createConfirmPaymentBody,
fixtures.createConfirmPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import confirmBody from "../../fixtures/confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import getConnectorDetails from "../PaymentUtils/utils";
import * as utils from "../PaymentUtils/utils";
import getConnectorDetails, * as utils from "../PaymentUtils/Utils";

let globalState;

Expand Down Expand Up @@ -32,7 +30,7 @@ describe("Card - ThreeDS payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
fixtures.createPaymentBody,
req_data,
res_data,
"three_ds",
Expand All @@ -53,13 +51,19 @@ describe("Card - ThreeDS payment flow test", () => {
];
let req_data = data["Request"];
let res_data = data["Response"];
cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
cy.confirmCallTest(
fixtures.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"];
let expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import captureBody from "../../fixtures/capture-flow-body.json";
import confirmBody from "../../fixtures/confirm-body.json";
import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import getConnectorDetails from "../PaymentUtils/utils";
import * as utils from "../PaymentUtils/utils";
import getConnectorDetails, * as utils from "../PaymentUtils/Utils";

let globalState;

Expand Down Expand Up @@ -36,7 +32,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
fixtures.createPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -59,7 +55,13 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
cy.confirmCallTest(
fixtures.confirmBody,
req_data,
res_data,
true,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand All @@ -75,7 +77,13 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState);
cy.captureCallTest(
fixtures.captureBody,
req_data,
res_data,
6500,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand Down Expand Up @@ -103,7 +111,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.createConfirmPaymentTest(
createConfirmPaymentBody,
fixtures.createConfirmPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -125,7 +133,13 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState);
cy.captureCallTest(
fixtures.captureBody,
req_data,
res_data,
6500,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand Down Expand Up @@ -155,7 +169,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
fixtures.createPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -179,7 +193,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.confirmCallTest(
confirmBody,
fixtures.confirmBody,
req_data,
res_data,
true,
Expand All @@ -199,7 +213,13 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
]["PartialCapture"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.captureCallTest(captureBody, req_data, res_data, 100, globalState);
cy.captureCallTest(
fixtures.captureBody,
req_data,
res_data,
100,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand Down Expand Up @@ -227,7 +247,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.createConfirmPaymentTest(
createConfirmPaymentBody,
fixtures.createConfirmPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -249,7 +269,13 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.captureCallTest(captureBody, req_data, res_data, 100, globalState);
cy.captureCallTest(
fixtures.captureBody,
req_data,
res_data,
100,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand Down
34 changes: 22 additions & 12 deletions cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import confirmBody from "../../fixtures/confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import voidBody from "../../fixtures/void-payment-body.json";
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import getConnectorDetails, * as utils from "../PaymentUtils/utils";
import getConnectorDetails, * as utils from "../PaymentUtils/Utils";

let globalState;

Expand Down Expand Up @@ -33,7 +31,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
fixtures.createPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -56,7 +54,13 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
cy.confirmCallTest(
fixtures.confirmBody,
req_data,
res_data,
true,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand All @@ -67,7 +71,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
];
let req_data = data["Request"];
let res_data = data["Response"];
cy.voidCallTest(voidBody, req_data, res_data, globalState);
cy.voidCallTest(fixtures.voidBody, req_data, res_data, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand All @@ -91,7 +95,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
fixtures.createPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -112,7 +116,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
]["Void"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.voidCallTest(voidBody, req_data, res_data, globalState);
cy.voidCallTest(fixtures.voidBody, req_data, res_data, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand All @@ -137,7 +141,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
fixtures.createPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -160,7 +164,13 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.confirmCallTest(confirmBody, req_data, res_data, false, globalState);
cy.confirmCallTest(
fixtures.confirmBody,
req_data,
res_data,
false,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand All @@ -171,7 +181,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
]["Void"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.voidCallTest(voidBody, req_data, res_data, globalState);
cy.voidCallTest(fixtures.voidBody, req_data, res_data, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand Down
16 changes: 10 additions & 6 deletions cypress-tests/cypress/e2e/PaymentTest/00007-SyncPayment.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import confirmBody from "../../fixtures/confirm-body.json";
import createPaymentBody from "../../fixtures/create-payment-body.json";
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import getConnectorDetails from "../PaymentUtils/utils";
import * as utils from "../PaymentUtils/utils";
import getConnectorDetails, * as utils from "../PaymentUtils/Utils";

let globalState;

Expand Down Expand Up @@ -31,7 +29,7 @@ describe("Card - Sync payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
cy.createPaymentIntentTest(
createPaymentBody,
fixtures.createPaymentBody,
req_data,
res_data,
"no_three_ds",
Expand All @@ -54,7 +52,13 @@ describe("Card - Sync payment flow test", () => {
let req_data = data["Request"];
let res_data = data["Response"];
console.log("det -> " + data.card);
cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState);
cy.confirmCallTest(
fixtures.confirmBody,
req_data,
res_data,
true,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand Down
Loading
Loading