From ba98797009719de6744ee901d6d1adf3317d251d Mon Sep 17 00:00:00 2001 From: mahula Date: Mon, 26 Jun 2023 13:55:45 +0200 Subject: [PATCH 1/5] add deleted user and not registered user scenarios to e2e password reset feature --- .../User.Authentication.ResetPassword.feature | 29 +++++++++++++++---- .../support/step_definitions/email_steps.ts | 15 ++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/e2e-tests/cypress/e2e/User.Authentication.ResetPassword.feature b/e2e-tests/cypress/e2e/User.Authentication.ResetPassword.feature index 50a29d320..ab9213cb9 100644 --- a/e2e-tests/cypress/e2e/User.Authentication.ResetPassword.feature +++ b/e2e-tests/cypress/e2e/User.Authentication.ResetPassword.feature @@ -2,13 +2,27 @@ Feature: User Authentication - reset password As a user I want to reset my password from the sign in page - # TODO for these pre-conditions utilize seeding or API check, if user exists in test system - # Background: - # Given the following "users" are in the database: - # | email | password | name | - # | raeuber@hotzenplotz.de | Aa12345_ | Räuber Hotzenplotz | - + Scenario: Reset password as not registered user + Given the user navigates to page "/login" + And the user navigates to the forgot password page + When the user enters the e-mail address "not@registered.com" + And the user submits the e-mail form + Then the user receives no password reset e-mail + + Scenario: Reset password as deleted user + # Given the following "users" are in the database: + # | email | password | name | + # | stephen@hawking.uk | Aa12345_ | Stephen Hawking | + Given the user navigates to page "/login" + And the user navigates to the forgot password page + When the user enters the e-mail address "stephen@hawking.uk" + And the user submits the e-mail form + Then the user receives no password reset e-mail + Scenario: Reset password from signin page successfully + # Given the following "users" are in the database: + # | email | password | name | + # | raeuber@hotzenplotz.de | Aa12345_ | Räuber Hotzenplotz | Given the user navigates to page "/login" And the user navigates to the forgot password page When the user enters the e-mail address "raeuber@hotzenplotz.de" @@ -23,3 +37,6 @@ Feature: User Authentication - reset password And the user cannot login But the user submits the credentials "raeuber@hotzenplotz.de" "12345Aa_" And the user is logged in with username "Räuber Hotzenplotz" + + + diff --git a/e2e-tests/cypress/support/step_definitions/email_steps.ts b/e2e-tests/cypress/support/step_definitions/email_steps.ts index d31e2474e..fdf273def 100644 --- a/e2e-tests/cypress/support/step_definitions/email_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/email_steps.ts @@ -51,6 +51,21 @@ Then('the user receives an e-mail containing the {string} link', (linkName: stri ) }) +Then('the user receives no password reset e-mail', () { + cy.origin( + Cypress.env('mailserverURL'), + { args: { userEMailSite } }, + ({ userEMailSite }) => { + cy.visit('/') + cy.get(userEMailSite.emailInbox).should('be.visible') + + cy.get(userEMailSite.emailList) + .find('.email-item') + .should('have.length', 0) + } + ) +}) + When('the user opens the {string} link in the browser', (linkName: string) => { cy.task('getEmailLink').then((emailLink) => { cy.visit(emailLink) From 8553bf59fda699587bbb583be8a189dc35d43e77 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 27 Jun 2023 09:59:09 +0200 Subject: [PATCH 2/5] check visibility of email list in e2e email test step --- e2e-tests/cypress/support/step_definitions/email_steps.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-tests/cypress/support/step_definitions/email_steps.ts b/e2e-tests/cypress/support/step_definitions/email_steps.ts index fdf273def..27c389ab8 100644 --- a/e2e-tests/cypress/support/step_definitions/email_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/email_steps.ts @@ -51,13 +51,13 @@ Then('the user receives an e-mail containing the {string} link', (linkName: stri ) }) -Then('the user receives no password reset e-mail', () { +Then('the user receives no password reset e-mail', () => { cy.origin( Cypress.env('mailserverURL'), { args: { userEMailSite } }, ({ userEMailSite }) => { cy.visit('/') - cy.get(userEMailSite.emailInbox).should('be.visible') + cy.get(userEMailSite.emailList).should('be.visible') cy.get(userEMailSite.emailList) .find('.email-item') From eb99a3243318a9a28f91a1f18c37278f892ada1f Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 27 Jun 2023 09:59:09 +0200 Subject: [PATCH 3/5] check visibility of email list in e2e email test step --- e2e-tests/cypress/support/step_definitions/email_steps.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-tests/cypress/support/step_definitions/email_steps.ts b/e2e-tests/cypress/support/step_definitions/email_steps.ts index 27c389ab8..830e86fe5 100644 --- a/e2e-tests/cypress/support/step_definitions/email_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/email_steps.ts @@ -57,7 +57,8 @@ Then('the user receives no password reset e-mail', () => { { args: { userEMailSite } }, ({ userEMailSite }) => { cy.visit('/') - cy.get(userEMailSite.emailList).should('be.visible') + cy.wait(300) + cy.get(userEMailSite.emailInbox).should('be.visible') cy.get(userEMailSite.emailList) .find('.email-item') From b4d54cfc6456265dae63f961ff3327c4bcd36d1b Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 29 Jun 2023 10:11:50 +0200 Subject: [PATCH 4/5] refactor e2e email step definition --- .../cypress/support/step_definitions/email_steps.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e-tests/cypress/support/step_definitions/email_steps.ts b/e2e-tests/cypress/support/step_definitions/email_steps.ts index 207e5781f..80581ad01 100644 --- a/e2e-tests/cypress/support/step_definitions/email_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/email_steps.ts @@ -49,7 +49,7 @@ Then('the user receives an e-mail containing the {string} link', (linkName: stri .invoke('text') .then((text) => { const emailLink = text.match(linkPattern)[0] - cy.task('setEmailLink', emailLink) + cy.task('setEmailLink', emailLink ) }) }, ) @@ -64,9 +64,12 @@ Then('the user receives no password reset e-mail', () => { cy.wait(300) cy.get(userEMailSite.emailInbox).should('be.visible') - cy.get(userEMailSite.emailList) - .find('.email-item') - .should('have.length', 0) + cy.get(userEMailSite.emailList).then(($emailList) => { + const emailItems = $emailList.find('.email-item') + if (emailItems.length > 0) { + expect(emailItems.filter(`:contains("asswor")`).length).to.equal(0) + } + }) } ) }) From 00c15a9c18fe7fdb63310241905e0c030efddbd3 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 29 Jun 2023 11:45:59 +0200 Subject: [PATCH 5/5] fix linting --- .../support/step_definitions/email_steps.ts | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/e2e-tests/cypress/support/step_definitions/email_steps.ts b/e2e-tests/cypress/support/step_definitions/email_steps.ts index 80581ad01..414490cda 100644 --- a/e2e-tests/cypress/support/step_definitions/email_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/email_steps.ts @@ -49,29 +49,25 @@ Then('the user receives an e-mail containing the {string} link', (linkName: stri .invoke('text') .then((text) => { const emailLink = text.match(linkPattern)[0] - cy.task('setEmailLink', emailLink ) + cy.task('setEmailLink', emailLink) }) }, ) }) Then('the user receives no password reset e-mail', () => { - cy.origin( - Cypress.env('mailserverURL'), - { args: { userEMailSite } }, - ({ userEMailSite }) => { - cy.visit('/') - cy.wait(300) - cy.get(userEMailSite.emailInbox).should('be.visible') + cy.origin(Cypress.env('mailserverURL'), { args: { userEMailSite } }, ({ userEMailSite }) => { + cy.visit('/') + cy.wait(300) + cy.get(userEMailSite.emailInbox).should('be.visible') - cy.get(userEMailSite.emailList).then(($emailList) => { - const emailItems = $emailList.find('.email-item') - if (emailItems.length > 0) { - expect(emailItems.filter(`:contains("asswor")`).length).to.equal(0) - } - }) - } - ) + cy.get(userEMailSite.emailList).then(($emailList) => { + const emailItems = $emailList.find('.email-item') + if (emailItems.length > 0) { + expect(emailItems.filter(`:contains("asswor")`).length).to.equal(0) + } + }) + }) }) When(