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): correction of cypress tests env variables for Payment method list #5299

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import {
} from "../PaymentMethodListUtils/Commons";
import getConnectorDetails from "../PaymentMethodListUtils/Utils";

// Testing for scenario:
// MCA1 -> Stripe configured with ideal = { country = "NL", currency = "EUR" }
// MCA2 -> Cybersource configured with credit = { currency = "USD" }
// Payment is done with currency as EUR and no billing address
// The resultant Payment Method list should only have ideal with stripe

let globalState;
describe("Payment Method list using Constraint Graph flow tests", () => {
// Testing for scenario:
Expand Down Expand Up @@ -90,7 +84,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", () => {
let data = getConnectorDetails(globalState.get("connectorId"))[
let data = getConnectorDetails("stripe")[
"pm_list"
]["PmListResponse"]["PmListWithStripeForIdeal"];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
Expand Down Expand Up @@ -170,7 +164,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", () => {
let data = getConnectorDetails(globalState.get("connectorId"))[
let data = getConnectorDetails("stripe")[
"pm_list"
]["PmListResponse"]["PmListNull"];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
Expand Down Expand Up @@ -250,7 +244,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", () => {
let data = getConnectorDetails(globalState.get("connectorId"))[
let data = getConnectorDetails("stripe")[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you make sure that it also runs for cybersource? i'm sure that this will run for stripe irrespective of connectors.

the same applies applies else where

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for getting the Response and Request configs which in PaymentMethodList will be same irrespective of any connector, as this is connector agnostic.
Moreover, we have implemented it for Stripe and Cybersource, So if the List runs fine for any 2 connectors it will run for any connectors, again as this is connector agnostic.

"pm_list"
]["PmListResponse"]["PmListWithCreditTwoConnector"];
cy.paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit(
Expand Down Expand Up @@ -330,7 +324,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// payment method list which shouldn't have anything
it("payment-method-list-call-test", () => {
let data = getConnectorDetails(globalState.get("connectorId"))[
let data = getConnectorDetails("stripe")[
"pm_list"
]["PmListResponse"]["PmListNull"];
cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(
Expand Down Expand Up @@ -414,7 +408,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", () => {
let data = getConnectorDetails(globalState.get("connectorId"))[
let data = getConnectorDetails("stripe")[
"pm_list"
]["PmListResponse"]["PmListWithCreditTwoConnector"];
cy.paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit(
Expand Down
15 changes: 0 additions & 15 deletions cypress-tests/cypress/e2e/PaymentMethodListUtils/Commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,3 @@ export const create_payment_body_with_currency = (currency) => ({
},
business_label: "default",
});

export const create_payment_body_in_USD = {
currency: "USD",
amount: 6500,
authentication_type: "three_ds",
description: "Joseph First Crypto",
email: "hyperswitch_sdk_demo_id@gmail.com",
setup_future_usage: "",
metadata: {
udf1: "value1",
new_customer: "true",
login_date: "2019-09-10T10:11:12Z",
},
business_label: "default",
};
8 changes: 5 additions & 3 deletions cypress-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,11 @@ Cypress.Commands.add(
.slice()
.sort();
}
for (let i = 0; i < getPaymentMethodType(response.body).length; i++) {
expect(getPaymentMethodType(res_data)[i]).to.equal(
getPaymentMethodType(response.body)[i]
let config_payment_method_type = getPaymentMethodType(res_data);
let response_payment_method_type = getPaymentMethodType(response.body);
for (let i = 0; i < response_payment_method_type.length; i++) {
expect(config_payment_method_type[i]).to.equal(
response_payment_method_type[i]
);
}
} else {
Expand Down
Loading