import { by , ElementFinder , protractor } from 'protractor' ; import { GenericFilter } from './generic-filter' ; import { isPresentAndDisplayed } from '../../../utilities/utils' ; import { BrowserActions } from '@alfresco/adf-testing' ; export class CreatedDateFilter extends GenericFilter { constructor ( ) { super ( 'Created date' ) ; } fromField : ElementFinder = this . filterDialogOpened . element ( by . cssContainingText ( '.adf-search-date-range .mat-form-field' , 'From' ) ) ; fromInput : ElementFinder = this . fromField . element ( by . css ( `[data-automation-id='date-range-from-input']` ) ) ; fromFieldError : ElementFinder = this . fromField . element ( by . css ( `[data-automation-id='date-range-from-error']` ) ) ; toField : ElementFinder = this . filterDialogOpened . element ( by . cssContainingText ( '.adf-search-date-range .mat-form-field' , 'To' ) ) ; toInput : ElementFinder = this . toField . element ( by . css ( `[data-automation-id='date-range-to-input']` ) ) ; toFieldError : ElementFinder = this . toField . element ( by . css ( `[data-automation-id='date-range-to-error']` ) ) ; async isFromFieldDisplayed ( ) { return isPresentAndDisplayed ( this . fromField ) ; } async isFromErrorDisplayed ( ) { return isPresentAndDisplayed ( this . fromFieldError ) ; } async isToFieldDisplayed ( ) { return isPresentAndDisplayed ( this . toField ) ; } async isToErrorDisplayed ( ) { return isPresentAndDisplayed ( this . toFieldError ) ; } async getFromValue ( ) { return BrowserActions . getInputValue ( this . fromInput ) ; } async getFromError ( ) { try { return await this . fromFieldError . getText ( ) ; } catch ( err ) { return '' ; } } async getToValue ( ) { return BrowserActions . getInputValue ( this . fromInput ) ; } async getToError ( ) { try { return await this . toFieldError . getText ( ) ; } catch ( err ) { return '' ; } } async resetPanel ( ) { const fromValue = await this . getFromValue ( ) ; const toValue = await this . getToValue ( ) ; if ( fromValue . length > 0 || toValue . length > 0 ) { await this . openDialog ( ) ; await this . clickResetButton ( ) ; await this . closeDialog ( ) ; } } async enterFromDate ( date ) { await this . openDialog ( ) ; await BrowserActions . clearWithBackSpace ( this . fromInput ) ; await this . fromInput . sendKeys ( date , protractor . Key . TAB ) ; } async enterToDate ( date ) { await this . openDialog ( ) ; await BrowserActions . clearWithBackSpace ( this . toInput ) ; await this . toInput . sendKeys ( date , protractor . Key . TAB ) ; } }