Skip to content

Commit

Permalink
Migrate @pages/FO/{classic|hummingbird}/modal/blockCart from Core
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Feb 18, 2025
1 parent f1eb29e commit 9e67ae6
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 45 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export {default as foHummingbirdCheckoutOrderConfirmationPage} from '@pages/FO/h
export {default as foHummingbirdContactUsPage} from '@pages/FO/hummingbird/contactUs';
export {default as foHummingbirdHomePage} from '@pages/FO/hummingbird/home';
export {default as foHummingbirdLoginPage} from '@pages/FO/hummingbird/login';
export {default as foHummingbirdModalBlockCartPage} from '@pages/FO/hummingbird/modal/blockCart';
export {default as foHummingbirdModalQuickViewPage} from '@pages/FO/hummingbird/modal/quickView';
export {default as foHummingbirdMyAccountPage} from '@pages/FO/hummingbird/myAccount';
export {default as foHummingbirdMyMerchandiseReturnsPage} from '@pages/FO/hummingbird/myAccount/merchandiseReturns';
Expand Down
5 changes: 1 addition & 4 deletions src/interfaces/FO/modal/blockCart.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {FOBasePagePageInterface} from '@interfaces/FO';

// Import data
import type {ProductAttribute} from '@data/types/product';
import type {CartProductDetails} from '@data/types/cart';

import {FOBasePagePageInterface} from '@interfaces/FO';
import type {Page} from '@playwright/test';

