diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index badb47e87..5eadf1e94 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -550,7 +550,7 @@ jobs: run: | cd e2e-tests/ yarn - yarn run cypress run --spec cypress/e2e/User.Authentication.feature,cypress/e2e/User.Authentication.ResetPassword.feature + yarn run cypress run --spec cypress/e2e/User.Authentication.feature,cypress/e2e/User.Authentication.ResetPassword.feature,cypress/e2e/User.Registration.feature - name: End-to-end tests | if tests failed, upload screenshots if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} uses: actions/upload-artifact@v3 diff --git a/e2e-tests/cypress.config.ts b/e2e-tests/cypress.config.ts index 16ebb0e97..9dff98a9b 100644 --- a/e2e-tests/cypress.config.ts +++ b/e2e-tests/cypress.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'cypress' import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor' import browserify from '@badeball/cypress-cucumber-preprocessor/browserify' -let resetPasswordLink: string +let emailLink: string async function setupNodeEvents( on: Cypress.PluginEvents, @@ -18,11 +18,11 @@ async function setupNodeEvents( ) on('task', { - setResetPasswordLink: (val) => { - return (resetPasswordLink = val) + setEmailLink: (link: string) => { + return (emailLink = link) }, - getResetPasswordLink: () => { - return resetPasswordLink + getEmailLink: () => { + return emailLink }, }) diff --git a/e2e-tests/cypress/e2e/User.Authentication.ResetPassword.feature b/e2e-tests/cypress/e2e/User.Authentication.ResetPassword.feature index 55ca87215..b0f660709 100644 --- a/e2e-tests/cypress/e2e/User.Authentication.ResetPassword.feature +++ b/e2e-tests/cypress/e2e/User.Authentication.ResetPassword.feature @@ -13,8 +13,8 @@ Feature: User Authentication - reset password And the user navigates to the forgot password page When the user enters the e-mail address "bibi@bloxberg.de" And the user submits the e-mail form - Then the user receives an e-mail containing the password reset link - When the user opens the password reset link in the browser + Then the user receives an e-mail containing the "password reset" link + When the user opens the "password reset" link in the browser And the user enters the password "12345Aa_" And the user repeats the password "12345Aa_" And the user submits the password form diff --git a/e2e-tests/cypress/e2e/User.Registration.feature b/e2e-tests/cypress/e2e/User.Registration.feature index ed53bb4b0..a50d57ea2 100644 --- a/e2e-tests/cypress/e2e/User.Registration.feature +++ b/e2e-tests/cypress/e2e/User.Registration.feature @@ -2,12 +2,16 @@ Feature: User registration As a user I want to register to create an account - @skip Scenario: Register successfully Given the user navigates to page "/register" When the user fills name and email "Regina" "Register" "regina@register.com" And the user agrees to the privacy policy And the user submits the registration form - Then the user can use a provided activation link - And the user can set a password "Aa12345_" - And the user can login with the credentials "regina@register.com" "Aa12345_" + Then the user receives an e-mail containing the "activation" link + When the user opens the "activation" link in the browser + And the user enters the password "12345Aa_" + And the user repeats the password "12345Aa_" + And the user submits the password form + And the user clicks the sign in button + Then the user submits the credentials "regina@register.com" "12345Aa_" + And the user is logged in with username "Regina Register" diff --git a/e2e-tests/cypress/e2e/models/RegistrationPage.ts b/e2e-tests/cypress/e2e/models/RegistrationPage.ts index 8cae26a26..2e9b48648 100644 --- a/e2e-tests/cypress/e2e/models/RegistrationPage.ts +++ b/e2e-tests/cypress/e2e/models/RegistrationPage.ts @@ -4,7 +4,7 @@ export class RegistrationPage { // selectors firstnameInput = '#registerFirstname' lastnameInput = '#registerLastname' - emailInput = '#Email-input-field' + emailInput = 'input[type=email]' checkbox = '#registerCheckbox' submitBtn = '[type=submit]' @@ -35,7 +35,7 @@ export class RegistrationPage { cy.get(this.checkbox).click({ force: true }) } - submitRegistrationPage() { + submitRegistrationForm() { cy.get(this.submitBtn).should('be.enabled') cy.get(this.submitBtn).click() } diff --git a/e2e-tests/cypress/e2e/models/ResetPasswordPage.ts b/e2e-tests/cypress/e2e/models/ResetPasswordPage.ts index 20134de6d..153b41a82 100644 --- a/e2e-tests/cypress/e2e/models/ResetPasswordPage.ts +++ b/e2e-tests/cypress/e2e/models/ResetPasswordPage.ts @@ -2,19 +2,19 @@ export class ResetPasswordPage { // selectors - newPasswordBlock = '#new-password-input-field' - newPasswordRepeatBlock = '#repeat-new-password-input-field' + newPasswordInput = '#new-password-input-field' + newPasswordRepeatInput = '#repeat-new-password-input-field' resetPasswordBtn = 'button[type=submit]' resetPasswordMessageBlock = '[data-test="reset-password-message"]' signinBtn = '.btn.test-message-button' enterNewPassword(password: string) { - cy.get(this.newPasswordBlock).find('input[type=password]').type(password) + cy.get(this.newPasswordInput).find('input[type=password]').type(password) return this } repeatNewPassword(password: string) { - cy.get(this.newPasswordRepeatBlock) + cy.get(this.newPasswordRepeatInput) .find('input[type=password]') .type(password) return this diff --git a/e2e-tests/cypress/support/step_definitions/email_steps.ts b/e2e-tests/cypress/support/step_definitions/email_steps.ts index b313442f2..d31e2474e 100644 --- a/e2e-tests/cypress/support/step_definitions/email_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/email_steps.ts @@ -5,41 +5,55 @@ import { UserEMailSite } from '../../e2e/models/UserEMailSite' const userEMailSite = new UserEMailSite() const resetPasswordPage = new ResetPasswordPage() -Then('the user receives an e-mail containing the password reset link', () => { +Then('the user receives an e-mail containing the {string} link', (linkName: string) => { + let emailSubject: string + let linkPattern: RegExp + + switch (linkName) { + case 'activation': + emailSubject = 'Email Verification' + linkPattern = /\/checkEmail\/[0-9]+\d/ + break + case 'password reset': + emailSubject = 'asswor' + linkPattern = /\/reset-password\/[0-9]+\d/ + break + default: + throw new Error(`Error in "Then the user receives an e-mail containing the {string} link" step: incorrect linkname string "${linkName}"`) + } + cy.origin( Cypress.env('mailserverURL'), - { args: userEMailSite }, - (userEMailSite) => { - const linkPattern = /\/reset-password\/[0-9]+\d/ - - cy.visit('/') // navigate to user's e-maile site (on fake mail server) + { args: { emailSubject, linkPattern, userEMailSite } }, + ({ emailSubject, linkPattern, userEMailSite }) => { + cy.visit('/') // navigate to user's e-mail site (on fake mail server) cy.get(userEMailSite.emailInbox).should('be.visible') cy.get(userEMailSite.emailList) .find('.email-item') - .filter(':contains(asswor)') + .filter(`:contains(${emailSubject})`) .first() .click() cy.get(userEMailSite.emailMeta) .find(userEMailSite.emailSubject) - .contains('asswor') + .contains(emailSubject) - cy.get('.email-content') + cy.get('.email-content', { timeout: 2000}) .find('.plain-text') .contains(linkPattern) .invoke('text') .then((text) => { - const resetPasswordLink = text.match(linkPattern)[0] - cy.task('setResetPasswordLink', resetPasswordLink) + const emailLink = text.match(linkPattern)[0] + cy.task('setEmailLink', emailLink) }) } ) }) -When('the user opens the password reset link in the browser', () => { - cy.task('getResetPasswordLink').then((passwordResetLink) => { - cy.visit(passwordResetLink) +When('the user opens the {string} link in the browser', (linkName: string) => { + cy.task('getEmailLink').then((emailLink) => { + cy.visit(emailLink) }) - cy.get(resetPasswordPage.newPasswordRepeatBlock).should('be.visible') + cy.get(resetPasswordPage.newPasswordInput).should('be.visible') }) diff --git a/e2e-tests/cypress/support/step_definitions/user_registration_steps.ts b/e2e-tests/cypress/support/step_definitions/user_registration_steps.ts index 8f12338b0..e90956b6e 100644 --- a/e2e-tests/cypress/support/step_definitions/user_registration_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/user_registration_steps.ts @@ -18,7 +18,7 @@ And('the user agrees to the privacy policy', () => { }) And('the user submits the registration form', () => { - registrationPage.submitRegistrationPage() + registrationPage.submitRegistrationForm() cy.get(registrationPage.RegistrationThanxHeadline).should('be.visible') cy.get(registrationPage.RegistrationThanxText).should('be.visible') }) diff --git a/e2e-tests/package.json b/e2e-tests/package.json index a6f817503..fc6403905 100644 --- a/e2e-tests/package.json +++ b/e2e-tests/package.json @@ -22,7 +22,7 @@ "@cypress/browserify-preprocessor": "^3.0.2", "@typescript-eslint/eslint-plugin": "^5.38.0", "@typescript-eslint/parser": "^5.38.0", - "cypress": "^10.4.0", + "cypress": "^12.7.0", "eslint": "^8.23.1", "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", diff --git a/frontend/src/components/ContributionMessages/ContributionMessagesListItem.vue b/frontend/src/components/ContributionMessages/ContributionMessagesListItem.vue index 6ae9d5933..01f835197 100644 --- a/frontend/src/components/ContributionMessages/ContributionMessagesListItem.vue +++ b/frontend/src/components/ContributionMessages/ContributionMessagesListItem.vue @@ -1,6 +1,23 @@