Skip to content

Commit

Permalink
Refactor GraphQL intercept aliases using a map for better readability (
Browse files Browse the repository at this point in the history
…#1603)

* Refactor GraphQL intercept aliases using a map for better readability

* fix lint
  • Loading branch information
artshllk authored Dec 20, 2024
1 parent 754e183 commit 8319a37
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions cypress/tests/ui/bankaccounts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ describe("Bank Accounts", function () {
cy.intercept("GET", "/notifications").as("getNotifications");

cy.intercept("POST", apiGraphQL, (req) => {
const { body } = req;
const operationAliases: Record<string, string> = {
ListBankAccount: "gqlListBankAccountQuery",
CreateBankAccount: "gqlCreateBankAccountMutation",
DeleteBankAccount: "gqlDeleteBankAccountMutation",
};

if (body.hasOwnProperty("operationName") && body.operationName === "ListBankAccount") {
req.alias = "gqlListBankAccountQuery";
}
const { body } = req;

if (body.hasOwnProperty("operationName") && body.operationName === "CreateBankAccount") {
req.alias = "gqlCreateBankAccountMutation";
}
const operationName = body?.operationName;

if (body.hasOwnProperty("operationName") && body.operationName === "DeleteBankAccount") {
req.alias = "gqlDeleteBankAccountMutation";
if (
body.hasOwnProperty("operationName") &&
operationName &&
operationAliases[operationName]
) {
req.alias = operationAliases[operationName];
}
});

Expand Down

0 comments on commit 8319a37

Please sign in to comment.