mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-12 23:35:50 +00:00
refactor email step definitions
This commit is contained in:
parent
86286023fa
commit
d66356c040
@ -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
|
||||
|
||||
@ -7,8 +7,8 @@ Feature: User registration
|
||||
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 receives an e-mail containing the activation link
|
||||
When the user opens the activation link in the browser
|
||||
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
|
||||
|
||||
@ -5,57 +5,39 @@ 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/
|
||||
|
||||
{ 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')
|
||||
|
||||
cy.get('.email-content')
|
||||
.find('.plain-text', { timeout: 2000 })
|
||||
.contains(linkPattern)
|
||||
.invoke('text')
|
||||
.then((text) => {
|
||||
const resetPasswordLink = text.match(linkPattern)[0]
|
||||
cy.task('setResetPasswordLink', resetPasswordLink)
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
Then('the user receives an e-mail containing the activation link', () => {
|
||||
cy.origin(
|
||||
Cypress.env('mailserverURL'),
|
||||
{ args: userEMailSite },
|
||||
(userEMailSite) => {
|
||||
const linkPattern = /\/checkEmail\/[0-9]+\d/
|
||||
|
||||
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(E-Mail Überprüfung)')
|
||||
.first()
|
||||
.click()
|
||||
|
||||
cy.get(userEMailSite.emailMeta)
|
||||
.find(userEMailSite.emailSubject)
|
||||
.contains('E-Mail Überprüfung')
|
||||
.contains(emailSubject)
|
||||
|
||||
cy.get('.email-content')
|
||||
.wait(2000)
|
||||
@ -63,23 +45,16 @@ Then('the user receives an e-mail containing the activation link', () => {
|
||||
.contains(linkPattern)
|
||||
.invoke('text')
|
||||
.then((text) => {
|
||||
const activationLink = text.match(linkPattern)[0]
|
||||
cy.task('setActivationLink', activationLink)
|
||||
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)
|
||||
})
|
||||
cy.get(resetPasswordPage.newPasswordInput).should('be.visible')
|
||||
})
|
||||
|
||||
When('the user opens the activation link in the browser', () => {
|
||||
cy.task('getActivationLink').then((activationLink) => {
|
||||
cy.visit(activationLink)
|
||||
When('the user opens the {string} link in the browser', (linkName: string) => {
|
||||
cy.task('getEmailLink').then((emailLink) => {
|
||||
cy.visit(emailLink)
|
||||
})
|
||||
cy.get(resetPasswordPage.newPasswordInput).should('be.visible')
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user