Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { faker } from '@faker-js/faker';

export class Randomizer {
export class MockGenerator {

public static getRandomFirstName(): string {
return faker.person.firstName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ProductItemOptionalParamsInterface {
quantity?: string,
}

export interface ClientSideValiationErrorOptionalParamsInterface {
export interface ClientSideValidationErrorOptionalParamsInterface {
isEmptyFieldPresent?: boolean,
allValidationErrorsText?: string,
emptyFieldsIndexes?: number[],
Expand Down
13 changes: 11 additions & 2 deletions pages/BasePage.ts → pages/base.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {

}
}
24 changes: 12 additions & 12 deletions pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
28 changes: 14 additions & 14 deletions pages/LumaMainPage.ts → pages/luma-main.page.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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
*/

Expand Down Expand Up @@ -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}`);
}
}
}
Expand Down Expand Up @@ -203,22 +203,22 @@ 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
*/
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[] = [];
Expand All @@ -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);
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
Loading