-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved POM
@pages\BO\modules\ps_facetedsearch
from Core
- Loading branch information
Showing
7 changed files
with
305 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/interfaces/BO/modules/ps_facetedsearch/filterTemplate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {ModuleConfigurationPageInterface} from '@interfaces/BO/modules/moduleConfiguration'; | ||
import {Page} from '@playwright/test'; | ||
|
||
export interface ModulePsFacetesearchFilterTemplatePageInterface extends ModuleConfigurationPageInterface { | ||
readonly submitFilter: string; | ||
readonly title: string; | ||
|
||
getPanelTitle(page: Page): Promise<string>; | ||
saveTemplate(page: Page): Promise<string>; | ||
setTemplateFilterForm( | ||
page: Page, | ||
filterName: string, | ||
status: boolean, | ||
filterType?: string, | ||
filterLimit?: string, | ||
): Promise<void>; | ||
setTemplateName(page: Page, name: string): Promise<void>; | ||
setTemplatePages(page: Page, controllers: string[]): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {ModuleConfigurationPageInterface} from '@interfaces/BO/modules/moduleConfiguration'; | ||
import {Page} from '@playwright/test'; | ||
|
||
export interface ModulePsFacetesearchMainPageInterface extends ModuleConfigurationPageInterface { | ||
readonly msgSuccessfulCreation: (name: string) => string; | ||
readonly msgSuccessfulDelete: string; | ||
readonly pageSubTitle: string; | ||
|
||
deleteFilterTemplate(page: Page, row: number): Promise<string>; | ||
editFilterTemplate(page: Page, row: number): Promise<void>; | ||
goToAddNewTemplate(page: Page): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type {ModulePsFacetesearchFilterTemplatePageInterface} from '@interfaces/BO/modules/ps_facetedsearch/filterTemplate'; | ||
|
||
/* eslint-disable global-require */ | ||
function requirePage(): ModulePsFacetesearchFilterTemplatePageInterface { | ||
return require('@versions/develop/pages/BO/modules/ps_facetedsearch/filterTemplate'); | ||
} | ||
/* eslint-enable global-require */ | ||
|
||
export default requirePage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type {ModulePsFacetesearchMainPageInterface} from '@interfaces/BO/modules/ps_facetedsearch/index'; | ||
|
||
/* eslint-disable global-require */ | ||
function requirePage(): ModulePsFacetesearchMainPageInterface { | ||
return require('@versions/develop/pages/BO/modules/ps_facetedsearch/index'); | ||
} | ||
/* eslint-enable global-require */ | ||
|
||
export default requirePage(); |
143 changes: 143 additions & 0 deletions
143
src/versions/develop/pages/BO/modules/ps_facetedsearch/filterTemplate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import {ModulePsFacetesearchFilterTemplatePageInterface} from '@interfaces/BO/modules/ps_facetedsearch/filterTemplate'; | ||
import ModuleConfiguration from '@pages/BO/modules/moduleConfiguration'; | ||
|
||
import type {Page} from 'playwright'; | ||
|
||
/** | ||
* Module configuration page for module : ps_facetedsearch, contains selectors and functions for the page | ||
* @class | ||
* @extends ModuleConfiguration | ||
*/ | ||
class PsFacetedSearchFilterTemplate extends ModuleConfiguration implements ModulePsFacetesearchFilterTemplatePageInterface { | ||
public readonly title: string; | ||
|
||
private readonly panel: string; | ||
|
||
private readonly panelTitle: string; | ||
|
||
private readonly templateNameInput: string; | ||
|
||
private readonly templateControllerCheckbox: (controller: string) => string; | ||
|
||
public readonly submitFilter: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up titles and selectors to use on ps email subscription page | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.title = 'New filters template'; | ||
|
||
// Selectors | ||
this.panel = '#content .panel'; | ||
this.panelTitle = `${this.panel} h3`; | ||
this.templateNameInput = `${this.panel} #layered_tpl_name`; | ||
this.templateControllerCheckbox = (controller: string) => `${this.panel} #fs_controller_${controller}`; | ||
this.submitFilter = '#submit-filter'; | ||
} | ||
|
||
/* Methods */ | ||
/** | ||
* Returns the panel title | ||
* @param page {Page} Browser tab | ||
* @returns {Promise<string>} | ||
*/ | ||
async getPanelTitle(page: Page): Promise<string> { | ||
return this.getTextContent(page, this.panelTitle); | ||
} | ||
|
||
/** | ||
* Set the template name | ||
* @param page {Page} Browser tab | ||
* @param name {string} Name of the template | ||
* @returns {Promise<void>} | ||
*/ | ||
async setTemplateName(page: Page, name: string): Promise<void> { | ||
await page.locator(this.templateNameInput).fill(name); | ||
} | ||
|
||
/** | ||
* Set the template name | ||
* @param page {Page} Browser tab | ||
* @param controllers {string[]} Controllers | ||
* @returns {Promise<void>} | ||
*/ | ||
async setTemplatePages(page: Page, controllers: string[]): Promise<void> { | ||
for (let c = 0; c < controllers.length; c++) { | ||
const controller: string = controllers[c]; | ||
|
||
await page.locator(this.templateControllerCheckbox(controller)).setChecked(true); | ||
} | ||
} | ||
|
||
/** | ||
* Set filters | ||
* @param page {Page} Browser tab | ||
* @param filterName {string} Filter Name | ||
* @param status {boolean} Status | ||
* @param filterType {string} Filter Type (checkbox, radio, dropdown) | ||
* @param filterLimit {string} Filter Limit (No Limit or a number) | ||
* @returns {Promise<void>} | ||
*/ | ||
async setTemplateFilterForm( | ||
page: Page, | ||
filterName: string, | ||
status: boolean, | ||
filterType: string = '', | ||
filterLimit: string = '', | ||
): Promise<void> { | ||
let selectorStatus: string; | ||
let selectorFilterType: string; | ||
|
||
switch (filterName) { | ||
case 'Product brand filter': | ||
selectorStatus = 'layered_selection_manufacturer'; | ||
break; | ||
case 'Product stock filter': | ||
selectorStatus = 'layered_selection_stock'; | ||
break; | ||
case 'Attribute group: Paper Type': | ||
selectorStatus = 'layered_selection_ag_4'; | ||
break; | ||
default: | ||
throw new Error(`The filter "${filterName}" has no defined selector.`); | ||
} | ||
await this.setChecked(page, `#${selectorStatus}`, status); | ||
|
||
if (filterType !== '') { | ||
switch (filterType) { | ||
case 'checkbox': | ||
selectorFilterType = 'Checkbox'; | ||
break; | ||
case 'radio': | ||
selectorFilterType = 'Radio button'; | ||
break; | ||
case 'dropdown': | ||
selectorFilterType = 'Drop-down list'; | ||
break; | ||
default: | ||
throw new Error(`The filter type "${filterType}" has no defined selector.`); | ||
} | ||
await this.selectByVisibleText(page, `select[name="${selectorStatus}_filter_type"]`, selectorFilterType); | ||
} | ||
|
||
if (filterLimit !== '') { | ||
await this.selectByValue(page, `select[name="${selectorStatus}_filter_show_limit"]`, filterLimit); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the panel title | ||
* @param page {Page} Browser tab | ||
* @returns {Promise<void>} | ||
*/ | ||
async saveTemplate(page: Page): Promise<string> { | ||
await this.clickAndWaitForURL(page, this.submitFilter); | ||
|
||
return this.getAlertSuccessBlockContent(page); | ||
} | ||
} | ||
|
||
module.exports = new PsFacetedSearchFilterTemplate(); |
111 changes: 111 additions & 0 deletions
111
src/versions/develop/pages/BO/modules/ps_facetedsearch/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import {ModulePsFacetesearchMainPageInterface} from '@interfaces/BO/modules/ps_facetedsearch'; | ||
import ModuleConfiguration from '@pages/BO/modules/moduleConfiguration'; | ||
import modPsFacetedsearchBoFilterTemplate from '@pages/BO/modules/ps_facetedsearch/filterTemplate'; | ||
|
||
import type {Page} from 'playwright'; | ||
|
||
/** | ||
* Module configuration page for module : ps_facetedsearch, contains selectors and functions for the page | ||
* @class | ||
* @extends ModuleConfiguration | ||
*/ | ||
class PsFacetedSearch extends ModuleConfiguration implements ModulePsFacetesearchMainPageInterface { | ||
public readonly pageSubTitle: string; | ||
|
||
public readonly msgSuccessfulCreation: (name: string) => string; | ||
|
||
public readonly msgSuccessfulDelete: string; | ||
|
||
private readonly gridPanel: string; | ||
|
||
private readonly gridTable: string; | ||
|
||
private readonly gridTableBody: string; | ||
|
||
private readonly gridTableBodyRows: string; | ||
|
||
private readonly gridTableBodyRow: (row: number) => string; | ||
|
||
private readonly gridTableBodyColumn: (row: number) => string; | ||
|
||
private readonly gridTableColumnActions: (row: number) => string; | ||
|
||
private readonly gridTableColumnActionsEditLink: (row: number) => string; | ||
|
||
private readonly gridTableColumnActionsDropdownBtn: (row: number) => string; | ||
|
||
private readonly gridTableColumnActionsDropdown: (row: number) => string; | ||
|
||
private readonly gridTableColumnActionsDeleteLink: (row: number) => string; | ||
|
||
private readonly gridPanelFooter: string; | ||
|
||
private readonly addTemplateLink: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up titles and selectors to use on ps email subscription page | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.pageSubTitle = 'Faceted search'; | ||
this.msgSuccessfulCreation = (name: string) => `Your filter "${name}" was added successfully.`; | ||
this.msgSuccessfulDelete = 'Filter template deleted, categories updated (reverted to default Filter template).'; | ||
|
||
this.gridPanel = 'div.panel'; | ||
this.gridTable = `${this.gridPanel} table.table`; | ||
this.gridTableBody = `${this.gridTable} tbody`; | ||
this.gridTableBodyRows = `${this.gridTableBody} tr`; | ||
this.gridTableBodyRow = (row: number) => `${this.gridTableBodyRows}:nth-child(${row})`; | ||
this.gridTableBodyColumn = (row: number) => `${this.gridTableBodyRow(row)} td`; | ||
this.gridTableColumnActions = (row: number) => `${this.gridTableBodyColumn(row)} .btn-group-action`; | ||
this.gridTableColumnActionsEditLink = (row: number) => `${this.gridTableColumnActions(row)} a.btn`; | ||
this.gridTableColumnActionsDropdownBtn = (row: number) => `${this.gridTableColumnActions(row)} button.dropdown-toggle`; | ||
this.gridTableColumnActionsDropdown = (row: number) => `${this.gridTableColumnActions(row)} ul.dropdown-menu`; | ||
this.gridTableColumnActionsDeleteLink = (row: number) => `${this.gridTableColumnActionsDropdown(row)} ` | ||
+ 'a[href*="&deleteFilterTemplate=1"]'; | ||
this.gridPanelFooter = `${this.gridPanel} div.panel-footer`; | ||
this.addTemplateLink = `${this.gridPanelFooter} a[href*="&add_new_filters_template=1"]`; | ||
} | ||
|
||
/* Methods */ | ||
/** | ||
* Edit a filter template | ||
* @param page {Page} Browser tab | ||
* @param row {number} Row number | ||
* @returns {Promise<number>} | ||
*/ | ||
async editFilterTemplate(page: Page, row: number): Promise<void> { | ||
await this.clickAndWaitForLoadState(page, this.gridTableColumnActionsEditLink(row)); | ||
await this.elementVisible(page, modPsFacetedsearchBoFilterTemplate.submitFilter); | ||
} | ||
|
||
/** | ||
* Delete a filter template | ||
* @param page {Page} Browser tab | ||
* @param row {number} Row number | ||
* @returns {Promise<string>} | ||
*/ | ||
async deleteFilterTemplate(page: Page, row: number): Promise<string> { | ||
// Add listener to dialog to accept erase | ||
await this.dialogListener(page); | ||
|
||
await page.locator(this.gridTableColumnActionsDropdownBtn(row)).click(); | ||
await this.elementVisible(page, this.gridTableColumnActionsDropdown(row)); | ||
await page.locator(this.gridTableColumnActionsDeleteLink(row)).click(); | ||
|
||
return this.getAlertSuccessBlockContent(page); | ||
} | ||
|
||
/** | ||
* Go to the "Add new template" page | ||
* @param page {Page} Browser tab | ||
* @returns {Promise<number>} | ||
*/ | ||
async goToAddNewTemplate(page: Page): Promise<void> { | ||
await page.locator(this.addTemplateLink).click(); | ||
} | ||
} | ||
|
||
module.exports = new PsFacetedSearch(); |