Skip to content

Commit be9615e

Browse files
authored
Merge pull request #236 from nesrineabdmouleh/adapt173
Migrate 173 selectors to run sanity tests
2 parents 73019b7 + 27b54bb commit be9615e

File tree

7 files changed

+111
-32
lines changed

7 files changed

+111
-32
lines changed

src/pages/BO/BOBasePage.ts

+34-31
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ export default class BOBasePage extends CommonPage implements BOBasePagePageInte
617617

618618
// Symfony Toolbar
619619
this.sfToolbarMainContentDiv = "div[id*='sfToolbarMainContent']";
620-
this.sfCloseToolbarLink = "[id*='sfToolbarHideButton']";
620+
this.sfCloseToolbarLink = "[id*='sfToolbarHideButton'], a.hide-button";
621621

622622
// Sidebar
623623
this.rightSidebar = '#right-sidebar';
@@ -638,7 +638,7 @@ export default class BOBasePage extends CommonPage implements BOBasePagePageInte
638638
* @param page {Page} Browser tab
639639
* @returns {Promise<string>}
640640
*/
641-
async getShopVersion(page:Page):Promise<string> {
641+
async getShopVersion(page: Page): Promise<string> {
642642
return this.getTextContent(page, this.shopVersion);
643643
}
644644

@@ -737,22 +737,27 @@ export default class BOBasePage extends CommonPage implements BOBasePagePageInte
737737
* @returns {Promise<void>}
738738
*/
739739
async goToSubMenu(page: Page, parentSelector: string, linkSelector: string): Promise<void> {
740-
await this.clickSubMenu(page, parentSelector);
741-
await this.scrollTo(page, linkSelector);
742-
await this.clickAndWaitForURL(page, linkSelector);
743-
744740
const shopVersion = testContext.getPSVersion();
745-
let linkActiveClass: string = '-active';
746-
747-
// >= 1.7.8.0
748-
if (semver.gte(shopVersion, '7.8.0')) {
749-
linkActiveClass = 'link-active';
750-
}
751741

752-
if (await this.isSidebarCollapsed(page)) {
753-
await this.waitForHiddenSelector(page, `${linkSelector}.${linkActiveClass}`);
742+
if (semver.lt(shopVersion, '7.4.0')) {
743+
await page.hover(parentSelector);
744+
await this.clickAndWaitForURL(page, linkSelector);
754745
} else {
755-
await this.waitForVisibleSelector(page, `${linkSelector}.${linkActiveClass}`);
746+
await this.clickSubMenu(page, parentSelector);
747+
await this.scrollTo(page, linkSelector);
748+
await this.clickAndWaitForURL(page, linkSelector);
749+
let linkActiveClass: string = '-active';
750+
751+
// >= 1.7.8.0
752+
if (semver.gte(shopVersion, '7.8.0')) {
753+
linkActiveClass = 'link-active';
754+
}
755+
756+
if (await this.isSidebarCollapsed(page)) {
757+
await this.waitForHiddenSelector(page, `${linkSelector}.${linkActiveClass}`);
758+
} else {
759+
await this.waitForVisibleSelector(page, `${linkSelector}.${linkActiveClass}`);
760+
}
756761
}
757762
}
758763

@@ -998,14 +1003,13 @@ export default class BOBasePage extends CommonPage implements BOBasePagePageInte
9981003
const args = {selector: iFrameSelector, vl: value, hasP: hasParagraph};
9991004
// eslint-disable-next-line no-eval
10001005
const fn: { fnSetValueOnTinymceInput: PageFunction<{ selector: string, vl: string, hasP: boolean }, void> } = eval(`({
1001-
async fnSetValueOnTinymceInput(args) {
1002-
/* eslint-env browser */
1003-
const iFrameElement = await document.querySelector(args.selector);
1004-
const iFrameHtml = iFrameElement.contentDocument.documentElement;
1005-
const textElement = await iFrameHtml.querySelector(args.hasP ? 'body p' : 'body');
1006-
textElement.textContent = args.vl;
1007-
}
1008-
})`);
1006+
async fnSetValueOnTinymceInput(args) {
1007+
/* eslint-env browser */
1008+
const iFrameElement = await document.querySelector(args.selector);
1009+
const iFrameHtml = iFrameElement.contentDocument.documentElement;
1010+
const textElement = await iFrameHtml.querySelector(args.hasP ? 'body p' : 'body');
1011+
textElement.textContent = args.vl;
1012+
}})`);
10091013
await page.evaluate(fn.fnSetValueOnTinymceInput, args);
10101014
}
10111015

@@ -1031,15 +1035,14 @@ export default class BOBasePage extends CommonPage implements BOBasePagePageInte
10311035
const args = {selector, value, onChange};
10321036
// eslint-disable-next-line no-eval
10331037
const fn: { fnSetValueOnDTPickerInput: PageFunction<{ selector: string, value: string, onChange: boolean }, void> } = eval(`({
1034-
async fnSetValueOnDTPickerInput(args) {
1035-
/* eslint-env browser */
1036-
const textElement = await document.querySelector(args.selector);
1037-
textElement.value = args.value;
1038-
if (args.onChange) {
1039-
textElement.dispatchEvent(new Event('change'));
1040-
}
1038+
async fnSetValueOnDTPickerInput(args) {
1039+
/* eslint-env browser */
1040+
const textElement = await document.querySelector(args.selector);
1041+
textElement.value = args.value;
1042+
if (args.onChange) {
1043+
textElement.dispatchEvent(new Event('change'));
10411044
}
1042-
})`);
1045+
}})`);
10431046
await page.evaluate(fn.fnSetValueOnDTPickerInput, args);
10441047
}
10451048

