bundle cypress step definitions

- bundle step definitions in feature-related multiple-step files
- avoid the long ugly file names
This commit is contained in:
mahula 2022-09-23 12:15:31 +02:00
parent 9f23ac9734
commit a12bb9e09b
14 changed files with 115 additions and 89 deletions

View File

@ -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");
});

View File

@ -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."
);
});

View File

@ -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");
});

View File

@ -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();
});

View File

@ -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();
});

View File

@ -1,5 +0,0 @@
import { Given } from "@badeball/cypress-cucumber-preprocessor";
Given("the browser navigates to page {string}", (page: string) => {
cy.visit(page);
});

View File

@ -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."
);
});

View File

@ -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);
}
);

View File

@ -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);
});

View File

@ -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();
});

View File

@ -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();
}
);

View File

@ -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();
});

View File

@ -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."
);
});

View File

@ -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");
});