import { by } from 'protractor' ; import { GenericDialog } from '../dialog/generic-dialog' ; import { isPresentAndDisplayed , isPresentAndEnabled , typeText } from '../../utilities/utils' ; import { BrowserActions , BrowserVisibility } from '@alfresco/adf-testing' ; export class CreateOrEditFolderDialog extends GenericDialog { createButton = this . childElement ( by . cssContainingText ( '.mat-dialog-actions button' , 'Create' ) ) ; cancelButton = this . childElement ( by . id ( 'adf-folder-cancel-button' ) ) ; updateButton = this . childElement ( by . cssContainingText ( '.mat-dialog-actions button' , 'Update' ) ) ; nameInput = this . rootElem . element ( by . id ( 'adf-folder-name-input' ) ) ; titleInput = this . rootElem . element ( by . id ( 'adf-folder-title-input' ) ) ; descriptionTextArea = this . rootElem . element ( by . id ( 'adf-folder-description-input' ) ) ; validationMessage = this . rootElem . element ( by . css ( '.mat-hint span' ) ) ; constructor ( ) { super ( 'adf-folder-dialog' ) ; } async waitForDialogToOpen ( ) { await super . waitForDialogToOpen ( ) ; await BrowserVisibility . waitUntilElementIsClickable ( this . nameInput ) ; } async isUpdateButtonEnabled ( ) { return isPresentAndEnabled ( this . updateButton ) ; } async isCreateButtonEnabled ( ) { return isPresentAndEnabled ( this . createButton ) ; } async isCancelButtonEnabled ( ) { return isPresentAndEnabled ( this . cancelButton ) ; } async getValidationMessage ( ) { if ( await isPresentAndDisplayed ( this . validationMessage ) ) { return this . validationMessage . getText ( ) ; } else { return '' ; } } async getName ( ) { return BrowserActions . getInputValue ( this . nameInput ) ; } async getDescription ( ) { return BrowserActions . getInputValue ( this . descriptionTextArea ) ; } async enterName ( name ) { await typeText ( this . nameInput , name ) ; } async enterDescription ( description ) { await typeText ( this . descriptionTextArea , description ) ; } async clickCancel ( ) { await BrowserActions . click ( this . cancelButton ) ; await this . waitForDialogToClose ( ) ; } }