import { browser , by } from 'protractor' ; import { Component } from '../component' ; import { waitForPresence , waitForStaleness } from '../../utilities/utils' ; import { BrowserActions } from '@alfresco/adf-testing' ; export class DropDownBreadcrumb extends Component { pathOptionCss = '.adf-dropdown-breadcrumb-path-option .mat-option-text' ; trigger = this . byCss ( '.adf-dropdown-breadcrumb-trigger' ) ; pathItems = browser . $$ ( this . pathOptionCss ) ; pathItemsContainer = this . byCss ( '.mat-select-panel' , browser ) ; currentFolder = this . byCss ( '.adf-current-folder' ) ; constructor ( ancestor ? ) { super ( '.adf-dropdown-breadcrumb' , ancestor ) ; } async waitForPathListDropdownToOpen ( ) { return waitForPresence ( this . pathItemsContainer , 'Timeout waiting for breadcrumb dropdown to open' ) ; } async waitForPathListDropdownToClose ( ) { return waitForStaleness ( browser . $ ( this . pathOptionCss ) , 'Timeout waiting for breadcrumb dropdown to close' ) ; } async openPath ( ) { await BrowserActions . click ( this . trigger ) ; await this . waitForPathListDropdownToOpen ( ) ; } async clickPathItem ( name ) { const elem = browser . element ( by . cssContainingText ( this . pathOptionCss , name ) ) ; await BrowserActions . click ( elem ) ; } async getPathItems ( ) { return this . pathItems . map ( async ( elem ) => { return elem . getText ( ) ; } ) ; } }