import { by , browser , ElementFinder } from 'protractor' ; import { Component } from '../component' ; import { isPresentAndEnabled , isPresentAndDisplayed } from '../../utilities/utils' ; import { BrowserActions , BrowserVisibility } from '@alfresco/adf-testing' ; export class ContentMetadata extends Component { expandedPanel = this . byCss ( '.mat-expansion-panel.mat-expanded' ) ; propertyList = this . byCss ( '.adf-property-list' ) ; propertyListElements = this . allByCss ( '.adf-property' ) ; propertyValue = this . byCss ( '.adf-property-value' ) ; editPropertiesButton = this . byCss ( `button[title='Edit']` ) ; lessInfoButton = this . byCssText ( `[data-automation-id='meta-data-card-toggle-expand']` , 'Less information' ) ; moreInfoButton = this . byCssText ( `[data-automation-id='meta-data-card-toggle-expand']` , 'More information' ) ; imagePropertiesPanel = this . byCss ( `[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE']` ) ; expandedImagePropertiesPanel = this . byCss ( `[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE'].mat-expanded` ) ; constructor ( ancestor ? ) { super ( 'adf-content-metadata-card' , ancestor ) ; } async isPropertiesListExpanded ( ) { return browser . isElementPresent ( this . expandedPanel ) ; } async waitForImagePropertiesPanelToExpand ( ) { await BrowserVisibility . waitUntilElementIsVisible ( this . expandedImagePropertiesPanel ) ; } async getVisiblePropertiesLabels ( ) { return this . allByCss ( '.adf-property-label' ) . filter ( async ( elem ) => elem . isDisplayed ( ) ) . map ( async ( elem ) => elem . getText ( ) ) ; } async getVisiblePropertiesValues ( ) { return this . allByCss ( '.adf-property-value' ) . filter ( async ( elem ) => elem . isDisplayed ( ) ) . map ( async ( elem ) => { if ( await elem . isElementPresent ( by . css ( '.mat-checkbox' ) ) ) { return ! ! ( await elem . isElementPresent ( by . css ( '.mat-checkbox-checked' ) ) ) ; } return this . getElementValue ( elem ) ; } ) ; } async isEditPropertiesButtonEnabled ( ) { return isPresentAndEnabled ( this . editPropertiesButton ) ; } async isLessInfoButtonEnabled ( ) { return isPresentAndEnabled ( this . lessInfoButton ) ; } async isMoreInfoButtonEnabled ( ) { return isPresentAndEnabled ( this . moreInfoButton ) ; } async isMoreInfoButtonDisplayed ( ) { return browser . isElementPresent ( this . moreInfoButton ) ; } async isImagePropertiesPanelDisplayed ( ) { return isPresentAndDisplayed ( this . imagePropertiesPanel ) ; } private async getElementValue ( elem ) { const tagName = await elem . getTagName ( ) ; if ( tagName === 'input' || tagName === 'textarea' ) { return BrowserActions . getInputValue ( elem ) ; } return elem . getText ( ) ; } }