Skip to content

Commit

Permalink
ps_cashondelivery : Adapt some pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Sep 27, 2024
1 parent 5a26ed8 commit 9d6ae24
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 19 deletions.
12 changes: 8 additions & 4 deletions src/pages/FO/classic/home/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ const psVersion = testContext.getPSVersion();

/* eslint-disable global-require, @typescript-eslint/no-var-requires */
function requirePage(): FoHomePageInterface {
// >= 9.0
if (semver.gte(psVersion, '9.0.0')) {
return require('@versions/develop/pages/FO/classic/home').homePage;
// > 1.7.7.0
if (semver.lt(psVersion, '7.7.0')) {
return require('@versions/1.7.6/pages/FO/classic/home');
}
return require('@versions/8.1/pages/FO/classic/home');
// > 9.0.0
if (semver.lt(psVersion, '9.0.0')) {
return require('@versions/8.1/pages/FO/classic/home').foHomePage;
}
return require('@versions/develop/pages/FO/classic/home').foHomePage;
}
/* eslint-enable global-require, @typescript-eslint/no-var-requires */

Expand Down
22 changes: 22 additions & 0 deletions src/versions/1.7.6/pages/FO/classic/home/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Import pages
import type {FoHomePageInterface} from '@interfaces/FO/home';
import {FoHomePage} from '@versions/8.1/pages/FO/classic/home/index';

/**
* Home page, contains functions that can be used on the page
* @class
*/
class FoHomePageVersion extends FoHomePage implements FoHomePageInterface {
/**
* @constructs
* Setting up texts and selectors to use on order confirmation page
*/
constructor(theme: string = 'classic') {
super(theme);

this.productArticle = (number: number) => `${this.productsBlockNth(2)} .products `
+ `article.product-miniature:nth-child(${number}) div`;
}
}

module.exports = new FoHomePageVersion();
9 changes: 5 additions & 4 deletions src/versions/8.1/pages/FO/classic/home/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
// Import pages
import type {FoHomePageInterface} from '@interfaces/FO/home';
import {HomePage} from '@versions/develop/pages/FO/classic/home/index';
import {FoHomePage} from '@versions/develop/pages/FO/classic/home/index';

/**
* Order confirmation page, contains functions that can be used on the page
* @class
* @extends OrderConfirmationPage
*/
class HomePageVersion extends HomePage implements FoHomePageInterface {
class FoHomePageVersion extends FoHomePage implements FoHomePageInterface {
/**
* @constructs
* Setting up texts and selectors to use on order confirmation page
*/
constructor(theme: string = 'classic') {
super(theme);

this.productArticle = (number: number) => `${this.productsBlockNth(2)} .products article:nth-child(${number}) div`;
this.productArticle = (number: number) => `${this.productsBlockNth(2)} .products div.product:nth-child(${number}) div`;
}
}

module.exports = new HomePageVersion();
const foHomePage = new FoHomePageVersion();
export {foHomePage, FoHomePageVersion as FoHomePage};
16 changes: 8 additions & 8 deletions src/versions/develop/pages/FO/classic/home/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {quickViewModal as foClassicModalQuickViewPage} from '@versions/develop/p
* @class
* @extends FOBasePage
*/
class HomePage extends FOBasePage implements FoHomePageInterface {
class FoHomePage extends FOBasePage implements FoHomePageInterface {
public readonly pageTitle: string;

public readonly successAddToCartMessage: string;
Expand Down Expand Up @@ -354,11 +354,11 @@ class HomePage extends FOBasePage implements FoHomePageInterface {
/**
* Quick view product
* @param page {Page} Browser tab
* @param row {number} Row of product to quick view
* @param id {number} Row of product to quick view
* @return {Promise<void>}
*/
async quickViewProduct(page: Page, row: number): Promise<void> {
await page.locator(this.productImg(row)).hover();
async quickViewProduct(page: Page, id: number): Promise<void> {
await page.locator(this.productImg(id)).hover();
let displayed: boolean = false;

/* eslint-disable no-await-in-loop */
Expand All @@ -375,14 +375,14 @@ class HomePage extends FOBasePage implements FoHomePageInterface {
}
return window.getComputedStyle(element, ':after').getPropertyValue('display') === 'block';
},
this.productDescriptionDiv(row),
this.productDescriptionDiv(id),
);
await page.waitForTimeout(100);
}
/* eslint-enable no-await-in-loop */
await Promise.all([
this.waitForVisibleSelector(page, foClassicModalQuickViewPage.quickViewModalDiv),
page.locator(this.productQuickViewLink(row)).evaluate((el: HTMLElement) => el.click()),
page.locator(this.productQuickViewLink(id)).evaluate((el: HTMLElement) => el.click()),
]);
}

Expand Down Expand Up @@ -467,5 +467,5 @@ class HomePage extends FOBasePage implements FoHomePageInterface {
}
}

const homePage = new HomePage();
export {homePage, HomePage};
const foHomePage = new FoHomePage();
export {foHomePage, FoHomePage};
6 changes: 3 additions & 3 deletions src/versions/develop/pages/FO/hummingbird/home/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {FoHomeHummingbirdPageInterface} from '@interfaces/FO/home';
import {type Page} from '@playwright/test';
import {HomePage as HomePageVersion} from '@versions/develop/pages/FO/classic/home';
import {FoHomePage as FoHomePageVersion} from '@versions/develop/pages/FO/classic/home';

/**
* Home page, contains functions that can be used on the page
* @class
* @extends HomePage
*/
class HomePage extends HomePageVersion implements FoHomeHummingbirdPageInterface {
class FoHomePage extends FoHomePageVersion implements FoHomeHummingbirdPageInterface {
private readonly addToCartIcon: (number: number) => string;

private readonly productColor: (number: number, color: string) => string;
Expand Down Expand Up @@ -100,4 +100,4 @@ class HomePage extends HomePageVersion implements FoHomeHummingbirdPageInterface
}
}

module.exports = new HomePage();
module.exports = new FoHomePage();

0 comments on commit 9d6ae24

Please sign in to comment.