export interface FoModalBlockCartPageInterface extends FOBasePagePageInterface {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/FO/classic/modal/blockCart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const psVersion = testContext.getPSVersion();
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): FoModalBlockCartPageInterface {
if (semver.lt(psVersion, '7.1.0')) {
return require('@versions/1.7.0/pages/FO/classic/modal/blockCart').blockCartModal;
return require('@versions/1.7.0/pages/FO/classic/modal/blockCart').foModalBlockCartPage;
}
return require('@versions/develop/pages/FO/classic/modal/blockCart').blockCartModal;
return require('@versions/develop/pages/FO/classic/modal/blockCart').foModalBlockCartPage;
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

Expand Down
9 changes: 9 additions & 0 deletions src/pages/FO/hummingbird/modal/blockCart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type {FoModalBlockCartPageInterface} from '@interfaces/FO/modal/blockCart';

/* eslint-disable global-require, @typescript-eslint/no-require-imports */
function requirePage(): FoModalBlockCartPageInterface {
return require('@versions/develop/pages/FO/hummingbird/modal/blockCart');
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports */

export default requirePage();
8 changes: 4 additions & 4 deletions src/versions/1.7.0/pages/FO/classic/modal/blockCart.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Import pages
import type {FoModalBlockCartPageInterface} from '@interfaces/FO/modal/blockCart';
import {BlockCartModal} from '@versions/develop/pages/FO/classic/modal/blockCart';
import {FoModalBlockCartPage as FoModalBlockCartPageVersion} from '@versions/develop/pages/FO/classic/modal/blockCart';

/**
* FO block cart modal, contains functions that can be used on the page
* @class
* @extends foProductPage
*/
class FoBlockCartModalVersion extends BlockCartModal implements FoModalBlockCartPageInterface {
class FoModalBlockCartPage extends FoModalBlockCartPageVersion implements FoModalBlockCartPageInterface {
/**
* @constructs
* Setting up texts and selectors to use on block cart modal
Expand All @@ -19,5 +19,5 @@ class FoBlockCartModalVersion extends BlockCartModal implements FoModalBlockCart
}
}

const blockCartModal = new FoBlockCartModalVersion();
export {blockCartModal, FoBlockCartModalVersion as BlockCartModal};
const foModalBlockCartPage = new FoModalBlockCartPage();
export {foModalBlockCartPage, FoModalBlockCartPage};
70 changes: 35 additions & 35 deletions src/versions/develop/pages/FO/classic/modal/blockCart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {Page} from 'playwright';
* @class
* @extends FOBasePage
*/
class BlockCartModal extends FOBasePage implements FoModalBlockCartPageInterface {
class FoModalBlockCartPage extends FOBasePage implements FoModalBlockCartPageInterface {
private readonly blockCartLabel: string;

protected readonly blockCartModalDiv: string;
Expand Down Expand Up @@ -45,9 +45,9 @@ class BlockCartModal extends FOBasePage implements FoModalBlockCartPageInterface
protected continueShoppingButton: string;

/**
* @constructs
* Setting up texts and selectors to use on home page
*/
* @constructs
* Setting up texts and selectors to use on home page
*/
constructor(theme: string = 'classic') {
super(theme);

Expand All @@ -69,28 +69,28 @@ class BlockCartModal extends FOBasePage implements FoModalBlockCartPageInterface
}

/**
* Get block cart modal title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
* Get block cart modal title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getBlockCartModalTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.blockCartLabel);
}

/**
* Is block cart modal visible
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
* Is block cart modal visible
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async isBlockCartModalVisible(page: Page): Promise<boolean> {
return this.elementVisible(page, this.blockCartModalDiv, 2000);
}

/**
* Get product details from blockCart modal
* @param page {Page} Browser tab
* @returns {Promise<CartProductDetails>}
*/
* Get product details from blockCart modal
* @param page {Page} Browser tab
* @returns {Promise<CartProductDetails>}
*/
async getProductDetailsFromBlockCartModal(page: Page): Promise<CartProductDetails> {
return {
name: await this.getTextContent(page, this.cartModalProductNameBlock),
Expand All @@ -104,10 +104,10 @@ class BlockCartModal extends FOBasePage implements FoModalBlockCartPageInterface
}

/**
* Get product attributes from block cart modal
* @param page {Page} Browser tab
* @returns {Promise<ProductAttribute[]>}
*/
* Get product attributes from block cart modal
* @param page {Page} Browser tab
* @returns {Promise<ProductAttribute[]>}
*/
async getProductAttributesFromBlockCartModal(page: Page): Promise<ProductAttribute[]> {
return [
{
Expand All @@ -122,32 +122,32 @@ class BlockCartModal extends FOBasePage implements FoModalBlockCartPageInterface
}

/**
* Click on proceed to checkout after adding product to cart (in modal homePage)
* @param page {Page} Browser tab
* @return {Promise<void>}
*/
* Click on proceed to checkout after adding product to cart (in modal homePage)
* @param page {Page} Browser tab
* @return {Promise<void>}
*/
async proceedToCheckout(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.cartModalCheckoutLink);
await page.waitForLoadState('domcontentloaded');
}

/**
* Click on continue shopping
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
* Click on continue shopping
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async continueShopping(page: Page): Promise<boolean> {
await this.waitForSelectorAndClick(page, this.continueShoppingButton);

return this.elementNotVisible(page, this.blockCartModalDiv, 2000);
}

/**
* Close block cart modal
* @param page {Page} Browser tab
* @param clickOutside {boolean} True if we need to click outside to close the modal
* @returns {Promise<boolean>}
*/
* Close block cart modal
* @param page {Page} Browser tab
* @param clickOutside {boolean} True if we need to click outside to close the modal
* @returns {Promise<boolean>}
*/
async closeBlockCartModal(page: Page, clickOutside: boolean = false): Promise<boolean> {
if (clickOutside) {
await page.waitForTimeout(1000);
Expand All @@ -159,5 +159,5 @@ class BlockCartModal extends FOBasePage implements FoModalBlockCartPageInterface
}
}

const blockCartModal = new BlockCartModal();
export {blockCartModal, BlockCartModal};
const foModalBlockCartPage = new FoModalBlockCartPage();
export {foModalBlockCartPage, FoModalBlockCartPage};
31 changes: 31 additions & 0 deletions src/versions/develop/pages/FO/hummingbird/modal/blockCart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {type FoModalBlockCartPageInterface} from '@interfaces/FO/modal/blockCart';
import {FoModalBlockCartPage as FoModalBlockCartPageClassic} from '@versions/develop/pages/FO/classic/modal/blockCart';

/**
* Block cart modal, contains functions that can be used on the modal
* @class
* @extends BlockCartModal
*/
class FoModalBlockCartPage extends FoModalBlockCartPageClassic implements FoModalBlockCartPageInterface {
private readonly blockCartModalSummary: string;

/**
* @constructs
* Setting up texts and selectors to use on home page
*/
constructor() {
super('hummingbird');

// Block Cart Modal
this.cartModalCheckoutLink = `${this.blockCartModalDiv} div.cart-footer-actions a`;
this.continueShoppingButton = `${this.blockCartModalDiv} div.cart-footer-actions button`;
this.blockCartModalCloseButton = `${this.blockCartModalDiv} button.btn-close`;
this.blockCartModalSummary = '.blockcart-modal__summery';
this.cartModalProductsCountBlock = `${this.blockCartModalSummary} p`;
this.cartModalSubtotalBlock = `${this.blockCartModalSummary} .product-subtotal .subtotals.value`;
this.cartModalShippingBlock = `${this.blockCartModalSummary} .product-shipping .shipping.value`;
this.cartModalProductTaxInclBlock = `${this.blockCartModalSummary} .product-total .value`;
}
}

module.exports = new FoModalBlockCartPage();

0 comments on commit 9e67ae6

Please sign in to comment.