gradido/e2e-tests/cypress/support/step_definitions/user_authentication_steps.ts
MateuszMichalowski 45f4207537
build(frontend): merged code from master (#3367)
* fix

* fix test

* update docker compose call

* update e2e test

* change docker-compose to docker compose in all workflows

* use mariadb container with enabled external_network

* add sleep to test_database

* add maybe new parameter --service-ports needed for docker compose run else there weren't any open ports

* try another approach

* save change (._.);

* fix(frontend): fix e2e setup & add additional check in validation rules.

* fix(frontend): fix e2e setup

---------

Co-authored-by: einhornimmond <info@einhornimmond.de>
Co-authored-by: einhornimmond <dario.rekowski@gmx.de>
2024-09-12 21:00:08 +02:00

66 lines
2.0 KiB
TypeScript

import { When } from '@badeball/cypress-cucumber-preprocessor'
import { ForgotPasswordPage } from '../../e2e/models/ForgotPasswordPage'
import { LoginPage } from '../../e2e/models/LoginPage'
import { ResetPasswordPage } from '../../e2e/models/ResetPasswordPage'
const loginPage = new LoginPage()
const forgotPasswordPage = new ForgotPasswordPage()
const resetPasswordPage = new ResetPasswordPage()
// login related
When('the user submits no credentials', () => {
loginPage.submitLogin()
})
When('the user submits the credentials {string} {string}', (email: string, password: string) => {
cy.intercept('POST', '/graphql', (req) => {
// eslint-disable-next-line no-prototype-builtins
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)
})
})
// password reset related
When('the user navigates to the forgot password page', () => {
loginPage.openForgotPasswordPage()
cy.url().should('include', '/forgot-password')
})
When('the user enters the e-mail address {string}', (email: string) => {
forgotPasswordPage.enterEmail(email)
})
When('the user submits the e-mail form', () => {
forgotPasswordPage.submitEmail()
cy.get(forgotPasswordPage.successComponent).debug()
cy.get(forgotPasswordPage.successComponent).should('be.visible')
})
When('the user enters the password {string}', (password: string) => {
resetPasswordPage.enterNewPassword(password)
})
When('the user repeats the password {string}', (password: string) => {
resetPasswordPage.repeatNewPassword(password)
})
When('the user submits the new password', () => {
resetPasswordPage.submitNewPassword()
cy.get(resetPasswordPage.resetPasswordMessageBlock).should('be.visible')
})
When('the user clicks the sign in button', () => {
resetPasswordPage.openSigninPage()
cy.url().should('contain', '/login')
})