From b91bf38f1bdcf481a6c2422cbb771ba0cbcad3c3 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 2 Feb 2023 14:25:08 +0100 Subject: [PATCH] add response check to submit login e2e test step --- .../step_definitions/user_authentication_steps.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/user_authentication_steps.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_authentication_steps.ts index bc637fdbb..d469180b3 100644 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/user_authentication_steps.ts +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_authentication_steps.ts @@ -16,17 +16,20 @@ When("the user submits no credentials", () => { When( "the user submits the credentials {string} {string}", (email: string, password: string) => { - cy.intercept("POST", "/graphql").as("login"); - // cy.intercept('POST', '/graphql', (req) => { - // if (req.body.hasOwnProperty('query') && req.body.query.includes('mutation')) { - // req.alias = 'login' - // } - // }); + cy.intercept("POST", "/graphql", (req) => { + if ( + req.body.hasOwnProperty("query") && + req.body.query.includes("mutation") + ) { + req.alias = "login"; + } + }); loginPage.enterEmail(email); loginPage.enterPassword(password); loginPage.submitLogin(); cy.wait("@login").then((interception) => { + expect(interception.response.statusCode).equals(200); expect(JSON.stringify(interception.response.body)).contains(email); }); }