diff --git a/common/accountHeader/AccountHeaderOptions.ts b/common/account-header/account-header-options.ts similarity index 100% rename from common/accountHeader/AccountHeaderOptions.ts rename to common/account-header/account-header-options.ts diff --git a/common/componentEnums/SideBarShoppingItemListEnum.ts b/common/common-enums/side-bar-shopping-item-list.enum.ts similarity index 100% rename from common/componentEnums/SideBarShoppingItemListEnum.ts rename to common/common-enums/side-bar-shopping-item-list.enum.ts diff --git a/common/componentEnums/SideBarShoppingOptionsEnum.ts b/common/common-enums/side-bar-shopping-options-enum.ts similarity index 100% rename from common/componentEnums/SideBarShoppingOptionsEnum.ts rename to common/common-enums/side-bar-shopping-options-enum.ts diff --git a/common/index.ts b/common/index.ts index 5fa3a97..9e55bf4 100644 --- a/common/index.ts +++ b/common/index.ts @@ -2,9 +2,9 @@ * @file Automatically generated by barrelsby. */ -export * from "./accountHeader/AccountHeaderOptions"; -export * from "./componentEnums/SideBarShoppingItemListEnum"; -export * from "./componentEnums/SideBarShoppingOptionsEnum"; -export * from "./navigationEnums/menuBar/MenuBarEnum"; -export * from "./navigationEnums/menuBarCategories/MenuBarCategories"; -export * from "./navigationEnums/menuBarSubCategories/MenuBarSubCategories"; +export * from "./account-header/account-header-options"; +export * from "./common-enums/side-bar-shopping-item-list.enum"; +export * from "./common-enums/side-bar-shopping-options-enum"; +export * from "./navigation-enums/menu-bar/menu-bar.enum"; +export * from "./navigation-enums/menu-bar-categories/menu-bar-categories.enum"; +export * from "./navigation-enums/menuBarSubCategories/menu-bar-sub-categories.enum"; diff --git a/common/navigationEnums/menuBarCategories/MenuBarCategories.ts b/common/navigation-enums/menu-bar-categories/menu-bar-categories.enum.ts similarity index 100% rename from common/navigationEnums/menuBarCategories/MenuBarCategories.ts rename to common/navigation-enums/menu-bar-categories/menu-bar-categories.enum.ts diff --git a/common/navigationEnums/menuBar/MenuBarEnum.ts b/common/navigation-enums/menu-bar/menu-bar.enum.ts similarity index 100% rename from common/navigationEnums/menuBar/MenuBarEnum.ts rename to common/navigation-enums/menu-bar/menu-bar.enum.ts diff --git a/common/navigationEnums/menuBarSubCategories/MenuBarSubCategories.ts b/common/navigation-enums/menuBarSubCategories/menu-bar-sub-categories.enum.ts similarity index 100% rename from common/navigationEnums/menuBarSubCategories/MenuBarSubCategories.ts rename to common/navigation-enums/menuBarSubCategories/menu-bar-sub-categories.enum.ts diff --git a/helpers/fixtures/customFixtures/CustomFixtures.ts b/helpers/fixtures/customFixtures/custom.fixture.ts similarity index 74% rename from helpers/fixtures/customFixtures/CustomFixtures.ts rename to helpers/fixtures/customFixtures/custom.fixture.ts index c87baf9..908031a 100644 --- a/helpers/fixtures/customFixtures/CustomFixtures.ts +++ b/helpers/fixtures/customFixtures/custom.fixture.ts @@ -1,13 +1,13 @@ import { test as base } from '@playwright/test'; -import { LoginPage } from '../../../pages/loginPage/LoginPage'; -import { LumaMainPage } from '../../../pages/LumaMainPage'; -import { CreateAnAccountPage } from '../../../pages/createNewAccountPage/CreateAnAccountPage'; -import { MenCategoryPage } from '../../../pages/men/MenCategoryPage'; -import { CheckoutShippingPage } from '../../../pages/checkoutPage/CheckOutShippingPage'; -import { CheckoutReviewAndPaymentPage } from '../../../pages/checkoutPage/CheckoutReviewAndPaymentPage'; -import { ShoppingCartPage } from '../../../pages/cartPage/ShoppingCartPage'; -import { WomenCategoryPage } from '../../../pages/women/WomenCategoryPage'; -import { ProductPage } from '../../../pages/productPage/ProductPage'; +import { LoginPage } from '../../../pages/login-page/login.page'; +import { LumaMainPage } from '../../../pages/luma-main.page'; +import { CreateAnAccountPage } from '../../../pages/create-new-account-page/create-new-account.page'; +import { MenCategoryPage } from '../../../pages/men-category/men-category.page'; +import { CheckoutShippingPage } from '../../../pages/checkout-page/checkout-shipping.page'; +import { CheckoutReviewAndPaymentPage } from '../../../pages/checkout-page/checkout-review-and-payment.page'; +import { ShoppingCartPage } from '../../../pages/cart-page/shopping-cart.page'; +import { WomenCategoryPage } from '../../../pages/women-category/women-category.page'; +import { ProductPage } from '../../../pages/product-page/product.page'; type TestFixtures = { loginPage: LoginPage; diff --git a/helpers/index.ts b/helpers/index.ts index 4a911fc..a9340e9 100644 --- a/helpers/index.ts +++ b/helpers/index.ts @@ -2,7 +2,7 @@ * @file Automatically generated by barrelsby. */ -export * from "./faker/FakeDataRandomizer"; -export * from "./fixtures/customFixtures/CustomFixtures"; -export * from "./optionalParamsInterfaces/OptionalParams"; +export * from "./mocks/mock-generator"; +export * from "./fixtures/customFixtures/custom.fixture"; +export * from "./types/optional-params.types"; diff --git a/helpers/faker/FakeDataRandomizer.ts b/helpers/mocks/mock-generator.ts similarity index 97% rename from helpers/faker/FakeDataRandomizer.ts rename to helpers/mocks/mock-generator.ts index 25b3f5d..c2477d1 100644 --- a/helpers/faker/FakeDataRandomizer.ts +++ b/helpers/mocks/mock-generator.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -export class Randomizer { +export class MockGenerator { public static getRandomFirstName(): string { return faker.person.firstName(); diff --git a/helpers/optionalParamsInterfaces/OptionalParams.ts b/helpers/types/optional-params.types.ts similarity index 93% rename from helpers/optionalParamsInterfaces/OptionalParams.ts rename to helpers/types/optional-params.types.ts index fe6e1c1..f9f4562 100644 --- a/helpers/optionalParamsInterfaces/OptionalParams.ts +++ b/helpers/types/optional-params.types.ts @@ -26,7 +26,7 @@ export interface ProductItemOptionalParamsInterface { quantity?: string, } -export interface ClientSideValiationErrorOptionalParamsInterface { +export interface ClientSideValidationErrorOptionalParamsInterface { isEmptyFieldPresent?: boolean, allValidationErrorsText?: string, emptyFieldsIndexes?: number[], diff --git a/pages/BasePage.ts b/pages/base.page.ts similarity index 92% rename from pages/BasePage.ts rename to pages/base.page.ts index 79c72e3..7ffb8cd 100644 --- a/pages/BasePage.ts +++ b/pages/base.page.ts @@ -20,9 +20,9 @@ export class BasePage { } } - public async clickElement(locator: (string | Locator)) { + public async clickElement(locator: (string | Locator), force: boolean = true) { const locatorElement = await this.getTypeOfLocator(locator); - await locatorElement.click({ force: true }); + await locatorElement.click({ force }); } public async fillText(locator: (string | Locator), text: string) { @@ -142,4 +142,13 @@ export class BasePage { } throw new Error(`the item ${dropdownItemText} does not exist in dropdown!`); } + + public async getElementVisibility(locator: (string | Locator)) { + const locatorElement = await this.getTypeOfLocator(locator); + return locatorElement.isVisible(); + } + + public async waitForElementVisibility(locator: (string | Locator)) { + + } } \ No newline at end of file diff --git a/pages/cartPage/ShoppingCartPage.ts b/pages/cart-page/shopping-cart.page.ts similarity index 100% rename from pages/cartPage/ShoppingCartPage.ts rename to pages/cart-page/shopping-cart.page.ts diff --git a/pages/checkoutPage/CheckoutReviewAndPaymentPage.ts b/pages/checkout-page/checkout-review-and-payment.page.ts similarity index 100% rename from pages/checkoutPage/CheckoutReviewAndPaymentPage.ts rename to pages/checkout-page/checkout-review-and-payment.page.ts diff --git a/pages/checkoutPage/CheckOutShippingPage.ts b/pages/checkout-page/checkout-shipping.page.ts similarity index 100% rename from pages/checkoutPage/CheckOutShippingPage.ts rename to pages/checkout-page/checkout-shipping.page.ts diff --git a/pages/createNewAccountPage/CreateAnAccountPage.ts b/pages/create-new-account-page/create-new-account.page.ts similarity index 100% rename from pages/createNewAccountPage/CreateAnAccountPage.ts rename to pages/create-new-account-page/create-new-account.page.ts diff --git a/pages/index.ts b/pages/index.ts index 6ddc9bf..626d1df 100644 --- a/pages/index.ts +++ b/pages/index.ts @@ -2,15 +2,15 @@ * @file Automatically generated by barrelsby. */ -export * from "./BasePage"; -export * from "./LumaMainPage"; -export * from "./cartPage/ShoppingCartPage"; -export * from "./checkoutPage/CheckOutShippingPage"; -export * from "./checkoutPage/CheckoutReviewAndPaymentPage"; -export * from "./createNewAccountPage/CreateAnAccountPage"; -export * from "./loginPage/LoginPage"; -export * from "./men/MenCategoryPage"; -export * from "./pageComponents/productShoppingComponent/ItemShoppingPage"; -export * from "./pageComponents/sidebarShoppingComponent/SideBarShoppingComponentPage"; -export * from "./productPage/ProductPage"; -export * from "./women/WomenCategoryPage"; +export * from "./base.page"; +export * from "./luma-main.page"; +export * from "./cart-page/shopping-cart.page"; +export * from "./checkout-page/checkout-shipping.page"; +export * from "./checkout-page/checkout-review-and-payment.page"; +export * from "./create-new-account-page/create-new-account.page"; +export * from "./login-page/login.page"; +export * from "./men-category/men-category.page"; +export * from "./page-components/product-shopping-component/item-shopping.component"; +export * from "./page-components/sidebar-shopping-component/side-bar-shopping.component"; +export * from "./product-page/product.page"; +export * from "./women-category/women-category.page"; diff --git a/pages/loginPage/LoginPage.ts b/pages/login-page/login.page.ts similarity index 83% rename from pages/loginPage/LoginPage.ts rename to pages/login-page/login.page.ts index c74b6ad..befc303 100644 --- a/pages/loginPage/LoginPage.ts +++ b/pages/login-page/login.page.ts @@ -1,12 +1,12 @@ import { LumaMainPage } from "@pages"; -import { ClientSideValiationErrorOptionalParamsInterface } from "../../helpers/optionalParamsInterfaces/OptionalParams"; +import { ClientSideValidationErrorOptionalParamsInterface } from "../../helpers/types/optional-params.types"; export class LoginPage extends LumaMainPage { private emailFieldLocator = '[name="login[username]"]'; private passwordFieldLocator = '[name="login[password]"]'; public async login(email: string = process.env.EMAIL as string, password: string = process.env.PASSWORD as string, - options?: ClientSideValiationErrorOptionalParamsInterface & { negativeTest?: boolean, expectedErrorCount?: number }) { + options?: ClientSideValidationErrorOptionalParamsInterface & { negativeTest?: boolean, expectedErrorCount?: number }) { const emailField = this.page.locator(this.emailFieldLocator); const passwordField = this.page.locator(this.passwordFieldLocator); const loggedInState = await this.getLoggedInState(); diff --git a/pages/LumaMainPage.ts b/pages/luma-main.page.ts similarity index 94% rename from pages/LumaMainPage.ts rename to pages/luma-main.page.ts index d916700..248e0d0 100644 --- a/pages/LumaMainPage.ts +++ b/pages/luma-main.page.ts @@ -1,7 +1,7 @@ import { Locator, Page, expect } from "@playwright/test"; import { MenuBar } from "@common"; import { BasePage } from "@pages"; -import { CartActionsOptionalParamsInterface, ClientSideValiationErrorOptionalParamsInterface } from "@helpers"; +import { CartActionsOptionalParamsInterface, ClientSideValidationErrorOptionalParamsInterface } from "@helpers"; import { MenuBarCategories } from "@common"; import { MenuBarSubCategories } from "@common"; import { AccountHeaderOptions } from "@common"; @@ -48,7 +48,7 @@ export class LumaMainPage extends BasePage { } /** - * @description applies to men and women top and bottom categories becasue they are the only onces with subcategories at the moment + * @description applies to men and women top and bottom categories because they are the only onces with subcategories at the moment * @param subCategory */ @@ -108,7 +108,7 @@ export class LumaMainPage extends BasePage { await this.page.waitForTimeout(2500); } } catch (error) { - throw new Error(`pleasae refer to function "performActionsOnShoppingCart" - the condition may not be satisifed `) + throw new Error(`an error occurred while performing actions on the shopping cart: ${error}`); } } } @@ -203,11 +203,11 @@ export class LumaMainPage extends BasePage { /** * @description this function is meant for negative testing to validate that the client side validation errors are displayed * on the relevant corresponding fields. - * It handles situiations where fields are empty or when typing invalid data in the fields. - * The purpose of this funciton is to return the index of the fields in case they are empty with validation on empty fields - * as well as returning the client side validation error text and on what fields it occured. - * The function returns an array of the validation error innertext and the index of each error and makes an assertion validation - * on the number of errors that occured, on which field they occoured and their text. + * It handles situations where fields are empty or when typing invalid data in the fields. + * The purpose of this function is to return the index of the fields in case they are empty with validation on empty fields + * as well as returning the client side validation error text and on what fields it occurred. + * The function returns an array of the validation error innertText and the index of each error and makes an assertion validation + * on the number of errors that occurred, on which field they occurred and their text. * @param expectedCount * @param inputFieldsLocator * @param options @@ -215,10 +215,10 @@ export class LumaMainPage extends BasePage { public async handleClientSideValidationErrors( expectedCount: number, inputFieldsLocator: Locator[], - options?: ClientSideValiationErrorOptionalParamsInterface + options?: ClientSideValidationErrorOptionalParamsInterface ) { - const cliendSideValidationError = this.page.locator(this.clientSideValidationErrorLocator); - const validationErrorsCount = await this.countElements(cliendSideValidationError); + const clientSideValidationError = this.page.locator(this.clientSideValidationErrorLocator); + const validationErrorsCount = await this.countElements(clientSideValidationError); expect(validationErrorsCount).toBe(expectedCount); const inputFields = await this.getInputFieldsValues(inputFieldsLocator); const emptyFieldIndexes: number[] = []; @@ -234,11 +234,11 @@ export class LumaMainPage extends BasePage { const validationErrorTextList: string[] = [] const validationErrorIndexes = await this.page.locator(this.fieldWrapperControlLocator).all(); for (let i = 0; i < validationErrorIndexes.length; i++) { - const fieldWrapperInnexText = await this.getInnerText(validationErrorIndexes[i]); - const validationErrorFilter = validationErrorIndexes[i].filter({ has: cliendSideValidationError }) + const fieldWrapperInnerText = await this.getInnerText(validationErrorIndexes[i]); + const validationErrorFilter = validationErrorIndexes[i].filter({ has: clientSideValidationError }) if (await validationErrorFilter.isVisible()) { validationErrorNthIndex.push(i); - validationErrorTextList.push(fieldWrapperInnexText); + validationErrorTextList.push(fieldWrapperInnerText); } } expect(validationErrorNthIndex).toEqual(options?.validationErrorsIndexes); diff --git a/pages/men/MenCategoryPage.ts b/pages/men-category/men-category.page.ts similarity index 100% rename from pages/men/MenCategoryPage.ts rename to pages/men-category/men-category.page.ts diff --git a/pages/pageComponents/productShoppingComponent/ItemShoppingPage.ts b/pages/page-components/product-shopping-component/item-shopping.component.ts similarity index 100% rename from pages/pageComponents/productShoppingComponent/ItemShoppingPage.ts rename to pages/page-components/product-shopping-component/item-shopping.component.ts diff --git a/pages/pageComponents/sidebarShoppingComponent/SideBarShoppingComponentPage.ts b/pages/page-components/sidebar-shopping-component/side-bar-shopping.component.ts similarity index 100% rename from pages/pageComponents/sidebarShoppingComponent/SideBarShoppingComponentPage.ts rename to pages/page-components/sidebar-shopping-component/side-bar-shopping.component.ts diff --git a/pages/productPage/ProductPage.ts b/pages/product-page/product.page.ts similarity index 100% rename from pages/productPage/ProductPage.ts rename to pages/product-page/product.page.ts diff --git a/pages/women/WomenCategoryPage.ts b/pages/women-category/women-category.page.ts similarity index 100% rename from pages/women/WomenCategoryPage.ts rename to pages/women-category/women-category.page.ts diff --git a/tests/loginTests/LoginTests.spec.ts b/tests/login-tests/login-tests.spec.ts similarity index 100% rename from tests/loginTests/LoginTests.spec.ts rename to tests/login-tests/login-tests.spec.ts diff --git a/tests/loginTests/LogOutTest.spec.ts b/tests/login-tests/logout-tests.spec.ts similarity index 100% rename from tests/loginTests/LogOutTest.spec.ts rename to tests/login-tests/logout-tests.spec.ts diff --git a/tests/menCategoryShoppingTests/BuyFilteredProductFromMenCategory.spec.ts b/tests/men-category-tests/buy-filtered-men-category-product-test.spec.ts similarity index 85% rename from tests/menCategoryShoppingTests/BuyFilteredProductFromMenCategory.spec.ts rename to tests/men-category-tests/buy-filtered-men-category-product-test.spec.ts index 975edc1..6d31f4a 100644 --- a/tests/menCategoryShoppingTests/BuyFilteredProductFromMenCategory.spec.ts +++ b/tests/men-category-tests/buy-filtered-men-category-product-test.spec.ts @@ -3,7 +3,7 @@ import { SideBarShoppingOptionsEnum } from '@common' import { MenuBar } from '@common' import { MenuBarCategories } from '@common' import { MenuBarSubCategories } from '@common' -import { Randomizer } from '@helpers' +import { MockGenerator } from '@helpers' import { test } from '@helpers' test('purchase product from specific category', { tag: ['@MEN_CATEGORY_SHOPPING'] }, async ({ loadApplication, menCategoryPage, checkoutShippingPage, checkoutPaymentPage }) => { @@ -13,16 +13,16 @@ test('purchase product from specific category', { tag: ['@MEN_CATEGORY_SHOPPING' let jacketColor: string = 'Black'; let filters: string[] = ['Lightweight'] let cartQuantity: number = 1 - let email: string = Randomizer.getRandomEmail(); - let firstname: string = Randomizer.getRandomFirstName(); - let lastname: string = Randomizer.getRandomLastName() - let company: string = Randomizer.getRandomCompanyName(); - let streetAddress: string = Randomizer.getRandomStreetAddress(); - let city: string = Randomizer.getRandomCityName(); + let email: string = MockGenerator.getRandomEmail(); + let firstname: string = MockGenerator.getRandomFirstName(); + let lastname: string = MockGenerator.getRandomLastName() + let company: string = MockGenerator.getRandomCompanyName(); + let streetAddress: string = MockGenerator.getRandomStreetAddress(); + let city: string = MockGenerator.getRandomCityName(); let state: string = 'Florida' - let postalCode: string = Randomizer.getRandomPostalCode(); + let postalCode: string = MockGenerator.getRandomPostalCode(); let country: string = 'United States' - let phoneNumber: string = Randomizer.getRandomPhoneNumber(); + let phoneNumber: string = MockGenerator.getRandomPhoneNumber(); let shippingMethod: string = 'Best Way'; let purchaseConfirmation: string = 'Thank you for your purchase!'; let streetFieldIndex: number = 0; diff --git a/tests/productPurchaseTests/BuyProductEndToEndSanityTest.spec.ts b/tests/product-purchase-tests/buy-product-end-to-end-sanity-test.spec.ts similarity index 100% rename from tests/productPurchaseTests/BuyProductEndToEndSanityTest.spec.ts rename to tests/product-purchase-tests/buy-product-end-to-end-sanity-test.spec.ts diff --git a/tests/shoppingCartTests/ShoppingCartSanityTest.spec.ts b/tests/shopping-cart-tests/shopping-cart-sanity-test.spec.ts similarity index 100% rename from tests/shoppingCartTests/ShoppingCartSanityTest.spec.ts rename to tests/shopping-cart-tests/shopping-cart-sanity-test.spec.ts diff --git a/tests/signUpTests/CreateAnAccountTest.spec.ts b/tests/sign-up-tests/create-an-account-test.spec.ts similarity index 76% rename from tests/signUpTests/CreateAnAccountTest.spec.ts rename to tests/sign-up-tests/create-an-account-test.spec.ts index 9fb9502..c8a1f53 100644 --- a/tests/signUpTests/CreateAnAccountTest.spec.ts +++ b/tests/sign-up-tests/create-an-account-test.spec.ts @@ -1,11 +1,11 @@ import { test } from '@helpers'; -import { Randomizer } from '@helpers'; +import { MockGenerator } from '@helpers'; test('sign upand create new user account for luma shopping website', { tag: ['@SIGN_UP'] }, async ({ loadApplication, createAnAccountPage }) => { - let firstname = Randomizer.getRandomFirstName(); - let lastname = Randomizer.getRandomLastName(); - let email = Randomizer.getRandomEmail(); + let firstname = MockGenerator.getRandomFirstName(); + let lastname = MockGenerator.getRandomLastName(); + let email = MockGenerator.getRandomEmail(); let strongPasswordStrength = 'Password Strength: Strong'; let expectedConfirmationText = 'Thank you for registering with Main Website Store.'; await test.step('sign up to luma website with all mandatory credentials and validate password is strong and validate register was successful', async () => {