Skip to content

Commit 8319a37

Browse files
authored
Refactor GraphQL intercept aliases using a map for better readability (#1603)
* Refactor GraphQL intercept aliases using a map for better readability * fix lint
1 parent 754e183 commit 8319a37

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

cypress/tests/ui/bankaccounts.spec.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@ describe("Bank Accounts", function () {
1616
cy.intercept("GET", "/notifications").as("getNotifications");
1717

1818
cy.intercept("POST", apiGraphQL, (req) => {
19-
const { body } = req;
19+
const operationAliases: Record<string, string> = {
20+
ListBankAccount: "gqlListBankAccountQuery",
21+
CreateBankAccount: "gqlCreateBankAccountMutation",
22+
DeleteBankAccount: "gqlDeleteBankAccountMutation",
23+
};
2024

21-
if (body.hasOwnProperty("operationName") && body.operationName === "ListBankAccount") {
22-
req.alias = "gqlListBankAccountQuery";
23-
}
25+
const { body } = req;
2426

25-
if (body.hasOwnProperty("operationName") && body.operationName === "CreateBankAccount") {
26-
req.alias = "gqlCreateBankAccountMutation";
27-
}
27+
const operationName = body?.operationName;
2828

29-
if (body.hasOwnProperty("operationName") && body.operationName === "DeleteBankAccount") {
30-
req.alias = "gqlDeleteBankAccountMutation";
29+
if (
30+
body.hasOwnProperty("operationName") &&
31+
operationName &&
32+
operationAliases[operationName]
33+
) {
34+
req.alias = operationAliases[operationName];
3135
}
3236
});
3337

0 commit comments

Comments
 (0)