Skip to content

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

feat: add support for enabling kv for all merchants in cypress tests (#12747)

Hrithikesh005a95611eed
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index c66df9b0db..bae08d6221 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -652,6 +652,48 @@ Cypress.Commands.add(
globalState.set(publishableKeyStateKey, response.body.publishable_key);
globalState.set("merchantDetails", response.body.merchant_details);
globalState.set("organizationId", response.body.organization_id);
+
+ if (globalState.get("kvEnabled")) {
+ cy.merchantKvEnableCallTest(
+ { merchant_id: merchantId, kv_enabled: true },
+ globalState
+ );
+ }
+ });
+ });
+ }
+);
+
+Cypress.Commands.add(
+ "merchantKvEnableCallTest",
+ (merchantKvEnableBody, globalState, options = {}) => {
+ const { expectedStatus = 200, expectedErrorCode = null } = options;
+
+ const merchant_id = globalState.get("merchantId");
+
+ cy.request({
+ method: "POST",
+ url: `${globalState.get("baseUrl")}/accounts/${merchant_id}/kv`,
+ headers: {
+ Accept: "application/json",
+ "Content-Type": "application/json",
+ "api-key": globalState.get("adminApiKey"),
+ },
+ body: merchantKvEnableBody,
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ expect(response.status).to.equal(expectedStatus);
+
+ if (expectedStatus !== 200) {
+ if (expectedErrorCode) {
+ expect(response.body).to.have.property("error");
+ expect(response.body.error.code).to.equal(expectedErrorCode);
+ }
+ return;
+ }
});
});
}
diff --git a/cypress-tests/cypress/utils/State.js b/cypress-tests/cypress/utils/State.js
index 484139a793..b056e1e7b3 100644
--- a/cypress-tests/cypress/utils/State.js
+++ b/cypress-tests/cypress/utils/State.js
@@ -18,6 +18,7 @@ class State {
this.data["proxyHttps"] = Cypress.env("PROXY_HTTPS");
this.data["methodFlow"] = Cypress.env("METHOD_FLOW");
this.data["validationServiceUrl"] = Cypress.env("VALIDATION_SERVICE_URL");
+ this.data["kvEnabled"] = Cypress.env("KV_ENABLED");
this.data["superpositionBaseUrl"] = Cypress.env("SUPERPOSITION_BASE_URL");
this.data["superpositionSecret"] = Cypress.env("SUPERPOSITION_SECRET");
this.data["superpositionApiKey"] = Cypress.env("SUPERPOSITION_API_KEY");