diff --git a/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_fills_the_password_form_with.ts b/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_fills_the_password_form_with.ts deleted file mode 100644 index 21fda4b19..000000000 --- a/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_fills_the_password_form_with.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { When } from "@badeball/cypress-cucumber-preprocessor"; -import { ProfilePage } from "../models/ProfilePage"; - -When("the user fills the password form with:", (table) => { - table = table.rowsHash(); - const profilePage = new ProfilePage(); - profilePage.enterOldPassword(table["Old password"]); - profilePage.enterNewPassword(table["New password"]); - profilePage.enterRepeatPassword(table["Repeat new password"]); - cy.get(profilePage.submitNewPasswordBtn).should("be.enabled"); -}); diff --git a/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_is_presented_a_{string}_message.ts b/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_is_presented_a_{string}_message.ts deleted file mode 100644 index 9fa90bd02..000000000 --- a/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_is_presented_a_{string}_message.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { When } from "@badeball/cypress-cucumber-preprocessor"; -import { Toasts } from "../models/Toasts"; - -When("the user is presented a {string} message", (type: string) => { - const toast = new Toasts(); - cy.get(toast.toastTitle).should("contain.text", "Success"); - cy.get(toast.toastMessage).should( - "contain.text", - "Your password has been changed." - ); -}); diff --git a/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_opens_the_change_password_menu.ts b/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_opens_the_change_password_menu.ts deleted file mode 100644 index dcfed3c71..000000000 --- a/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_opens_the_change_password_menu.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { And } from "@badeball/cypress-cucumber-preprocessor"; -import { ProfilePage } from "../models/ProfilePage"; - -And("the user opens the change password menu", () => { - const profilePage = new ProfilePage(); - cy.get(profilePage.openChangePassword).click(); - cy.get(profilePage.newPasswordRepeatInput).should("be.visible"); - cy.get(profilePage.submitNewPasswordBtn).should("be.disabled"); -}); diff --git a/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_submits_the_password_form.ts b/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_submits_the_password_form.ts deleted file mode 100644 index 5752c94fa..000000000 --- a/e2e-tests/cypress/tests/cypress/e2e/UserProfile.ChangePassword/the_user_submits_the_password_form.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { And } from "@badeball/cypress-cucumber-preprocessor"; -import { ProfilePage } from "../models/ProfilePage"; - -And("the user submits the password form", () => { - const profilePage = new ProfilePage(); - profilePage.submitPasswordForm(); -}); 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 new file mode 100644 index 000000000..439974cda --- /dev/null +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/common_steps.ts @@ -0,0 +1,52 @@ +import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; +import { LoginPage } from "../../e2e/models/LoginPage"; +import { OverviewPage } from "../../e2e/models/OverviewPage"; +import { SideNavMenu } from "../../e2e/models/SideNavMenu"; +import { Toasts } from "../../e2e/models/Toasts"; + +Given("the browser navigates to page {string}", (page: string) => { + cy.visit(page); +}); + +// login-related + +Given( + "the user is logged in as {string} {string}", + (email: string, password: string) => { + 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 cannot login", () => { + const toast = new Toasts(); + cy.get(toast.toastTitle).should("contain.text", "Error!"); + cy.get(toast.toastMessage).should( + "contain.text", + "No user with this credentials." + ); +}); + +// + +When( + "the user submits the credentials {string} {string}", + (email: string, password: string) => { + const loginPage = new LoginPage(); + loginPage.enterEmail(email); + loginPage.enterPassword(password); + loginPage.submitLogin(); + } +); + +// logout + +Then("the user logs out", () => { + const sideNavMenu = new SideNavMenu(); + sideNavMenu.logout(); +}); diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_browser_navigates_to_page_{string}.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_browser_navigates_to_page_{string}.ts deleted file mode 100644 index cd397080d..000000000 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_browser_navigates_to_page_{string}.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Given } from "@badeball/cypress-cucumber-preprocessor"; - -Given("the browser navigates to page {string}", (page: string) => { - cy.visit(page); -}); diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_cannot_login.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_cannot_login.ts deleted file mode 100644 index 1f38747fe..000000000 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_cannot_login.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Then } from "@badeball/cypress-cucumber-preprocessor"; -import { Toasts } from "../../e2e/models/Toasts"; - -Then("the user cannot login", () => { - const toast = new Toasts(); - cy.get(toast.toastTitle).should("contain.text", "Error!"); - cy.get(toast.toastMessage).should( - "contain.text", - "No user with this credentials." - ); -}); diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_as_{string}_{string}.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_as_{string}_{string}.ts deleted file mode 100644 index 145ece1b1..000000000 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_as_{string}_{string}.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Given } from "@badeball/cypress-cucumber-preprocessor"; - -Given( - "the user is logged in as {string} {string}", - (email: string, password: string) => { - cy.login(email, password); - } -); diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_with_username_{string}.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_with_username_{string}.ts deleted file mode 100644 index 64741d122..000000000 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_with_username_{string}.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Then } from "@badeball/cypress-cucumber-preprocessor"; -import { OverviewPage } from "../../e2e/models/OverviewPage"; - -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); -}); diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_logs_out.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_logs_out.ts deleted file mode 100644 index 62766f7bd..000000000 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_logs_out.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Then } from "@badeball/cypress-cucumber-preprocessor"; -import { SideNavMenu } from "../../e2e/models/SideNavMenu"; - -Then("the user logs out", () => { - const sideNavMenu = new SideNavMenu(); - sideNavMenu.logout(); -}); diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_submits_the_credentials_{string}_{string}.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_submits_the_credentials_{string}_{string}.ts deleted file mode 100644 index 6aef84797..000000000 --- a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_submits_the_credentials_{string}_{string}.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { When } from "@badeball/cypress-cucumber-preprocessor"; -import { LoginPage } from "../../e2e/models/LoginPage"; - -When( - "the user submits the credentials {string} {string}", - (email: string, password: string) => { - const loginPage = new LoginPage(); - loginPage.enterEmail(email); - loginPage.enterPassword(password); - loginPage.submitLogin(); - } -); 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 new file mode 100644 index 000000000..1e5cfe88c --- /dev/null +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_authentication_steps.ts @@ -0,0 +1,7 @@ +import { When } from "@badeball/cypress-cucumber-preprocessor"; +import { LoginPage } from "../../e2e/models/LoginPage"; + +When("the user submits no credentials", () => { + const loginPage = new LoginPage(); + loginPage.submitLogin(); +}); 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 new file mode 100644 index 000000000..cbe851f02 --- /dev/null +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_profile_change_password_steps.ts @@ -0,0 +1,32 @@ +import { And, When } from "@badeball/cypress-cucumber-preprocessor"; +import { ProfilePage } from "../../e2e/models/ProfilePage"; +import { Toasts } from "../../e2e/models/Toasts"; + +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"); +}); + +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"); +}); + +And("the user submits the password form", () => { + profilePage.submitPasswordForm(); +}); + +When("the user is presented a {string} message", (type: string) => { + const toast = new Toasts(); + cy.get(toast.toastTitle).should("contain.text", "Success"); + cy.get(toast.toastMessage).should( + "contain.text", + "Your password has been changed." + ); +}); 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 new file mode 100644 index 000000000..49e121fc2 --- /dev/null +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/user_registration_steps.ts @@ -0,0 +1,24 @@ +import { And, When } from "@badeball/cypress-cucumber-preprocessor"; +import { RegistrationPage } from "../../e2e/models/RegistrationPage"; + +const registrationPage = new RegistrationPage(); + +When( + "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); + } +); + +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"); +});