From 140b53faf3701cb3646f557534f29b9a11b6c2b6 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 10:12:44 +0100 Subject: [PATCH] Change " to ', remove ; at end of statements, try to correct IDE recognition of modul imports. --- e2e-tests/cypress/tests/.eslintrc.js | 25 ++--- e2e-tests/cypress/tests/.prettierrc.js | 9 ++ e2e-tests/cypress/tests/cypress.config.ts | 78 +++++++-------- .../cypress/e2e/models/ForgotPasswordPage.ts | 16 ++-- .../tests/cypress/e2e/models/LoginPage.ts | 32 +++---- .../tests/cypress/e2e/models/OverviewPage.ts | 8 +- .../tests/cypress/e2e/models/ProfilePage.ts | 32 +++---- .../cypress/e2e/models/RegistrationPage.ts | 38 ++++---- .../cypress/e2e/models/ResetPasswordPage.ts | 30 +++--- .../tests/cypress/e2e/models/SideNavMenu.ts | 14 +-- .../tests/cypress/e2e/models/Toasts.ts | 12 +-- .../tests/cypress/e2e/models/UserEMailSite.ts | 18 ++-- .../cypress/tests/cypress/support/e2e.ts | 30 +++--- .../cypress/tests/cypress/support/index.ts | 6 +- .../support/step_definitions/common_steps.ts | 52 +++++----- .../support/step_definitions/email_steps.ts | 56 +++++------ .../user_authentication_steps.ts | 96 +++++++++---------- .../user_profile_change_password_steps.ts | 52 +++++----- .../user_registration_steps.ts | 34 +++---- e2e-tests/cypress/tests/tsconfig.json | 2 +- 20 files changed, 325 insertions(+), 315 deletions(-) create mode 100644 e2e-tests/cypress/tests/.prettierrc.js diff --git a/e2e-tests/cypress/tests/.eslintrc.js b/e2e-tests/cypress/tests/.eslintrc.js index 157454287..9bdd630c7 100644 --- a/e2e-tests/cypress/tests/.eslintrc.js +++ b/e2e-tests/cypress/tests/.eslintrc.js @@ -3,22 +3,23 @@ module.exports = { env: { node: true, }, - parser: "@typescript-eslint/parser", - plugins: ["cypress", "prettier", "@typescript-eslint"], + parser: '@typescript-eslint/parser', + plugins: ['cypress', 'prettier', '@typescript-eslint' /*, 'jest' */], extends: [ - "standard", - "eslint:recommended", - "plugin:prettier/recommended", - "plugin:@typescript-eslint/recommended", + 'standard', + 'eslint:recommended', + 'plugin:prettier/recommended', + 'plugin:@typescript-eslint/recommended', ], + // add your custom rules here rules: { - "no-console": ["error"], - "no-debugger": "error", - "prettier/prettier": [ - "error", + 'no-console': ['error'], + 'no-debugger': 'error', + 'prettier/prettier': [ + 'error', { - htmlWhitespaceSensitivity: "ignore", + htmlWhitespaceSensitivity: 'ignore', }, ], }, -}; +} diff --git a/e2e-tests/cypress/tests/.prettierrc.js b/e2e-tests/cypress/tests/.prettierrc.js new file mode 100644 index 000000000..bc1d767d7 --- /dev/null +++ b/e2e-tests/cypress/tests/.prettierrc.js @@ -0,0 +1,9 @@ +module.exports = { + semi: false, + printWidth: 100, + singleQuote: true, + trailingComma: "all", + tabWidth: 2, + bracketSpacing: true, + endOfLine: "auto", +}; diff --git a/e2e-tests/cypress/tests/cypress.config.ts b/e2e-tests/cypress/tests/cypress.config.ts index a9627c5ae..16ebb0e97 100644 --- a/e2e-tests/cypress/tests/cypress.config.ts +++ b/e2e-tests/cypress/tests/cypress.config.ts @@ -1,51 +1,51 @@ -import { defineConfig } from "cypress"; -import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor"; -import browserify from "@badeball/cypress-cucumber-preprocessor/browserify"; +import { defineConfig } from 'cypress' +import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor' +import browserify from '@badeball/cypress-cucumber-preprocessor/browserify' -let resetPasswordLink: string; +let resetPasswordLink: string async function setupNodeEvents( on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions ): Promise { - await addCucumberPreprocessorPlugin(on, config); + await addCucumberPreprocessorPlugin(on, config) on( - "file:preprocessor", + 'file:preprocessor', browserify(config, { - typescript: require.resolve("typescript"), + typescript: require.resolve('typescript'), }) - ); + ) - on("task", { + on('task', { setResetPasswordLink: (val) => { - return (resetPasswordLink = val); + return (resetPasswordLink = val) }, getResetPasswordLink: () => { - return resetPasswordLink; + return resetPasswordLink }, - }); + }) - on("after:run", (results) => { + on('after:run', (results) => { if (results) { // results will be undefined in interactive mode // eslint-disable-next-line no-console - console.log(results.status); + console.log(results.status) } - }); + }) - return config; + return config } export default defineConfig({ e2e: { - specPattern: "**/*.feature", - excludeSpecPattern: "*.js", + specPattern: '**/*.feature', + excludeSpecPattern: '*.js', experimentalSessionAndOrigin: true, - baseUrl: "http://localhost:3000", + baseUrl: 'http://localhost:3000', chromeWebSecurity: false, defaultCommandTimeout: 10000, - supportFile: "cypress/support/index.ts", + supportFile: 'cypress/support/index.ts', viewportHeight: 720, viewportWidth: 1280, video: false, @@ -54,26 +54,26 @@ export default defineConfig({ openMode: 0, }, env: { - backendURL: "http://localhost:4000", - mailserverURL: "http://localhost:1080", + backendURL: 'http://localhost:4000', + mailserverURL: 'http://localhost:1080', loginQuery: `query ($email: String!, $password: String!, $publisherId: Int) { - login(email: $email, password: $password, publisherId: $publisherId) { - email - firstName - lastName - language - klickTipp { - newsletterState - __typename - } - hasElopage - publisherId - isAdmin - creation - __typename - } -}`, + login(email: $email, password: $password, publisherId: $publisherId) { + email + firstName + lastName + language + klickTipp { + newsletterState + __typename + } + hasElopage + publisherId + isAdmin + creation + __typename + } + }`, }, setupNodeEvents, }, -}); +}) diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/ForgotPasswordPage.ts b/e2e-tests/cypress/tests/cypress/e2e/models/ForgotPasswordPage.ts index 295bb1fda..b97bc8ee7 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/ForgotPasswordPage.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/ForgotPasswordPage.ts @@ -1,18 +1,18 @@ -/// +/// export class ForgotPasswordPage { // selectors - emailInput = "input[type=email]"; - submitBtn = "button[type=submit]"; - successComponent = "[data-test='forgot-password-success']"; + emailInput = 'input[type=email]' + submitBtn = 'button[type=submit]' + successComponent = '[data-test="forgot-password-success"]' enterEmail(email: string) { - cy.get(this.emailInput).clear().type(email); - return this; + cy.get(this.emailInput).clear().type(email) + return this } submitEmail() { - cy.get(this.submitBtn).click(); - return this; + cy.get(this.submitBtn).click() + return this } } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/LoginPage.ts b/e2e-tests/cypress/tests/cypress/e2e/models/LoginPage.ts index df91e8e14..52aa5d19b 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/LoginPage.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/LoginPage.ts @@ -1,35 +1,35 @@ -/// +/// export class LoginPage { // selectors - emailInput = "input[type=email]"; - passwordInput = "input[type=password]"; - forgotPasswordLink = '[data-test="forgot-password-link"]'; - submitBtn = "[type=submit]"; - emailHint = "#vee_Email"; - passwordHint = "#vee_Password"; + emailInput = 'input[type=email]' + passwordInput = 'input[type=password]' + forgotPasswordLink = '[data-test="forgot-password-link"]' + submitBtn = '[type=submit]' + emailHint = '#vee_Email' + passwordHint = '#vee_Password' goto() { - cy.visit("/"); - return this; + cy.visit('/') + return this } enterEmail(email: string) { - cy.get(this.emailInput).clear().type(email); - return this; + cy.get(this.emailInput).clear().type(email) + return this } enterPassword(password: string) { - cy.get(this.passwordInput).clear().type(password); - return this; + cy.get(this.passwordInput).clear().type(password) + return this } submitLogin() { - cy.get(this.submitBtn).click(); - return this; + cy.get(this.submitBtn).click() + return this } openForgotPasswordPage() { - cy.get(this.forgotPasswordLink).click(); + cy.get(this.forgotPasswordLink).click() } } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/OverviewPage.ts b/e2e-tests/cypress/tests/cypress/e2e/models/OverviewPage.ts index 426c2b8b3..345124c66 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/OverviewPage.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/OverviewPage.ts @@ -1,10 +1,10 @@ -/// +/// export class OverviewPage { - navbarName = '[data-test="navbar-item-username"]'; + navbarName = '[data-test="navbar-item-username"]' goto() { - cy.visit("/overview"); - return this; + cy.visit('/overview') + return this } } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/ProfilePage.ts b/e2e-tests/cypress/tests/cypress/e2e/models/ProfilePage.ts index 0532a7ff8..4d5b98a53 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/ProfilePage.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/ProfilePage.ts @@ -1,35 +1,35 @@ -/// +/// export class ProfilePage { // selectors - openChangePassword = "[data-test=open-password-change-form]"; - oldPasswordInput = "#password-input-field"; - newPasswordInput = "#new-password-input-field"; - newPasswordRepeatInput = "#repeat-new-password-input-field"; - submitNewPasswordBtn = "[data-test=submit-new-password-btn]"; + openChangePassword = '[data-test=open-password-change-form]' + oldPasswordInput = '#password-input-field' + newPasswordInput = '#new-password-input-field' + newPasswordRepeatInput = '#repeat-new-password-input-field' + submitNewPasswordBtn = '[data-test=submit-new-password-btn]' goto() { - cy.visit("/profile"); - return this; + cy.visit('/profile') + return this } enterOldPassword(password: string) { - cy.get(this.oldPasswordInput).clear().type(password); - return this; + cy.get(this.oldPasswordInput).clear().type(password) + return this } enterNewPassword(password: string) { - cy.get(this.newPasswordInput).find("input").clear().type(password); - return this; + cy.get(this.newPasswordInput).find('input').clear().type(password) + return this } enterRepeatPassword(password: string) { - cy.get(this.newPasswordRepeatInput).find("input").clear().type(password); - return this; + cy.get(this.newPasswordRepeatInput).find('input').clear().type(password) + return this } submitPasswordForm() { - cy.get(this.submitNewPasswordBtn).click(); - return this; + cy.get(this.submitNewPasswordBtn).click() + return this } } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/RegistrationPage.ts b/e2e-tests/cypress/tests/cypress/e2e/models/RegistrationPage.ts index 27a9cb8cc..8cae26a26 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/RegistrationPage.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/RegistrationPage.ts @@ -1,42 +1,42 @@ -/// +/// export class RegistrationPage { // selectors - firstnameInput = "#registerFirstname"; - lastnameInput = "#registerLastname"; - emailInput = "#Email-input-field"; - checkbox = "#registerCheckbox"; - submitBtn = "[type=submit]"; + firstnameInput = '#registerFirstname' + lastnameInput = '#registerLastname' + emailInput = '#Email-input-field' + checkbox = '#registerCheckbox' + submitBtn = '[type=submit]' - RegistrationThanxHeadline = ".test-message-headline"; - RegistrationThanxText = ".test-message-subtitle"; + RegistrationThanxHeadline = '.test-message-headline' + RegistrationThanxText = '.test-message-subtitle' goto() { - cy.visit("/register"); - return this; + cy.visit('/register') + return this } enterFirstname(firstname: string) { - cy.get(this.firstnameInput).clear().type(firstname); - return this; + cy.get(this.firstnameInput).clear().type(firstname) + return this } enterLastname(lastname: string) { - cy.get(this.lastnameInput).clear().type(lastname); - return this; + cy.get(this.lastnameInput).clear().type(lastname) + return this } enterEmail(email: string) { - cy.get(this.emailInput).clear().type(email); - return this; + cy.get(this.emailInput).clear().type(email) + return this } checkPrivacyCheckbox() { - cy.get(this.checkbox).click({ force: true }); + cy.get(this.checkbox).click({ force: true }) } submitRegistrationPage() { - cy.get(this.submitBtn).should("be.enabled"); - cy.get(this.submitBtn).click(); + cy.get(this.submitBtn).should('be.enabled') + cy.get(this.submitBtn).click() } } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/ResetPasswordPage.ts b/e2e-tests/cypress/tests/cypress/e2e/models/ResetPasswordPage.ts index 4f01d73b0..20134de6d 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/ResetPasswordPage.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/ResetPasswordPage.ts @@ -1,32 +1,32 @@ -/// +/// export class ResetPasswordPage { // selectors - newPasswordBlock = "#new-password-input-field"; - newPasswordRepeatBlock = "#repeat-new-password-input-field"; - resetPasswordBtn = "button[type=submit]"; - resetPasswordMessageBlock = '[data-test="reset-password-message"]'; - signinBtn = ".btn.test-message-button"; + newPasswordBlock = '#new-password-input-field' + newPasswordRepeatBlock = '#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); - return this; + cy.get(this.newPasswordBlock).find('input[type=password]').type(password) + return this } repeatNewPassword(password: string) { cy.get(this.newPasswordRepeatBlock) - .find("input[type=password]") - .type(password); - return this; + .find('input[type=password]') + .type(password) + return this } submitNewPassword() { - cy.get(this.resetPasswordBtn).click(); - return this; + cy.get(this.resetPasswordBtn).click() + return this } openSigninPage() { - cy.get(this.signinBtn).click(); - return this; + cy.get(this.signinBtn).click() + return this } } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/SideNavMenu.ts b/e2e-tests/cypress/tests/cypress/e2e/models/SideNavMenu.ts index 3dd9d6914..ccd177b66 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/SideNavMenu.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/SideNavMenu.ts @@ -1,17 +1,17 @@ -/// +/// export class SideNavMenu { // selectors - profileMenu = "[data-test=profile-menu]"; - logoutMenu = "[data-test=logout-menu]"; + profileMenu = '[data-test=profile-menu]' + logoutMenu = '[data-test=logout-menu]' openUserProfile() { - cy.get(this.profileMenu).click(); - return this; + cy.get(this.profileMenu).click() + return this } logout() { - cy.get(this.logoutMenu).click(); - return this; + cy.get(this.logoutMenu).click() + return this } } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/Toasts.ts b/e2e-tests/cypress/tests/cypress/e2e/models/Toasts.ts index aabd0a45e..efd5052fb 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/Toasts.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/Toasts.ts @@ -1,10 +1,10 @@ -/// +/// export class Toasts { // selectors - toastSlot = ".b-toaster-slot"; - toastTypeSuccess = ".b-toast-success"; - toastTypeError = ".b-toast-danger"; - toastTitle = ".gdd-toaster-title"; - toastMessage = ".gdd-toaster-body"; + toastSlot = '.b-toaster-slot' + toastTypeSuccess = '.b-toast-success' + toastTypeError = '.b-toast-danger' + toastTitle = '.gdd-toaster-title' + toastMessage = '.gdd-toaster-body' } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/UserEMailSite.ts b/e2e-tests/cypress/tests/cypress/e2e/models/UserEMailSite.ts index 02207827d..f46f5677b 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/UserEMailSite.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/UserEMailSite.ts @@ -1,17 +1,17 @@ -/// +/// export class UserEMailSite { // selectors - emailInbox = ".sidebar-emails-container"; - emailList = ".email-list"; - emailMeta = ".email-meta"; - emailSubject = ".subject"; + emailInbox = '.sidebar-emails-container' + emailList = '.email-list' + emailMeta = '.email-meta' + emailSubject = '.subject' openRecentPasswordResetEMail() { cy.get(this.emailList) - .find("email-item") - .filter(":contains(asswor)") - .click(); - expect(cy.get(this.emailSubject)).to("contain", "asswor"); + .find('email-item') + .filter(':contains(asswor)') + .click() + expect(cy.get(this.emailSubject)).to('contain', 'asswor') } } diff --git a/e2e-tests/cypress/tests/cypress/support/e2e.ts b/e2e-tests/cypress/tests/cypress/support/e2e.ts index 16cc474bf..801165a48 100644 --- a/e2e-tests/cypress/tests/cypress/support/e2e.ts +++ b/e2e-tests/cypress/tests/cypress/support/e2e.ts @@ -1,38 +1,38 @@ -import jwtDecode from "jwt-decode"; +import jwtDecode from 'jwt-decode' -Cypress.Commands.add("login", (email, password) => { - cy.clearLocalStorage("vuex"); +Cypress.Commands.add('login', (email, password) => { + cy.clearLocalStorage('vuex') cy.request({ - method: "POST", - url: Cypress.env("backendURL"), + method: 'POST', + url: Cypress.env('backendURL'), body: { operationName: null, variables: { email: email, password: password, }, - query: Cypress.env("loginQuery"), + query: Cypress.env('loginQuery'), }, }).then(async (response) => { - const token = response.headers.token; - let tokenTime; + const token = response.headers.token + let tokenTime // to avoid JWT InvalidTokenError, the decoding of the token is wrapped // in a try-catch block (see // https://github.com/auth0/jwt-decode/issues/65#issuecomment-395493807) try { - tokenTime = jwtDecode(token).exp; + tokenTime = jwtDecode(token).exp } catch (tokenDecodingError) { - cy.log("JWT decoding error: ", tokenDecodingError); + cy.log('JWT decoding error: ', tokenDecodingError) } const vuexToken = { token: token, tokenTime: tokenTime, - }; + } - cy.visit("/"); - window.localStorage.setItem("vuex", JSON.stringify(vuexToken)); - }); -}); + cy.visit('/') + window.localStorage.setItem('vuex', JSON.stringify(vuexToken)) + }) +}) diff --git a/e2e-tests/cypress/tests/cypress/support/index.ts b/e2e-tests/cypress/tests/cypress/support/index.ts index 99ab0efc2..f8d1abacf 100644 --- a/e2e-tests/cypress/tests/cypress/support/index.ts +++ b/e2e-tests/cypress/tests/cypress/support/index.ts @@ -1,14 +1,14 @@ /* eslint-disable @typescript-eslint/no-namespace */ /* eslint-disable @typescript-eslint/no-explicit-any */ -/// +/// -import "./e2e"; +import './e2e' declare global { namespace Cypress { interface Chainable { - login(email: string, password: string): Chainable; + login(email: string, password: string): Chainable } } } diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/common_steps.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/common_steps.ts index e2d66f76a..c5d3004ac 100644 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/common_steps.ts +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/common_steps.ts @@ -1,39 +1,39 @@ -import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; -import { OverviewPage } from "../../e2e/models/OverviewPage"; -import { SideNavMenu } from "../../e2e/models/SideNavMenu"; -import { Toasts } from "../../e2e/models/Toasts"; +import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor' +import { OverviewPage } from '../../e2e/models/OverviewPage' +import { SideNavMenu } from '../../e2e/models/SideNavMenu' +import { Toasts } from '../../e2e/models/Toasts' -Given("the user navigates to page {string}", (page: string) => { - cy.visit(page); -}); +Given('the user navigates to page {string}', (page: string) => { + cy.visit(page) +}) // login related Given( - "the user is logged in as {string} {string}", + 'the user is logged in as {string} {string}', (email: string, password: string) => { - cy.login(email, password); + cy.login(email, password) } -); +) -Then("the user is logged in with username {string}", (username: string) => { - const overviewPage = new OverviewPage(); - cy.url().should("include", "/overview"); - cy.get(overviewPage.navbarName).should("contain", username); -}); +Then('the user is logged in with username {string}', (username: string) => { + const overviewPage = new OverviewPage() + cy.url().should('include', '/overview') + cy.get(overviewPage.navbarName).should('contain', username) +}) -Then("the user cannot login", () => { - const toast = new Toasts(); +Then('the user cannot login', () => { + const toast = new Toasts() cy.get(toast.toastSlot).within(() => { - cy.get(toast.toastTypeError); - cy.get(toast.toastTitle).should("be.visible"); - cy.get(toast.toastMessage).should("be.visible"); - }); -}); + cy.get(toast.toastTypeError) + cy.get(toast.toastTitle).should('be.visible') + cy.get(toast.toastMessage).should('be.visible') + }) +}) // logout -Then("the user logs out", () => { - const sideNavMenu = new SideNavMenu(); - sideNavMenu.logout(); -}); +Then('the user logs out', () => { + const sideNavMenu = new SideNavMenu() + sideNavMenu.logout() +}) diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/email_steps.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/email_steps.ts index 4044c3717..b313442f2 100644 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/email_steps.ts +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/email_steps.ts @@ -1,45 +1,45 @@ -import { Then, When } from "@badeball/cypress-cucumber-preprocessor"; -import { ResetPasswordPage } from "../../e2e/models/ResetPasswordPage"; -import { UserEMailSite } from "../../e2e/models/UserEMailSite"; +import { Then, When } from '@badeball/cypress-cucumber-preprocessor' +import { ResetPasswordPage } from '../../e2e/models/ResetPasswordPage' +import { UserEMailSite } from '../../e2e/models/UserEMailSite' -const userEMailSite = new UserEMailSite(); -const resetPasswordPage = new ResetPasswordPage(); +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 password reset link', () => { cy.origin( - Cypress.env("mailserverURL"), + Cypress.env('mailserverURL'), { args: userEMailSite }, (userEMailSite) => { - const linkPattern = /\/reset-password\/[0-9]+\d/; + const linkPattern = /\/reset-password\/[0-9]+\d/ - cy.visit("/"); // navigate to user's e-maile site (on fake mail server) - cy.get(userEMailSite.emailInbox).should("be.visible"); + cy.visit('/') // navigate to user's e-maile site (on fake mail server) + cy.get(userEMailSite.emailInbox).should('be.visible') cy.get(userEMailSite.emailList) - .find(".email-item") - .filter(":contains(asswor)") + .find('.email-item') + .filter(':contains(asswor)') .first() - .click(); + .click() cy.get(userEMailSite.emailMeta) .find(userEMailSite.emailSubject) - .contains("asswor"); + .contains('asswor') - cy.get(".email-content") - .find(".plain-text") + cy.get('.email-content') + .find('.plain-text') .contains(linkPattern) - .invoke("text") + .invoke('text') .then((text) => { - const resetPasswordLink = text.match(linkPattern)[0]; - cy.task("setResetPasswordLink", resetPasswordLink); - }); + const resetPasswordLink = text.match(linkPattern)[0] + cy.task('setResetPasswordLink', resetPasswordLink) + }) } - ); -}); + ) +}) -When("the user opens the password reset link in the browser", () => { - cy.task("getResetPasswordLink").then((passwordResetLink) => { - cy.visit(passwordResetLink); - }); - cy.get(resetPasswordPage.newPasswordRepeatBlock).should("be.visible"); -}); +When('the user opens the password reset link in the browser', () => { + cy.task('getResetPasswordLink').then((passwordResetLink) => { + cy.visit(passwordResetLink) + }) + cy.get(resetPasswordPage.newPasswordRepeatBlock).should('be.visible') +}) 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 17743ebe5..5b25f5391 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 @@ -1,69 +1,69 @@ -import { When, And } from "@badeball/cypress-cucumber-preprocessor"; -import { ForgotPasswordPage } from "../../e2e/models/ForgotPasswordPage"; -import { LoginPage } from "../../e2e/models/LoginPage"; -import { ResetPasswordPage } from "../../e2e/models/ResetPasswordPage"; +import { When, And } 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(); +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 no credentials', () => { + loginPage.submitLogin() +}) When( - "the user submits the credentials {string} {string}", + 'the user submits the credentials {string} {string}', (email: string, password: string) => { - cy.intercept("POST", "/graphql", (req) => { + cy.intercept('POST', '/graphql', (req) => { if ( - req.body.hasOwnProperty("query") && - req.body.query.includes("mutation") + req.body.hasOwnProperty('query') && + req.body.query.includes('mutation') ) { - req.alias = "login"; + req.alias = 'login' } - }); + }) - loginPage.enterEmail(email); - loginPage.enterPassword(password); - loginPage.submitLogin(); - cy.wait("@login").then((interception) => { - expect(interception.response.statusCode).equals(200); - }); + loginPage.enterEmail(email) + loginPage.enterPassword(password) + loginPage.submitLogin() + cy.wait('@login').then((interception) => { + expect(interception.response.statusCode).equals(200) + }) } -); +) // password reset related -And("the user navigates to the forgot password page", () => { - loginPage.openForgotPasswordPage(); - cy.url().should("include", "/forgot-password"); -}); +And('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 enters the e-mail address {string}', (email: string) => { + forgotPasswordPage.enterEmail(email) +}) -And("the user submits the e-mail form", () => { - forgotPasswordPage.submitEmail(); - cy.get(forgotPasswordPage.successComponent).should("be.visible"); -}); +And('the user submits the e-mail form', () => { + forgotPasswordPage.submitEmail() + cy.get(forgotPasswordPage.successComponent).should('be.visible') +}) -And("the user enters the password {string}", (password: string) => { - resetPasswordPage.enterNewPassword(password); -}); +And('the user enters the password {string}', (password: string) => { + resetPasswordPage.enterNewPassword(password) +}) -And("the user repeats the password {string}", (password: string) => { - resetPasswordPage.repeatNewPassword(password); -}); +And('the user repeats the password {string}', (password: string) => { + resetPasswordPage.repeatNewPassword(password) +}) -And("the user submits the new password", () => { - resetPasswordPage.submitNewPassword(); - cy.get(resetPasswordPage.resetPasswordMessageBlock).should("be.visible"); -}); +And('the user submits the new password', () => { + resetPasswordPage.submitNewPassword() + cy.get(resetPasswordPage.resetPasswordMessageBlock).should('be.visible') +}) -And("the user clicks the sign in button", () => { - resetPasswordPage.openSigninPage(); - cy.url().should("contain", "/login"); -}); +And('the user clicks the sign in button', () => { + resetPasswordPage.openSigninPage() + cy.url().should('contain', '/login') +}) diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/user_profile_change_password_steps.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_profile_change_password_steps.ts index 5396b66bb..1dcbe69ef 100644 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/user_profile_change_password_steps.ts +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_profile_change_password_steps.ts @@ -1,32 +1,32 @@ -import { And, When } from "@badeball/cypress-cucumber-preprocessor"; -import { ProfilePage } from "../../e2e/models/ProfilePage"; -import { Toasts } from "../../e2e/models/Toasts"; +import { And, When } from '@badeball/cypress-cucumber-preprocessor' +import { ProfilePage } from '../../e2e/models/ProfilePage' +import { Toasts } from '../../e2e/models/Toasts' -const profilePage = new ProfilePage(); +const profilePage = new ProfilePage() -And("the user opens the change password menu", () => { - cy.get(profilePage.openChangePassword).click(); - cy.get(profilePage.newPasswordRepeatInput).should("be.visible"); - cy.get(profilePage.submitNewPasswordBtn).should("be.disabled"); -}); +And('the user opens the change password menu', () => { + cy.get(profilePage.openChangePassword).click() + cy.get(profilePage.newPasswordRepeatInput).should('be.visible') + cy.get(profilePage.submitNewPasswordBtn).should('be.disabled') +}) -When("the user fills the password form with:", (table) => { - table = table.rowsHash(); - profilePage.enterOldPassword(table["Old password"]); - profilePage.enterNewPassword(table["New password"]); - profilePage.enterRepeatPassword(table["Repeat new password"]); - cy.get(profilePage.submitNewPasswordBtn).should("be.enabled"); -}); +When('the user fills the password form with:', (table) => { + let hashedTableRows = table.rowsHash() + profilePage.enterOldPassword(hashedTableRows['Old password']) + profilePage.enterNewPassword(hashedTableRows['New password']) + profilePage.enterRepeatPassword(hashedTableRows['Repeat new password']) + cy.get(profilePage.submitNewPasswordBtn).should('be.enabled') +}) -And("the user submits the password form", () => { - profilePage.submitPasswordForm(); -}); +And('the user submits the password form', () => { + profilePage.submitPasswordForm() +}) -When("the user is presented a {string} message", (type: string) => { - const toast = new Toasts(); +When('the user is presented a {string} message', (type: string) => { + const toast = new Toasts() cy.get(toast.toastSlot).within(() => { - cy.get(toast.toastTypeSuccess); - cy.get(toast.toastTitle).should("be.visible"); - cy.get(toast.toastMessage).should("be.visible"); - }); -}); + cy.get(toast.toastTypeSuccess) + cy.get(toast.toastTitle).should('be.visible') + cy.get(toast.toastMessage).should('be.visible') + }) +}) diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/user_registration_steps.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_registration_steps.ts index 49e121fc2..8f12338b0 100644 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/user_registration_steps.ts +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_registration_steps.ts @@ -1,24 +1,24 @@ -import { And, When } from "@badeball/cypress-cucumber-preprocessor"; -import { RegistrationPage } from "../../e2e/models/RegistrationPage"; +import { And, When } from '@badeball/cypress-cucumber-preprocessor' +import { RegistrationPage } from '../../e2e/models/RegistrationPage' -const registrationPage = new RegistrationPage(); +const registrationPage = new RegistrationPage() When( - "the user fills name and email {string} {string} {string}", + 'the user fills name and email {string} {string} {string}', (firstname: string, lastname: string, email: string) => { - const registrationPage = new RegistrationPage(); - registrationPage.enterFirstname(firstname); - registrationPage.enterLastname(lastname); - registrationPage.enterEmail(email); + const registrationPage = new RegistrationPage() + registrationPage.enterFirstname(firstname) + registrationPage.enterLastname(lastname) + registrationPage.enterEmail(email) } -); +) -And("the user agrees to the privacy policy", () => { - registrationPage.checkPrivacyCheckbox(); -}); +And('the user agrees to the privacy policy', () => { + registrationPage.checkPrivacyCheckbox() +}) -And("the user submits the registration form", () => { - registrationPage.submitRegistrationPage(); - cy.get(registrationPage.RegistrationThanxHeadline).should("be.visible"); - cy.get(registrationPage.RegistrationThanxText).should("be.visible"); -}); +And('the user submits the registration form', () => { + registrationPage.submitRegistrationPage() + cy.get(registrationPage.RegistrationThanxHeadline).should('be.visible') + cy.get(registrationPage.RegistrationThanxText).should('be.visible') +}) diff --git a/e2e-tests/cypress/tests/tsconfig.json b/e2e-tests/cypress/tests/tsconfig.json index c031a126e..287443d46 100644 --- a/e2e-tests/cypress/tests/tsconfig.json +++ b/e2e-tests/cypress/tests/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es2016", "lib": ["es6", "dom"], - "baseUrl": "../node_modules", + "baseUrl": ".", "types": ["cypress", "node"], "strict": true },