import { browser , by , By } from 'protractor' ; import { BrowsingPage } from './browsing-page' ; import { SearchSortingPicker } from '../components/search/search-sorting-picker' ; import { SearchFilters } from '../components/search/search-filters' ; import { BrowserActions } from '@alfresco/adf-testing' ; export class SearchResultsPage extends BrowsingPage { root = this . byCss ( 'aca-search-results' ) ; chipList = this . root . element ( by . css ( '.adf-search-chip-list' ) ) ; infoText = this . root . element ( by . css ( '.adf-search-results--info-text' ) ) ; sortingPicker = new SearchSortingPicker ( 'aca-search-results' ) ; filters = new SearchFilters ( 'aca-search-results' ) ; async waitForResults ( ) { await this . dataTable . waitForBody ( ) ; } async getResultsFoundText ( ) { return this . infoText . getText ( ) ; } async getName ( name ) { return this . dataTable . getRowByName ( name ) . element ( by . css ( '[title="Name"] div.search-file-name' ) ) . getText ( ) ; } async getDescription ( name ) { return this . dataTable . getRowByName ( name ) . element ( by . css ( '[title="Description"]' ) ) . getText ( ) ; } async getModified ( name ) { return BrowserActions . getAttribute ( this . dataTable . getRowByName ( name ) . element ( by . css ( '[title="Modified"] span' ) ) , 'title' ) ; } async getSize ( name ) { return this . dataTable . getRowByName ( name ) . element ( by . css ( '[title="Size"]' ) ) . getText ( ) ; } async getModifiedBy ( name ) { return this . dataTable . getRowByName ( name ) . element ( by . css ( '[title="Modified by"]' ) ) . getText ( ) ; } async getLocation ( name ) { return this . dataTable . getRowByName ( name ) . element ( by . css ( '[title="Name"] a' ) ) . getText ( ) ; } async getResultsChipsValues ( ) { const chips = this . chipList . all ( by . css ( '.mat-chip' ) ) ; return chips . map ( async ( elem ) => { return ( await elem . getText ( ) ) . replace ( `\ncancel` , '' ) ; } ) ; } async removeChip ( chipName ) { const chip = browser . element ( By . cssContainingText ( '.mat-chip' , chipName ) ) ; const closeChip = chip . element ( by . css ( '.mat-chip-remove' ) ) ; await BrowserActions . click ( closeChip ) ; } }