import { by , ElementFinder } from 'protractor' ; import { GenericDialog } from '../dialog/generic-dialog' ; import { isPresentAndEnabled , typeText } from '../../utilities/utils' ; import { BrowserActions , BrowserVisibility } from '@alfresco/adf-testing' ; export class CreateLibraryDialog extends GenericDialog { createButton = this . childElement ( by . cssContainingText ( '.mat-dialog-actions button' , 'Create' ) ) ; cancelButton = this . childElement ( by . cssContainingText ( '.mat-dialog-actions button' , 'Cancel' ) ) ; nameInput = this . rootElem . element ( by . css ( 'input[formcontrolname="title"]' ) ) ; libraryIdInput = this . rootElem . element ( by . css ( 'input[formcontrolname="id"]' ) ) ; descriptionTextArea = this . rootElem . element ( by . css ( 'textarea[formcontrolname="description"]' ) ) ; visibilityPublic = this . rootElem . element ( by . cssContainingText ( '.mat-radio-label' , 'Public' ) ) ; visibilityModerated = this . rootElem . element ( by . cssContainingText ( '.mat-radio-label' , 'Moderated' ) ) ; visibilityPrivate = this . rootElem . element ( by . cssContainingText ( '.mat-radio-label' , 'Private' ) ) ; errorMessage = this . rootElem . element ( by . css ( '.mat-error' ) ) ; constructor ( ) { super ( 'adf-library-dialog' ) ; } async waitForDialogToOpen ( ) { await super . waitForDialogToOpen ( ) ; await BrowserVisibility . waitUntilElementIsClickable ( this . nameInput ) ; } async getErrorMessage ( ) { if ( await this . errorMessage . isDisplayed ( ) ) { return this . errorMessage . getText ( ) ; } return '' ; } async enterName ( name ) { await typeText ( this . nameInput , name ) ; } async enterLibraryId ( id ) { await typeText ( this . libraryIdInput , id ) ; } async enterDescription ( description ) { await typeText ( this . descriptionTextArea , description ) ; } async isCreateEnabled ( ) { return isPresentAndEnabled ( this . createButton ) ; } async isCancelEnabled ( ) { return isPresentAndEnabled ( this . cancelButton ) ; } async clickCancel ( ) { await BrowserActions . click ( this . cancelButton ) ; await this . waitForDialogToClose ( ) ; } private async isChecked ( target ) { const elemClass = await target . element ( by . xpath ( '..' ) ) . getAttribute ( 'class' ) ; return elemClass . includes ( 'mat-radio-checked' ) ; } async isPublicChecked ( ) { return this . isChecked ( this . visibilityPublic ) ; } async isModeratedChecked ( ) { return this . isChecked ( this . visibilityModerated ) ; } async isPrivateChecked ( ) { return this . isChecked ( this . visibilityPrivate ) ; } }