import { $ , $$ , browser , by , element , ElementFinder } from 'protractor' ; export class FiltersPage { async getPage ( ) { await browser . get ( '#/filters' ) ; } container = element ( by . id ( 'container' ) ) ; authorMenu = element ( by . id ( 'authorMenu' ) ) ; statusMenu = element ( by . id ( 'statusMenu' ) ) ; title = element ( by . id ( 'tableTitle' ) ) ; table = element ( by . id ( 'tableRow' ) ) ; confirmClassExists ( item , soughtClass ) { return item . getAttribute ( 'class' ) . then ( function ( classes ) { var allClasses = classes . split ( ' ' ) ; if ( allClasses . indexOf ( soughtClass ) > - 1 ) { return true ; } else { return false ; } } ) ; } confirmAuthorsAreFiltered ( ) { return this . confirmClassExists ( this . getAuthorMenuBtn ( ) , 'active' ) ; } confirmStatusIsFiltered ( ) { return this . confirmClassExists ( this . getStatusMenuBtn ( ) , 'active' ) ; } confirmFilterItemIsHighlighted ( index ) { return this . confirmClassExists ( this . getFilterItem ( index ) , 'highlighted' ) ; } confirmAuthorMenuIsExpanded ( ) { return $ ( '.ux-dynamic-filter-menu' ) . isPresent ( ) ; } confirmStatusMenuIsExpanded ( ) { return $ ( '.ux-filter-menu' ) . isPresent ( ) ; } confirmAuthorMenuItemCheckExists ( index ) { return $ ( '.ux-dynamic-filter-menu' ) . $$ ( '.ux-menu-item' ) . get ( index ) . $ ( 'ux-icon' ) . isDisplayed ( ) ; } confirmStatusMenuItemCheckExists ( index ) { return $ ( '.ux-filter-menu' ) . $$ ( '.ux-menu-item' ) . get ( index ) . $ ( 'ux-icon' ) . isDisplayed ( ) ; } confirmClearAllIsVisible ( ) { return this . container . $ ( 'button.btn-link' ) . isPresent ( ) ; } confirmItemStatus ( index ) { return this . table . $$ ( 'tr.clickable' ) . get ( index ) . $ ( 'td.text-center' ) . $ ( 'ux-icon' ) . isPresent ( ) ; } getAuthorMenuBtn ( ) { return this . authorMenu . $ ( 'button.filter-dropdown' ) ; } getAuthorMenuItem ( index ) { return $ ( '.ux-dynamic-filter-menu' ) . $$ ( '.ux-menu-item' ) . get ( index ) . $ ( '.filter-dropdown-title' ) ; } getStatusMenuBtn ( ) { return this . statusMenu . $ ( 'div.btn-group' ) . $ ( 'button.filter-dropdown' ) ; } getStatusMenuItem ( index ) { return $ ( '.ux-filter-menu' ) . $$ ( '.ux-menu-item' ) . get ( index ) . $ ( '.filter-dropdown-title' ) ; } getFilter ( ) { return $ ( '.ux-dynamic-filter-menu' ) . $ ( '.typeahead-box' ) . $ ( 'input.form-control' ) ; } getFilterItem ( index ) { return $ ( '.ux-dynamic-filter-menu' ) . $ ( '.typeahead-box' ) . $ ( '.ux-typeahead-options' ) . $$ ( 'li' ) . get ( index ) ; } getAuthorMenuItemText ( index ) { return this . getAuthorMenuItem ( index ) . getText ( ) ; } getPlaceholderText ( ) { return this . getFilter ( ) . getAttribute ( 'placeholder' ) ; } getFilterItemText ( index ) { return this . getFilterItem ( index ) . getText ( ) ; } getFilterText ( index ) { return this . getFilterItem ( index ) . $ ( 'span' ) . $ ( 'b' ) . getText ( ) ; } getStatusMenuItemText ( index ) { return this . getStatusMenuItem ( index ) . getText ( ) ; } getTitleText ( index ) { return this . title . $$ ( 'th.text-black' ) . get ( index ) . getText ( ) ; } getItemText ( index , index2 ) { return this . table . $$ ( 'tr.clickable' ) . get ( index ) . $$ ( 'td' ) . get ( index2 ) . getText ( ) ; } getPercentageOfWorkCompleted ( index ) { return this . table . $$ ( 'tr.clickable' ) . get ( index ) . $$ ( 'td' ) . get ( 4 ) . $ ( 'ux-spark' ) . $ ( 'div.ux-spark-inline-label-container' ) . $ ( 'div.ux-spark-inline-label-left' ) . getText ( ) ; } clickOnAuthorMenu ( ) { return this . getAuthorMenuBtn ( ) . click ( ) ; } clickOnAuthorMenuItem ( index ) { return this . getAuthorMenuItem ( index ) . click ( ) ; } clickOnFilter ( ) { return this . getFilter ( ) . click ( ) ; } clickOnFilterItem ( index ) { return this . getFilterItem ( index ) . $ ( 'span' ) . click ( ) ; } clickOnStatusMenu ( ) { return this . getStatusMenuBtn ( ) . click ( ) ; } clickOnStatusMenuItem ( index ) { return this . getStatusMenuItem ( index ) . click ( ) ; } clickOnClearAll ( ) { return this . container . $ ( 'button.btn-link' ) . click ( ) ; } getNumberOfItems ( ) { return this . table . $$ ( 'tr.clickable' ) . count ( ) ; } getNumberOfFilterItems ( ) { return $ ( '.ux-dynamic-filter-menu' ) . $ ( '.ux-typeahead-options' ) . $$ ( 'li' ) . count ( ) ; } hoverOverFilterItem ( index ) { browser . actions ( ) . mouseMove ( this . getFilterItem ( index ) ) . perform ( ) ; } async closeMenus ( ) { return $$ ( '.cdk-overlay-backdrop.cdk-overlay-backdrop-showing' ) . click ( ) ; } }