mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
test(cypress): add test for In Memory Cache (#6961)
Co-authored-by: Sumit Kumar <sumit.kumar@Sumit-Kumar-D9GXRYR75W.local> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Kartikeya Hegde <karthikey.hegde@juspay.in>
This commit is contained in:
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user