Skip to content

Commit

Permalink
refactor(configs): re-use config function
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate committed Jan 6, 2025
1 parent 9acee2a commit a0a3c2b
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import State from "../../../utils/State";

let globalState;

describe("In Memory Cache Test", () => {
describe("In Memory Cache configs", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
Expand All @@ -19,17 +19,17 @@ describe("In Memory Cache Test", () => {
const newValue = "new test value";

it("Create Configs", () => {
cy.createConfigs(globalState, key, value);
cy.fetchConfigs(globalState, key, value);
cy.setConfigs(globalState, key, value, "CREATE");
cy.setConfigs(globalState, key, value, "FETCH");
});

it("Update Configs", () => {
cy.updateConfigs(globalState, key, newValue);
cy.fetchConfigs(globalState, key, newValue);
cy.setConfigs(globalState, key, newValue, "UPDATE");
// cy.setConfigs(globalState, key, value, "FETCH");
});

it("delete configs", () => {
cy.deleteConfigs(globalState, key, newValue);
cy.setConfigs(globalState, key, newValue, "DELETE");
});
});
});
108 changes: 84 additions & 24 deletions cypress-tests/cypress/e2e/spec/Routing/00003-Retries.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ describe("Auto Retries & Step Up 3DS", () => {
context("Auto Retries", () => {
context("[Config: enable] Auto retries", () => {
it("Enable auto retries", () => {
cy.updateConfig("autoRetry", globalState, "true");
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`should_call_gsm_${merchantId}`,
"true",
"UPDATE"
);
});

context("Max auto retries", () => {
Expand Down Expand Up @@ -93,9 +99,15 @@ describe("Auto Retries & Step Up 3DS", () => {
});

context("Max auto retries = 2", () => {
const max_auto_retries = 2;
const maxAutoRetries = 2;
it("Update max auto retries", () => {
cy.updateConfig("maxRetries", globalState, `${max_auto_retries}`);
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`max_auto_retries_enabled_${merchantId}`,
maxAutoRetries,
"UPDATE"
);
});

context("Make payment", () => {
Expand Down Expand Up @@ -133,16 +145,22 @@ describe("Auto Retries & Step Up 3DS", () => {
globalState,
null,
true,
max_auto_retries + 1
maxAutoRetries + 1
);
});
});
});

context("Max auto retries = 1", () => {
const max_auto_retries = 1;
const maxAutoRetries = 1;
it("Update max auto retries", () => {
cy.updateConfig("maxRetries", globalState, `${max_auto_retries}`);
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`max_auto_retries_enabled_${merchantId}`,
maxAutoRetries,
"UPDATE"
);
});

context("Make payment", () => {
Expand Down Expand Up @@ -180,15 +198,21 @@ describe("Auto Retries & Step Up 3DS", () => {
globalState,
null,
true,
max_auto_retries + 1
maxAutoRetries + 1
);
});
});
});
context("Max auto retries = 0", () => {
const max_auto_retries = 0;
const maxAutoRetries = 0;
it("Update max auto retries", () => {
cy.updateConfig("maxRetries", globalState, `${max_auto_retries}`);
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`max_auto_retries_enabled_${merchantId}`,
maxAutoRetries,
"UPDATE"
);
});

context("Make payment", () => {
Expand Down Expand Up @@ -226,7 +250,7 @@ describe("Auto Retries & Step Up 3DS", () => {
globalState,
null,
true,
max_auto_retries + 1
maxAutoRetries + 1
);
});
});
Expand Down Expand Up @@ -280,9 +304,15 @@ describe("Auto Retries & Step Up 3DS", () => {
});

context("Max auto retries = 2", () => {
const max_auto_retries = 2;
const maxAutoRetries = 2;
it("Update max auto retries", () => {
cy.updateConfig("maxRetries", globalState, `${max_auto_retries}`);
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`max_auto_retries_enabled_${merchantId}`,
maxAutoRetries,
"UPDATE"
);
});

context("Make payment", () => {
Expand Down Expand Up @@ -320,16 +350,22 @@ describe("Auto Retries & Step Up 3DS", () => {
globalState,
null,
true,
max_auto_retries + 1
maxAutoRetries + 1
);
});
});
});

context("Max auto retries = 1", () => {
const max_auto_retries = 1;
const maxAutoRetries = 1;
it("Update max auto retries", () => {
cy.updateConfig("maxRetries", globalState, `${max_auto_retries}`);
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`max_auto_retries_enabled_${merchantId}`,
maxAutoRetries,
"UPDATE"
);
});

context("Make payment", () => {
Expand Down Expand Up @@ -367,16 +403,22 @@ describe("Auto Retries & Step Up 3DS", () => {
globalState,
null,
true,
max_auto_retries + 1
maxAutoRetries + 1
);
});
});
});

context("Max auto retries = 0", () => {
const max_auto_retries = 0;
const maxAutoRetries = 0;
it("Update max auto retries", () => {
cy.updateConfig("maxRetries", globalState, `${max_auto_retries}`);
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`max_auto_retries_enabled_${merchantId}`,
maxAutoRetries,
"UPDATE"
);
});

context("Make payment", () => {
Expand Down Expand Up @@ -414,7 +456,7 @@ describe("Auto Retries & Step Up 3DS", () => {
globalState,
null,
true,
max_auto_retries + 1
maxAutoRetries + 1
);
});
});
Expand All @@ -429,14 +471,26 @@ describe("Auto Retries & Step Up 3DS", () => {
});

it("[Config: enable] Step up for Stripe", () => {
cy.updateConfig("stepUp", globalState, '["stripe"]');
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`step_up_enabled_${merchantId}`,
'["stripe"]',
"UPDATE"
);
});
});

context("Make Payment", () => {
const max_auto_retries = 1;
const maxAutoRetries = 1;
it("Update max auto retries", () => {
cy.updateConfig("maxRetries", globalState, `${max_auto_retries}`);
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`max_auto_retries_enabled_${merchantId}`,
maxAutoRetries,
"UPDATE"
);
});

it("Payment create call", () => {
Expand Down Expand Up @@ -468,7 +522,7 @@ describe("Auto Retries & Step Up 3DS", () => {
globalState,
null,
true,
max_auto_retries + 1
maxAutoRetries + 1
);
});
});
Expand All @@ -477,7 +531,13 @@ describe("Auto Retries & Step Up 3DS", () => {

context("[Config: disable] Auto retries", () => {
it("[Config: disable] Auto retries", () => {
cy.updateConfig("autoRetry", globalState, "false");
const merchantId = globalState.get("merchantId");
cy.setConfigs(
globalState,
`should_call_gsm_${merchantId}`,
"false",
"UPDATE"
);
});

it("[Config: disable] Step up GSM", () => {
Expand Down
Loading

0 comments on commit a0a3c2b

Please sign in to comment.