diff --git a/cypress/tests/ui/bankaccounts.spec.ts b/cypress/tests/ui/bankaccounts.spec.ts index 4658361bf..3118ec46b 100644 --- a/cypress/tests/ui/bankaccounts.spec.ts +++ b/cypress/tests/ui/bankaccounts.spec.ts @@ -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 = { + 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]; } });