import { by } from 'protractor' ; import { DateTimePicker } from '../../components/datetime-picker/datetime-picker' ; import { GenericDialog } from '../dialog/generic-dialog' ; import { isPresentAndEnabled } from '../../utilities/utils' ; import { BrowserActions } from '@alfresco/adf-testing' ; export class ShareDialog extends GenericDialog { dateTimePicker = new DateTimePicker ( ) ; dialogTitle = this . childElement ( by . css ( `[data-automation-id='adf-share-dialog-title']` ) ) ; infoText = this . childElement ( by . css ( '.adf-share-link__info' ) ) ; labels = this . rootElem . all ( by . css ( '.adf-share-link__label' ) ) ; shareToggle = this . childElement ( by . css ( `[data-automation-id='adf-share-toggle']` ) ) ; url = this . childElement ( by . css ( `[data-automation-id='adf-share-link']` ) ) ; urlAction = this . childElement ( by . css ( '.adf-input-action' ) ) ; expireToggle = this . childElement ( by . css ( `[data-automation-id='adf-expire-toggle']` ) ) ; expireInput = this . childElement ( by . css ( 'input[formcontrolname="time"]' ) ) ; datetimePickerButton = this . childElement ( by . css ( '.mat-datetimepicker-toggle' ) ) ; closeButton = this . childElement ( by . css ( `[data-automation-id='adf-share-dialog-close']` ) ) ; constructor ( ) { super ( '.adf-share-dialog' ) ; } async getDialogTitle ( ) { return this . dialogTitle . getText ( ) ; } async getInfoText ( ) { return this . infoText . getText ( ) ; } async getLinkUrl ( ) { return BrowserActions . getInputValue ( this . url ) ; } async isUrlReadOnly ( ) { const urlAttr = await this . url . getAttribute ( 'readonly' ) ; return urlAttr === 'true' ; } async isCloseEnabled ( ) { return isPresentAndEnabled ( this . closeButton ) ; } async clickClose ( ) { await this . closeButton . click ( ) ; await this . waitForDialogToClose ( ) ; } async isShareToggleChecked ( ) { const toggleClass = await this . shareToggle . getAttribute ( 'class' ) ; return toggleClass . includes ( 'checked' ) ; } async isShareToggleDisabled ( ) { const toggleClass = await this . shareToggle . getAttribute ( 'class' ) ; return toggleClass . includes ( 'mat-disabled' ) ; } async isExpireToggleEnabled ( ) { const toggleClass = await this . expireToggle . getAttribute ( 'class' ) ; return toggleClass . includes ( 'checked' ) ; } async closeDatetimePicker ( ) { if ( await this . dateTimePicker . isCalendarOpen ( ) ) { await BrowserActions . click ( this . datetimePickerButton ) ; } } async getExpireDate ( ) { return BrowserActions . getInputValue ( this . expireInput ) ; } }