Skip to content

Commit

Permalink
refactor: directly pass data instead of splitting in .cy.js files
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate committed Nov 25, 2024
1 parent 06ab242 commit 22feccb
Show file tree
Hide file tree
Showing 34 changed files with 1,104 additions and 3,051 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// creating payment with currency as EUR and no billing address
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyEUR"];
let res_data = data["Response"];

const newData = {
...data,
Request: data.RequestCurrencyEUR,
RequestCurrencyEUR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency("EUR"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand Down Expand Up @@ -148,13 +151,16 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// creating payment with currency as INR and no billing address
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyINR"];
let res_data = data["Response"];

const newData = {
...data,
Request: data.RequestCurrencyINR,
RequestCurrencyINR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency("INR"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand Down Expand Up @@ -228,13 +234,16 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// creating payment with currency as USD and billing address as US
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyUSD"];
let res_data = data["Response"];

const newData = {
...data,
Request: data.RequestCurrencyUSD,
RequestCurrencyUSD: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency("USD"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand Down Expand Up @@ -308,13 +317,16 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// creating payment with currency as EUR and billing address as US
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyEUR"];
let res_data = data["Response"];

const newData = {
...data,
Request: data.RequestCurrencyEUR,
RequestCurrencyEUR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency_country("EUR", "US", "US"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand Down Expand Up @@ -390,13 +402,16 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// creating payment with currency as USD and billing address as IN
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyUSD"];
let res_data = data["Response"];

const newData = {
...data,
Request: data.RequestCurrencyUSD,
RequestCurrencyUSD: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency_country("USD", "IN", "IN"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand Down Expand Up @@ -471,13 +486,16 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// creating payment with currency as USD and billing address as IN
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyUSD"];
let res_data = data["Response"];

const newData = {
...data,
Request: data.RequestCurrencyUSD,
RequestCurrencyUSD: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency("USD"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand Down Expand Up @@ -551,13 +569,16 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// creating payment with currency as EUR and no billing address
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyEUR"];
let res_data = data["Response"];

const newData = {
...data,
Request: data.RequestCurrencyEUR,
RequestCurrencyEUR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency_country("EUR", "NL", "US"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,16 @@ describe("Card - NoThreeDS payment flow test", () => {
"PaymentIntent"
];

let configs = validateConfig(data["Configs"]);
let req_data = data["Request"];
let res_data = data["Response"];

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

if (should_continue)
should_continue = utils.should_continue_further(res_data, configs);
should_continue = utils.should_continue_further(data);
});

it("payment_methods-call-test", () => {
Expand All @@ -57,21 +51,10 @@ describe("Card - NoThreeDS payment flow test", () => {
"No3DSAutoCapture"
];

let configs = validateConfig(data["Configs"]);
let req_data = data["Request"];
let res_data = data["Response"];

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

if (should_continue)
should_continue = utils.should_continue_further(res_data, configs);
should_continue = utils.should_continue_further(data);
});

it("retrieve-payment-call-test", () => {
Expand Down Expand Up @@ -99,22 +82,16 @@ describe("Card - NoThreeDS payment flow test", () => {
"No3DSAutoCapture"
];

let configs = validateConfig(data["Configs"]);
let req_data = data["Request"];
let res_data = data["Response"];

cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
req_data,
res_data,
data,
"no_three_ds",
"automatic",
globalState,
configs
globalState
);

if (should_continue)
should_continue = utils.should_continue_further(res_data, configs);
should_continue = utils.should_continue_further(data);
});

it("retrieve-payment-call-test", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,15 @@ describe("Card - ThreeDS payment flow test", () => {
"PaymentIntent"
];

let configs = validateConfig(data["Configs"]);
let req_data = data["Request"];
let res_data = data["Response"];

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

if (should_continue)
should_continue = utils.should_continue_further(res_data, configs);
if (should_continue) should_continue = utils.should_continue_further(data);
});

it("payment_methods-call-test", () => {
Expand All @@ -56,21 +49,9 @@ describe("Card - ThreeDS payment flow test", () => {
"3DSAutoCapture"
];

let configs = validateConfig(data["Configs"]);
let req_data = data["Request"];
let res_data = data["Response"];

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

if (should_continue)
should_continue = utils.should_continue_further(res_data, configs);
if (should_continue) should_continue = utils.should_continue_further(data);
});

it("Handle redirection", () => {
Expand Down
Loading

0 comments on commit 22feccb

Please sign in to comment.