Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
ci(cypress): Added Config Testcases (#6622)
Gnanasundari242c865156a24a
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00024-ConnectorAgnostic.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00024-ConnectorAgnostic.cy.jsindex 64abe296b2..29b0097253 100644--- a/cypress-tests/cypress/e2e/PaymentTest/00024-ConnectorAgnostic.cy.js+++ b/cypress-tests/cypress/e2e/PaymentTest/00024-ConnectorAgnostic.cy.js@@ -26,7 +26,7 @@ describe("Connector Agnostic Tests", () => {it("Create Business Profile", () => {cy.createBusinessProfileTest(- fixtures.createBusinessProfile,+ fixtures.businessProfile.bpCreate,globalState);});@@ -85,7 +85,7 @@ describe("Connector Agnostic Tests", () => {it("Create Business Profile", () => {cy.createBusinessProfileTest(- fixtures.createBusinessProfile,+ fixtures.businessProfile.bpCreate,globalState);});@@ -101,8 +101,12 @@ describe("Connector Agnostic Tests", () => {it("Enable Connector Agnostic for Business Profile", () => {cy.UpdateBusinessProfileTest(- fixtures.updateBusinessProfile,- true,+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connectorglobalState);});@@ -141,7 +145,10 @@ describe("Connector Agnostic Tests", () => {});it("Create Business Profile", () => {- cy.createBusinessProfileTest(fixtures.createBusinessProfile, globalState);+ cy.createBusinessProfileTest(+ fixtures.businessProfile.bpCreate,+ globalState+ );});it("connector-create-call-test", () => {@@ -159,8 +166,12 @@ describe("Connector Agnostic Tests", () => {it("Enable Connector Agnostic for Business Profile", () => {cy.UpdateBusinessProfileTest(- fixtures.updateBusinessProfile,- true,+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connectorglobalState);});@@ -205,7 +216,10 @@ describe("Connector Agnostic Tests", () => {});it("Create Business Profile", () => {- cy.createBusinessProfileTest(fixtures.createBusinessProfile, globalState);+ cy.createBusinessProfileTest(+ fixtures.businessProfile.bpCreate,+ globalState+ );});it("connector-create-call-test", () => {@@ -219,8 +233,12 @@ describe("Connector Agnostic Tests", () => {it("Enable Connector Agnostic for Business Profile", () => {cy.UpdateBusinessProfileTest(- fixtures.updateBusinessProfile,- true,+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connectorglobalState);});diff --git a/cypress-tests/cypress/e2e/PaymentTest/00025-ConfigTest.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00025-ConfigTest.cy.jsnew file mode 100644index 0000000000..724233852c--- /dev/null+++ b/cypress-tests/cypress/e2e/PaymentTest/00025-ConfigTest.cy.js@@ -0,0 +1,407 @@+import * as fixtures from "../../fixtures/imports";+import State from "../../utils/State";+import { payment_methods_enabled } from "../PaymentUtils/Commons";+import getConnectorDetails, * as utils from "../PaymentUtils/Utils";++let globalState;++describe("Config Tests", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context(+ "Update collect_billing_details_from_wallet_connector to true and verifying in payment method list, this config should be true",+ () => {+ let should_continue = true;++ beforeEach(function () {+ if (!should_continue) {+ this.skip();+ }+ });++ it("Create Business Profile", () => {+ cy.createBusinessProfileTest(+ fixtures.businessProfile.bpCreate,+ globalState+ );+ });++ it("connector-create-call-test", () => {+ cy.createConnectorCallTest(+ "payment_processor",+ fixtures.createConnectorBody,+ payment_methods_enabled,+ globalState+ );+ });++ it("Create Customer", () => {+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);+ });++ it("Update collect_billing_details_from_wallet_connector to true", () => {+ cy.UpdateBusinessProfileTest(+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ true, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ it("Create Payment Intent", () => {+ let data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntentOffSession"];++ let req_data = data["Request"];+ let res_data = data["Response"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ req_data,+ res_data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (should_continue)+ should_continue = utils.should_continue_further(res_data);+ });++ it("payment_methods-call-test", () => {+ cy.paymentMethodsCallTest(globalState);+ });+ }+ );++ context(+ "Update collect_shipping_details_from_wallet_connector to true and verifying in payment method list, this config should be true",+ () => {+ let should_continue = true;++ beforeEach(function () {+ if (!should_continue) {+ this.skip();+ }+ });++ it("Update collect_shipping_details_from_wallet_connector to true", () => {+ cy.UpdateBusinessProfileTest(+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ it("Create Payment Intent", () => {+ let data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntentOffSession"];++ let req_data = data["Request"];+ let res_data = data["Response"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ req_data,+ res_data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (should_continue)+ should_continue = utils.should_continue_further(res_data);+ });++ it("payment_methods-call-test", () => {+ cy.paymentMethodsCallTest(globalState);+ });+ }+ );++ context(+ "Update always_collect_billing_details_from_wallet_connector to true and verifying in payment method list, this config should be true",+ () => {+ let should_continue = true;++ beforeEach(function () {+ if (!should_continue) {+ this.skip();+ }+ });++ it("Update always_collect_billing_details_from_wallet_connector to true", () => {+ cy.UpdateBusinessProfileTest(+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ true, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ it("Create Payment Intent", () => {+ let data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntentOffSession"];++ let req_data = data["Request"];+ let res_data = data["Response"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ req_data,+ res_data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (should_continue)+ should_continue = utils.should_continue_further(res_data);+ });++ it("payment_methods-call-test", () => {+ cy.paymentMethodsCallTest(globalState);+ });+ }+ );++ context(+ "Update always_collect_shipping_details_from_wallet_connector to true and verifying in payment method list, this config should be true",+ () => {+ let should_continue = true;++ beforeEach(function () {+ if (!should_continue) {+ this.skip();+ }+ });++ it("Update always_collect_shipping_details_from_wallet_connector to true", () => {+ cy.UpdateBusinessProfileTest(+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ true, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ it("Create Payment Intent", () => {+ let data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntentOffSession"];++ let req_data = data["Request"];+ let res_data = data["Response"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ req_data,+ res_data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (should_continue)+ should_continue = utils.should_continue_further(res_data);+ });++ it("payment_methods-call-test", () => {+ cy.paymentMethodsCallTest(globalState);+ });+ }+ );++ context(+ "Update always_collect_shipping_details_from_wallet_connector & collect_shipping_details_from_wallet_connector to true and verifying in payment method list, this config should be true",+ () => {+ let should_continue = true;++ beforeEach(function () {+ if (!should_continue) {+ this.skip();+ }+ });++ it("Update both always & collect_shipping_details_from_wallet_connector to true", () => {+ cy.UpdateBusinessProfileTest(+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ true, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ true, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ it("Create Payment Intent", () => {+ let data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntentOffSession"];++ let req_data = data["Request"];+ let res_data = data["Response"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ req_data,+ res_data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (should_continue)+ should_continue = utils.should_continue_further(res_data);+ });++ it("payment_methods-call-test", () => {+ cy.paymentMethodsCallTest(globalState);+ });+ }+ );+ context(+ "Update always_collect_billing_details_from_wallet_connector & to collect_billing_details_from_wallet_connector to true and verifying in payment method list, this config should be true",+ () => {+ let should_continue = true;++ beforeEach(function () {+ if (!should_continue) {+ this.skip();+ }+ });++ it("Update both always & collect_billing_details_from_wallet_connector to true", () => {+ cy.UpdateBusinessProfileTest(+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ true, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ true, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ it("Create Payment Intent", () => {+ let data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntentOffSession"];++ let req_data = data["Request"];+ let res_data = data["Response"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ req_data,+ res_data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (should_continue)+ should_continue = utils.should_continue_further(res_data);+ });++ it("payment_methods-call-test", () => {+ cy.paymentMethodsCallTest(globalState);+ });+ }+ );++ context(+ "Update all config(Collect address config) to false and verifying in payment method list, both config should be false",+ () => {+ let should_continue = true;++ beforeEach(function () {+ if (!should_continue) {+ this.skip();+ }+ });++ it("Create Business Profile", () => {+ cy.createBusinessProfileTest(+ fixtures.businessProfile.bpCreate,+ globalState+ );+ });++ it("connector-create-call-test", () => {+ cy.createConnectorCallTest(+ "payment_processor",+ fixtures.createConnectorBody,+ payment_methods_enabled,+ globalState+ );+ });++ it("Create Customer", () => {+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);+ });++ it("Update all config to false", () => {+ cy.UpdateBusinessProfileTest(+ fixtures.businessProfile.bpUpdate,+ true, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ it("Create Payment Intent", () => {+ let data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntentOffSession"];++ let req_data = data["Request"];+ let res_data = data["Response"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ req_data,+ res_data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (should_continue)+ should_continue = utils.should_continue_further(res_data);+ });++ it("payment_methods-call-test", () => {+ cy.paymentMethodsCallTest(globalState);+ });+ }+ );+});diff --git a/cypress-tests/cypress/fixtures/business-profile.json b/cypress-tests/cypress/fixtures/business-profile.jsonnew file mode 100644index 0000000000..8d7bf637b5--- /dev/null+++ b/cypress-tests/cypress/fixtures/business-profile.json@@ -0,0 +1,13 @@+{+ "bpCreate": {+ "profile_name": "default"+ },++ "bpUpdate": {+ "is_connector_agnostic_mit_enabled": true,+ "collect_shipping_details_from_wallet_connector": true,+ "collect_billing_details_from_wallet_connector": true,+ "always_collect_billing_details_from_wallet_connector": true,+ "always_collect_shipping_details_from_wallet_connector": true+ }+}diff --git a/cypress-tests/cypress/fixtures/create-business-profile.json b/cypress-tests/cypress/fixtures/create-business-profile.jsondeleted file mode 100644index cdce863615..0000000000--- a/cypress-tests/cypress/fixtures/create-business-profile.json+++ /dev/null@@ -1,3 +0,0 @@-{- "profile_name": "default"-}\ No newline at end of filediff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.jsindex 49fea00491..58768394cb 100644--- a/cypress-tests/cypress/fixtures/imports.js+++ b/cypress-tests/cypress/fixtures/imports.js@@ -1,8 +1,8 @@+import businessProfile from "./business-profile.json";import captureBody from "./capture-flow-body.json";import configs from "./configs.json";import confirmBody from "./confirm-body.json";import apiKeyCreateBody from "./create-api-key-body.json";-import createBusinessProfile from "./create-business-profile.json";import createConfirmPaymentBody from "./create-confirm-body.json";import createConnectorBody from "./create-connector-body.json";import customerCreateBody from "./create-customer-body.json";@@ -20,7 +20,6 @@ import routingConfigBody from "./routing-config-body.json";import saveCardConfirmBody from "./save-card-confirm-body.json";import sessionTokenBody from "./session-token.json";import apiKeyUpdateBody from "./update-api-key-body.json";-import updateBusinessProfile from "./update-business-profile.json";import updateConnectorBody from "./update-connector-body.json";import customerUpdateBody from "./update-customer-body.json";import voidBody from "./void-payment-body.json";@@ -29,11 +28,11 @@ import ntidConfirmBody from "./create-ntid-mit.json";export {apiKeyCreateBody,apiKeyUpdateBody,+ businessProfile,captureBody,citConfirmBody,configs,confirmBody,- createBusinessProfile,createConfirmPaymentBody,createConnectorBody,createPaymentBody,@@ -51,7 +50,6 @@ export {routingConfigBody,saveCardConfirmBody,sessionTokenBody,- updateBusinessProfile,updateConnectorBody,voidBody,};diff --git a/cypress-tests/cypress/fixtures/update-business-profile.json b/cypress-tests/cypress/fixtures/update-business-profile.jsondeleted file mode 100644index 9d69534bae..0000000000--- a/cypress-tests/cypress/fixtures/update-business-profile.json+++ /dev/null@@ -1,3 +0,0 @@-{- "is_connector_agnostic_mit_enabled": true-}diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 17c2270efe..ee64d3247c 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -196,9 +196,25 @@ Cypress.Commands.add(Cypress.Commands.add("UpdateBusinessProfileTest",- (updateBusinessProfile, is_connector_agnostic_mit_enabled, globalState) => {+ (+ updateBusinessProfile,+ is_connector_agnostic_mit_enabled,+ collect_billing_details_from_wallet_connector,+ collect_shipping_details_from_wallet_connector,+ always_collect_billing_details_from_wallet_connector,+ always_collect_shipping_details_from_wallet_connector,+ globalState+ ) => {updateBusinessProfile.is_connector_agnostic_mit_enabled =is_connector_agnostic_mit_enabled;+ updateBusinessProfile.collect_shipping_details_from_wallet_connector =+ collect_shipping_details_from_wallet_connector;+ updateBusinessProfile.collect_billing_details_from_wallet_connector =+ collect_billing_details_from_wallet_connector;+ updateBusinessProfile.always_collect_billing_details_from_wallet_connector =+ always_collect_billing_details_from_wallet_connector;+ updateBusinessProfile.always_collect_shipping_details_from_wallet_connector =+ always_collect_shipping_details_from_wallet_connector;const merchant_id = globalState.get("merchantId");const profile_id = globalState.get("profileId");cy.request({@@ -213,6 +229,24 @@ Cypress.Commands.add(failOnStatusCode: false,}).then((response) => {logRequestId(response.headers["x-request-id"]);+ if (response.status === 200) {+ globalState.set(+ "collectBillingDetails",+ response.body.collect_billing_details_from_wallet_connector+ );+ globalState.set(+ "collectShippingDetails",+ response.body.collect_shipping_details_from_wallet_connector+ );+ globalState.set(+ "alwaysCollectBillingDetails",+ response.body.always_collect_billing_details_from_wallet_connector+ );+ globalState.set(+ "alwaysCollectShippingDetails",+ response.body.always_collect_shipping_details_from_wallet_connector+ );+ }});});@@ -1001,6 +1035,33 @@ Cypress.Commands.add("paymentMethodsCallTest", (globalState) => {expect(response.headers["content-type"]).to.include("application/json");expect(response.body).to.have.property("redirect_url");expect(response.body).to.have.property("payment_methods");+ if (+ globalState.get("collectBillingDetails") === true ||+ globalState.get("alwaysCollectBillingDetails") === true+ ) {+ expect(+ response.body.collect_billing_details_from_wallets,+ "collectBillingDetailsFromWallets"+ ).to.be.true;+ } else+ expect(+ response.body.collect_billing_details_from_wallets,+ "collectBillingDetailsFromWallets"+ ).to.be.false;++ if (+ globalState.get("collectShippingDetails") === true ||+ globalState.get("alwaysCollectShippingDetails") === true+ ) {+ expect(+ response.body.collect_shipping_details_from_wallets,+ "collectShippingDetailsFromWallets"+ ).to.be.true;+ } else+ expect(+ response.body.collect_shipping_details_from_wallets,+ "collectShippingDetailsFromWallets"+ ).to.be.false;globalState.set("paymentID", paymentIntentID);cy.log(response);});