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

test(cypress): add test for In Memory Cache (#6961)

sumitdahiya125d8d8c400bbda
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00025-ConfigTest.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00025-BusinessProfileConfigs.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/PaymentTest/00025-ConfigTest.cy.js
rename to cypress-tests/cypress/e2e/PaymentTest/00025-BusinessProfileConfigs.cy.js
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00028-MemoryCacheConfigs.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00028-MemoryCacheConfigs.cy.js
new file mode 100644
index 0000000000..afa7ceda0d
--- /dev/null
+++ b/cypress-tests/cypress/e2e/PaymentTest/00028-MemoryCacheConfigs.cy.js
@@ -0,0 +1,35 @@
+import State from "../../utils/State";
+
+let globalState;
+
+describe("In Memory Cache Test", () => {
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Config flows", () => {
+ const key = "test-key";
+ const value = "test value";
+ const newValue = "new test value";
+
+ it("Create Configs", () => {
+ cy.createConfigs(globalState, key, value);
+ cy.fetchConfigs(globalState, key, value);
+ });
+
+ it("Update Configs", () => {
+ cy.updateConfigs(globalState, key, newValue);
+ cy.fetchConfigs(globalState, key, newValue);
+ });
+
+ it("delete configs", () => {
+ cy.deleteConfigs(globalState, key, newValue);
+ });
+ });
+});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index e2e83edaf0..1b7b41a035 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -3369,3 +3369,95 @@ Cypress.Commands.add("incrementalAuth", (globalState, data) => {
}
});
});
+
+Cypress.Commands.add("createConfigs", (globalState, key, value) => {
+ const base_url = globalState.get("baseUrl");
+ const api_key = globalState.get("adminApiKey");
+
+ cy.request({
+ method: "POST",
+ url: `${base_url}/configs/`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": api_key,
+ },
+ body: {
+ key: key,
+ value: value,
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ expect(response.status).to.equal(200);
+ expect(response.body).to.have.property("key").to.equal(key);
+ expect(response.body).to.have.property("value").to.equal(value);
+ });
+});
+
+Cypress.Commands.add("fetchConfigs", (globalState, key, value) => {
+ const base_url = globalState.get("baseUrl");
+ const api_key = globalState.get("adminApiKey");
+
+ cy.request({
+ method: "GET",
+ url: `${base_url}/configs/${key}`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": api_key,
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ expect(response.status).to.equal(200);
+ expect(response.body).to.have.property("key").to.equal(key);
+ expect(response.body).to.have.property("value").to.equal(value);
+ });
+});
+
+Cypress.Commands.add("updateConfigs", (globalState, key, value) => {
+ const base_url = globalState.get("baseUrl");
+ const api_key = globalState.get("adminApiKey");
+
+ cy.request({
+ method: "POST",
+ url: `${base_url}/configs/${key}`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": api_key,
+ },
+ body: {
+ key: key,
+ value: value,
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ expect(response.status).to.equal(200);
+ expect(response.body).to.have.property("key").to.equal(key);
+ expect(response.body).to.have.property("value").to.equal(value);
+ });
+});
+
+Cypress.Commands.add("deleteConfigs", (globalState, key, value) => {
+ const base_url = globalState.get("baseUrl");
+ const api_key = globalState.get("adminApiKey");
+
+ cy.request({
+ method: "DELETE",
+ url: `${base_url}/configs/${key}`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": api_key,
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ expect(response.status).to.equal(200);
+ expect(response.body).to.have.property("key").to.equal(key);
+ expect(response.body).to.have.property("value").to.equal(value);
+ });
+});