import { ElementFinder , by , browser , Locator } from 'protractor' ; import { isPresentAndDisplayed , waitForPresence , waitForStaleness } from '../../utilities/utils' ; import { BrowserVisibility , Logger } from '@alfresco/adf-testing' ; export abstract class GenericDialog { protected constructor ( private rootCssSelector ? ) { } get rootElem ( ) : ElementFinder { return browser . element ( by . css ( this . rootCssSelector ) ) ; } get title ( ) : ElementFinder { return this . rootElem . element ( by . css ( '.mat-dialog-title' ) ) ; } get content ( ) : ElementFinder { return this . rootElem . element ( by . css ( '.mat-dialog-content' ) ) ; } async getText ( ) { return this . content . getText ( ) ; } async waitForDialogToOpen ( ) { await waitForPresence ( this . rootElem ) ; await BrowserVisibility . waitUntilElementIsVisible ( this . content ) ; await waitForPresence ( browser . element ( by . css ( '.cdk-overlay-backdrop' ) ) ) ; } async waitForDialogToClose ( ) { try { await waitForStaleness ( this . content ) ; } catch ( error ) { Logger . error ( `GenericDialog waitForDialogToClose :  catch : ${ error }` ) ; } } async isDialogOpen ( ) { return isPresentAndDisplayed ( this . rootElem ) ; } async getDialogTitle ( ) { return this . title . getText ( ) ; } protected childElement ( selector ) { return this . rootElem . element ( selector ) ; } }