src/pages/BO/catalog/products/create/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const psVersion = testContext.getPSVersion();
66

77
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
88
function requirePage(): BOProductsCreatePageInterface {
9+
if (semver.lt(psVersion, '7.4.0')) {
10+
return require('@versions/1.7.3/pages/BO/catalog/products/create').createProduct;
11+
}
912
if (semver.lt(psVersion, '7.6.0')) {
1013
return require('@versions/1.7.5/pages/BO/catalog/products/create').createProduct;
1114
}

src/pages/BO/catalog/products/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const psVersion = testContext.getPSVersion();
66

77
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
88
function requirePage(): BOProductsPageInterface {
9+
if (semver.lt(psVersion, '7.4.0')) {
10+
return require('@versions/1.7.3/pages/BO/catalog/products').productsPage;
11+
}
912
if (semver.lt(psVersion, '7.6.0')) {
1013
return require('@versions/1.7.5/pages/BO/catalog/products').productsPage;
1114
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Import pages
2+
import type {BOProductsCreatePageInterface} from '@interfaces/BO/catalog/products/create';
3+
import {CreateProduct} from '@versions/1.7.5/pages/BO/catalog/products/create';
4+
import {type Page} from '@playwright/test';
5+
6+
/**
7+
* Bo create product page, contains functions that can be used on the page
8+
* @class
9+
* @extends CreateProduct
10+
*/
11+
class BOCreateProductVersion extends CreateProduct implements BOProductsCreatePageInterface {
12+
/**
13+
* @constructs
14+
* Setting up texts and selectors to use on create products page
15+
*/
16+
constructor() {
17+
super();
18+
19+
this.deleteProductButton = '#product_form_delete_btn';
20+
}
21+
22+
/**
23+
* Delete product
24+
* @param page {Page} Browser tab
25+
* @returns {Promise<string>}
26+
*/
27+
async deleteProduct(page: Page): Promise<string> {
28+
await this.clickAndWaitForURL(page, this.deleteProductButton);
29+
30+
return this.getAlertSuccessBlockParagraphContent(page);
31+
}
32+
}
33+
34+
const createProduct = new BOCreateProductVersion();
35+
export {createProduct, BOCreateProductVersion as CreateProduct};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Import pages
2+
import type {BOProductsPageInterface} from '@interfaces/BO/catalog/products';
3+
import {ProductsPage} from '@versions/1.7.5/pages/BO/catalog/products';
4+
5+
/**
6+
* Bo products page, contains functions that can be used on the page
7+
* @class
8+
* @extends ProductsPage
9+
*/
10+
class BOProductsVersion extends ProductsPage implements BOProductsPageInterface {
11+
/**
12+
* @constructs
13+
* Setting up texts and selectors to use on products page
14+
*/
15+
constructor() {
16+
super();
17+
18+
// Products list
19+
this.productsListTableColumnName = (row: number) => `${this.productsListTableRow(row)} td:nth-child(3) a`;
20+
this.productsListTableColumnReference = (row: number) => `${this.productsListTableRow(row)} td:nth-child(4)`;
21+
this.productsListTableColumnCategory = (row: number) => `${this.productsListTableRow(row)} td:nth-child(5)`;
22+
this.productsListTableColumnPriceTExc = (row: number) => `${this.productsListTableRow(row)} td:nth-child(6) a`;
23+
this.productsListTableColumnPriceATI = (row: number) => `${this.productsListTableRow(row)} td:nth-child(7)`;
24+
this.productsListTableColumnStatus = (row: number) => `${this.productsListTableRow(row)} td:nth-child(8)`;
25+
this.productListTableDropDownList = (row: number) => `${this.productsListTableRow(row)} td div.btn-group-action `
26+
+ 'a.dropdown-toggle';
27+
28+
// Bulk actions
29+
this.selectAllProductsCheckbox = '#bulk_action_select_all';
30+
}
31+
}
32+
33+
const productsPage = new BOProductsVersion();
34+
export {productsPage, BOProductsVersion as ProductsPage};

src/versions/develop/pages/BO/catalog/products/create/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class CreateProduct extends BOBasePage implements BOProductsCreatePageInterface
7878

7979
public saveProductButton: string;
8080

81-
private readonly deleteProductButton: string;
81+
protected deleteProductButton: string;
8282

8383
private readonly deleteProductFooterModal: string;
8484

src/versions/develop/pages/BO/catalog/products/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ class ProductsPage extends BOBasePage implements BOProductsPageInterface {
765765
// Do nothing
766766
}
767767
// click on search
768+
await page.mouse.click(100, 100);
768769
await this.clickAndWaitForLoadState(page, this.filterSearchButton, 'networkidle', 10000);
769770
}
770771

0 commit comments

Comments
 (0)