import { ElementFinder , ElementArrayFinder , by , browser } from 'protractor' ; import { GenericFilter } from './generic-filter' ; import { BrowserActions } from '@alfresco/adf-testing' ; export class FacetFilter extends GenericFilter { private readonly locators = { checkbox : '.mat-menu-content .mat-checkbox' , checkboxChecked : '.mat-menu-content .mat-checkbox.mat-checkbox-checked' , categoryInput : '.mat-menu-content input[data-automation-id^="facet-result-filter"]' , facetsFilter : '.mat-menu-content .adf-facet-result-filter' } ; get facets ( ) : ElementArrayFinder { return this . filterDialogOpened . all ( by . css ( this . locators . checkbox ) ) ; } get selectedFacets ( ) : ElementArrayFinder { return this . filterDialogOpened . all ( by . css ( this . locators . checkboxChecked ) ) ; } get facetsFilter ( ) : ElementFinder { return this . filterDialogOpened . element ( by . css ( this . locators . facetsFilter ) ) ; } get filterCategoryInput ( ) : ElementFinder { return this . facetsFilter . element ( by . css ( this . locators . categoryInput ) ) ; } async getFiltersValues ( ) { return this . facets . map ( ( option ) => { return option . getText ( ) ; } ) ; } async getFiltersCheckedValues ( ) { return this . selectedFacets . map ( ( option ) => { return option . getText ( ) ; } ) ; } async resetPanel ( ) { if ( ( await this . selectedFacets . count ( ) ) > 0 ) { await this . openDialog ( ) ; await this . selectedFacets . each ( async ( elem ) => { await BrowserActions . click ( elem ) ; } ) ; } await this . openDialog ( ) ; } async isFilterFacetsDisplayed ( ) { return this . facetsFilter . isDisplayed ( ) ; } async isFilterCategoryInputDisplayed ( ) { return this . filterCategoryInput . isDisplayed ( ) ; } async checkCategory ( name ) { const option = this . facets . filter ( async ( elem ) => ( await elem . getText ( ) ) . includes ( name ) ) . first ( ) ; await browser . executeScript ( `arguments[0].scrollIntoView();` , option ) ; await browser . actions ( ) . mouseMove ( option ) . perform ( ) ; await browser . actions ( ) . click ( ) . perform ( ) ; } async filterCategoriesBy ( name ) { await this . filterCategoryInput . sendKeys ( name ) ; } }