import { by } from 'protractor' ; import { GenericDialog } from '../dialog/generic-dialog' ; import { isPresentAndDisplayed , isPresentAndEnabled , typeText } from '../../utilities/utils' ; import { BrowserActions } from '@alfresco/adf-testing' ; export class CreateFromTemplateDialog extends GenericDialog { createButton = this . childElement ( by . cssContainingText ( '.mat-dialog-actions button' , 'Create' ) ) ; cancelButton = this . childElement ( by . cssContainingText ( '.mat-dialog-actions button' , 'CANCEL' ) ) ; nameInput = this . childElement ( by . css ( 'input[formcontrolname="name"]' ) ) ; titleInput = this . childElement ( by . css ( 'input[formcontrolname="title"]' ) ) ; descriptionTextArea = this . childElement ( by . css ( 'textarea[formcontrolname="description"]' ) ) ; validationMessage = this . childElement ( by . css ( '.mat-error' ) ) ; constructor ( ) { super ( '.aca-create-from-template-dialog' ) ; } async isValidationMessageDisplayed ( ) { return isPresentAndDisplayed ( this . validationMessage ) ; } async isCreateButtonEnabled ( ) { return isPresentAndEnabled ( this . createButton ) ; } async isCancelButtonEnabled ( ) { return isPresentAndEnabled ( this . cancelButton ) ; } async getValidationMessage ( ) { if ( await this . isValidationMessageDisplayed ( ) ) { return this . validationMessage . getText ( ) ; } else { return '' ; } } async getNameInputValue ( ) { return BrowserActions . getInputValue ( this . nameInput ) ; } async getDescriptionValue ( ) { return BrowserActions . getInputValue ( this . descriptionTextArea ) ; } async getTitleInputValue ( ) { return BrowserActions . getInputValue ( this . titleInput ) ; } async enterName ( name ) { await typeText ( this . nameInput , name ) ; } async enterTitle ( title ) { await typeText ( this . titleInput , title ) ; } async enterDescription ( description ) { await typeText ( this . descriptionTextArea , description ) ; } async clickCancel ( ) { await BrowserActions . click ( this . cancelButton ) ; await this . waitForDialogToClose ( ) ; } }