ci(cypress): Added Config Testcases (#6622)

Co-authored-by: Pa1NarK <69745008+pixincreate@users.noreply.github.com>
This commit is contained in:
Gnanasundari24
2024-11-28 14:38:31 +05:30
committed by GitHub
parent 9be012826a
commit 2c865156a2
7 changed files with 512 additions and 21 deletions

View File

@ -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_connector
globalState
);
});
@ -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_connector
globalState
);
});
@ -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_connector
globalState
);
});

View File

@ -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);
});
}
);
});

View File

@ -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
}
}

View File

@ -1,3 +0,0 @@
{
"profile_name": "default"
}

View File

@ -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,
};

View File

@ -1,3 +0,0 @@
{
"is_connector_agnostic_mit_enabled": true
}

View File

@ -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);
});