Skip to content

Commit 862d611

Browse files
authored
Merge pull request #176 from Progi1984/modPsFacetedsearchBoFilterTemplate
`foClassicCategoryPage` : Added method `isSearchFilterSlider`
2 parents c862509 + 9ed7a5a commit 862d611

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/interfaces/FO/category/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ export interface FoCategoryPageInterface extends FOBasePagePageInterface {
4141
isAddedToWishlist(page: Page, idxProduct: number): Promise<boolean>;
4242
isCategoryPage(page: Page): Promise<boolean>;
4343
isPagesListVisible(page: Page): Promise<boolean>;
44+
isSearchFilterCheckbox(page: Page, facetType: string, facetLabel?: string): Promise<boolean>;
4445
isSearchFilterDropdown(page: Page, facetType: string, facetLabel?: string): Promise<boolean>;
4546
isSearchFilterRadio(page: Page, facetType: string, facetLabel?: string): Promise<boolean>;
46-
isSearchFiltersCheckbox(page: Page, facetType: string, facetLabel?: string): Promise<boolean>;
47+
isSearchFilterSlider(page: Page, facetType: string, facetLabel?: string): Promise<boolean>
4748
isSortButtonVisible(page: Page): Promise<boolean>;
4849
isSupplierListDropdown(page: Page): Promise<boolean>;
4950
quickViewProduct(page: Page, id: number): Promise<void>;

src/versions/develop/pages/FO/classic/category/index.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ class CategoryPage extends FOBasePage implements FoCategoryPageInterface {
8787

8888
private readonly searchFiltersDropdown: (facetType: string, facetLabel: string) => string;
8989

90-
protected closeOneFilter: (row: number) => string;
90+
protected searchFiltersSlider: (facetType: string, facetLabel: string) => string;
9191

92-
protected searchFiltersSlider: string;
92+
protected closeOneFilter: (row: number) => string;
9393

9494
private readonly searchFilterPriceValues: string;
9595

@@ -171,7 +171,8 @@ class CategoryPage extends FOBasePage implements FoCategoryPageInterface {
171171
+ 'label.facet-label input[type="radio"]';
172172
this.searchFiltersDropdown = (facetType: string, facetLabel: string) => `${this.searchFilter(facetType, facetLabel)
173173
} .facet-dropdown`;
174-
this.searchFiltersSlider = '.ui-slider-horizontal';
174+
this.searchFiltersSlider = (facetType: string, facetLabel: string) => `${this.searchFilter(facetType, facetLabel)
175+
}.faceted-slider`;
175176
this.searchFilterPriceValues = '[id*=facet_label]';
176177
this.clearAllFiltersLink = '#_desktop_search_filters_clear_all button.js-search-filters-clear-all';
177178
this.activeSearchFilters = '#js-active-search-filters';
@@ -508,7 +509,7 @@ class CategoryPage extends FOBasePage implements FoCategoryPageInterface {
508509
* @param facetLabel {string} Facet label
509510
* @return {Promise<boolean>}
510511
*/
511-
async isSearchFiltersCheckbox(page: Page, facetType: string, facetLabel: string = ''): Promise<boolean> {
512+
async isSearchFilterCheckbox(page: Page, facetType: string, facetLabel: string = ''): Promise<boolean> {
512513
return (await this.getNumSearchFiltersCheckbox(page, facetType, facetLabel)) !== 0;
513514
}
514515

@@ -632,7 +633,7 @@ class CategoryPage extends FOBasePage implements FoCategoryPageInterface {
632633
* @return {Promise<void>}
633634
*/
634635
async filterByPrice(page: Page, minPrice: number, maxPrice: number, filterFrom: number, filterTo: number): Promise<void> {
635-
const sliderTrack = page.locator(this.searchFiltersSlider);
636+
const sliderTrack = page.locator(this.searchFiltersSlider('price', ''));
636637
const sliderOffsetWidth = await sliderTrack.evaluate((el) => el.getBoundingClientRect().width);
637638
const pxOneEuro = sliderOffsetWidth / (maxPrice - minPrice);
638639

@@ -668,6 +669,17 @@ class CategoryPage extends FOBasePage implements FoCategoryPageInterface {
668669
return (await page.locator(this.searchFiltersDropdown(facetType, facetLabel)).count()) !== 0;
669670
}
670671

672+
/**
673+
* Return if search filters use slider
674+
* @param page {Page} Browser tab
675+
* @param facetType {string} Facet type
676+
* @param facetLabel {string} Facet label
677+
* @return {Promise<boolean>}
678+
*/
679+
async isSearchFilterSlider(page: Page, facetType: string, facetLabel: string = ''): Promise<boolean> {
680+
return (await page.locator(this.searchFiltersSlider(facetType, facetLabel)).count()) !== 0;
681+
}
682+
671683
/**
672684
* Add a product (based on its index) to the first wishlist
673685
* @param page {Page}

src/versions/develop/pages/FO/hummingbird/category/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CategoryPage extends CategoryPageVersion implements FoCategoryPageInterfac
4040
this.searchFiltersLabel = `${this.searchFilters} label.form-check-label`;
4141
this.clearAllFiltersLink = `${this.searchFilters} button.js-search-filters-clear-all`;
4242
this.searchFilterPriceSlider = 'div.faceted-slider';
43-
this.searchFiltersSlider = 'div.noUi-base';
43+
this.searchFiltersSlider = () => `${this.searchFilters} div.faceted-slider`;
4444
this.closeOneFilter = (row: number) => `#js-active-search-filters ul li:nth-child(${row + 1}) a i`;
4545

4646
// Pagination selectors

0 commit comments

Comments
 (0)