Skip to content

Commit

Permalink
Ci(Cypress): Add PML test and Dynamic Fields Test for Novalnet (#6544)
Browse files Browse the repository at this point in the history
  • Loading branch information
cookieg13 authored Jan 6, 2025
1 parent de2f209 commit 638e1f2
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
cardCreditEnabled,
cardCreditEnabledInUs,
cardCreditEnabledInUsd,
cardCreditEnabledInEur,
createPaymentBodyWithCurrency,
createPaymentBodyWithCurrencyCountry,
} from "../PaymentMethodListUtils/Commons";
Expand Down Expand Up @@ -68,7 +69,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as EUR and no billing address
it("create-payment-call-test", () => {
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Expand All @@ -88,7 +90,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// payment method list which should only have ideal with stripe
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListWithStripeForIdeal"
];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
Expand Down Expand Up @@ -151,7 +153,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as INR and no billing address
it("create-payment-call-test", () => {
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Expand All @@ -171,7 +174,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// payment method list which should only have ideal with stripe
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListNull"
];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
Expand Down Expand Up @@ -234,7 +237,8 @@ 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", () => {
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Expand All @@ -254,7 +258,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// payment method list which should only have credit with Stripe and Cybersource
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListWithCreditTwoConnector"
];
cy.paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit(
Expand Down Expand Up @@ -317,7 +321,8 @@ 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", () => {
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Expand All @@ -337,7 +342,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// payment method list which shouldn't have anything
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListNull"
];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
Expand Down Expand Up @@ -402,7 +407,8 @@ 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", () => {
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Expand All @@ -422,7 +428,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// payment method list which should have credit with stripe and cybersource and no ideal
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListWithCreditTwoConnector"
];
cy.paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit(
Expand Down Expand Up @@ -486,7 +492,8 @@ 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", () => {
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Expand All @@ -506,7 +513,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// payment method list which should have credit with stripe and cybersource and no ideal
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListWithCreditTwoConnector"
];
cy.paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit(
Expand Down Expand Up @@ -569,7 +576,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as EUR and no billing address
it("create-payment-call-test", () => {
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Expand All @@ -589,7 +597,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
// payment method list which should only have ideal with stripe
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListWithStripeForIdeal"
];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
Expand All @@ -599,4 +607,179 @@ describe("Payment Method list using Constraint Graph flow tests", () => {
});
}
);

context(
`
MCA1 -> Stripe configured with credit = { currency = "USD" }\n
MCA2 -> Novalnet configured with credit = { currency = "EUR" }\n
Payment is done with currency as as USD and no billing address\n
The resultant Payment Method list should only have credit with stripe\n
`,
() => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

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

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

it("api-key-create-call-test", () => {
cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState);
});

it("customer-create-call-test", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});

// stripe connector create with card credit enabled in USD
it("connector-create-call-test", () => {
cy.createNamedConnectorCallTest(
"payment_processor",
fixtures.createConnectorBody,
cardCreditEnabledInUsd,
globalState,
"stripe",
"stripe_US_default"
);
});

// novalnet connector create with card credit enabled in EUR
it("connector-create-call-test", () => {
cy.createNamedConnectorCallTest(
"payment_processor",
fixtures.createConnectorBody,
cardCreditEnabledInEur,
globalState,
"novalnet",
"novalnet_DE_default"
);
});

// creating payment with currency as USD and no billing email
// billing.email is mandatory for novalnet
it("create-payment-call-test", () => {
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];
const newData = {
...data,
Request: data.RequestCurrencyUSD,
RequestCurrencyUSD: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
createPaymentBodyWithCurrency("USD"),
newData,
"no_three_ds",
"automatic",
globalState
);
});

// payment method list should only have credit with stripe
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListWithCreditOneConnector"
];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
data,
globalState
);
});
}
);
context(
`
MCA1 -> Stripe configured with credit = { currency = "USD" }\n
MCA2 -> Novalnet configured with credit = { currency = "EUR" }\n
Payment is done with currency as as EUR and billing address for 3ds credit card\n
The resultant Payment Method list should only have credit with novalnet\n
`,
() => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

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

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

it("api-key-create-call-test", () => {
cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState);
});

it("customer-create-call-test", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});

// stripe connector create with card credit enabled in USD
it("connector-create-call-test", () => {
cy.createNamedConnectorCallTest(
"payment_processor",
fixtures.createConnectorBody,
cardCreditEnabledInUsd,
globalState,
"stripe",
"stripe_US_default"
);
});

// novalnet connector create with card credit enabled in EUR
it("connector-create-call-test", () => {
cy.createNamedConnectorCallTest(
"payment_processor",
fixtures.createConnectorBody,
cardCreditEnabledInEur,
globalState,
"novalnet",
"novalnet_DE_default"
);
});

// creating payment with currency as EUR and billing email
// billing.email is mandatory for novalnet
it("create-payment-call-test", () => {
const data =
getConnectorDetails("connector")["pm_list"]["PaymentIntent"];
const newData = {
...data,
Request: data.RequestCurrencyEUR,
RequestCurrencyEUR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
createPaymentBodyWithCurrencyCountry("EUR", "IN", "IN"),
newData,
"three_ds",
"automatic",
globalState
);
});

// payment method list should only have credit with novalnet
it("payment-method-list-call-test", () => {
const data =
getConnectorDetails("connector")["pm_list"]["PmListResponse"][
"PmListWithCreditOneConnector"
];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
data,
globalState
);
});
}
);
});
20 changes: 20 additions & 0 deletions cypress-tests/cypress/e2e/PaymentMethodListUtils/Commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ export const cardCreditEnabledInUs = [
},
];

export const cardCreditEnabledInEur = [
{
payment_method: "card",
payment_method_types: [
{
payment_method_type: "credit",
card_networks: ["Visa"],
minimum_amount: 0,
accepted_currencies: {
type: "enable_only",
list: ["EUR"],
},
maximum_amount: 68607706,
recurring_enabled: false,
installment_payment_enabled: true,
},
],
},
];

export const bankRedirectIdealEnabled = [
{
payment_method: "bank_redirect",
Expand Down
4 changes: 2 additions & 2 deletions cypress-tests/cypress/e2e/PaymentMethodListUtils/Utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { connectorDetails as CommonConnectorDetails } from "./Commons.js";
import { connectorDetails as stripeConnectorDetails } from "./Stripe.js";
import { connectorDetails as ConnectorDetails } from "./Connector.js";

const connectorDetails = {
commons: CommonConnectorDetails,
stripe: stripeConnectorDetails,
connector: ConnectorDetails,
};

export default function getConnectorDetails(connectorId) {
Expand Down
Loading

0 comments on commit 638e1f2

Please sign in to comment.