alfresco-ng2-components/e2e/core/pages/metadata-view.page.ts
Anukriti Singh a900dd2551
[ACS-5645] Property Panel Feature (#8995)
* [ACS-5645]Added edit functionality for each panel and updated test cases

* metadata e2e fix

* [ACS-5725]fixed failing e2es

* added unit test cases for new functionality

* minor fixes

* minor fixes

* minor fixes

* [ACS-5645]code modification

* [ACS-5645]removed unwanted code

* [ACS-5645]modified the changes

* [ACS-5645]removed unwanted space

* [ACS-5645]removed unwanted code

* [ACS-5645]Implemented changes as per the review comments

* linting fixes

* [ACS-5645]minor fixes

* [ACS-5645] removed unwanted code

* [ACS-5645]modified the change

* [ACS-5645]aligned input

* [ACS-5645]modified changes

* [ACS-5645]Implemented the changes as per the review comments

* [ACS-5645]linting fixes

* [ACS-5645]fixed sonarcloud issue

* [ACS-5645]fixed errors

* [ACS-5645]rename the function

* [ACS-5645]fixes linting

* [ACS-5540]lint fixes

* [ACS-5645]Implemented the changes as per review comments

* [ACS-5645] Removed unused code

* [ACS-5645]linting fixes

* [ACS-5645]fixes for lint

* [ACS-5645] e2e fixes

* [ACS-5645]Added translation

* [ACS-5645]fixes for e2e

* [ACS-5645]fixes for e2e

* [ACS-5645]e2e fixes

* [ACS-5645] Renamed the theme

* [ACS-5645]modified changes

* [ACS-5645] fixed lock-file bug

* [ACS-5645] added tooltips for save and cancel icons

* [ACS-5645] Modified the changes

* [ACS-5645]Modified the changes

* [ACS-5645] Implemented the changes as per the review comments

* [ACS-5645] Implemented the changes as per the review comments

* [ACS-5645]Modified the changes

* [ACS-5645] added group panel lock changes

* [ACS-5645] Resolved sonarcloud issue

* [ACS-5645] added test cases for tags component

* [ACS-5645] updated the documentation

* [ACS-5645] updated the documentation

* [ACS-5645] updated the documentation

* [ACS-5645] Implemented changes as per review comments

* [ACS-5645] lint fixes

* [ACS-5645] Implemented the review comments

* [ACS-5645] added focus

* [ACS-5645] modified the changes

* [ACS-5645] Lint fixes

* [ACS-5645] Lint fixes

* [ACS-5645] Lint fixes

* [ACS-5645] Removed unwanted code

* [ACS-5645] fixed sonarcloud issue

* [ACS-5645] Added missing translation key

* [ACS-5645] renamed the methods

* [ACS-5645]Added edit functionality for each panel and updated test cases

* [ACS-5645]code modification

* [ACS-5645]removed unwanted code

* [ACS-5645]Implemented changes as per the review comments

* [ACS-5645]Implemented the changes as per review comments

* [ACS-5645]linting fixes

* [ACS-5645] fixed lock-file bug

* [ACS-5645] Modified the changes

* [ACS-5645] added group panel lock changes

* [ACS-5645]Added edit functionality for each panel and updated test cases

* minor fixes

* [ACS-5645] Modified the changes

* [ACS-5645] added group panel lock changes

* [ACS-5645]Added edit functionality for each panel and updated test cases

* metadata e2e fix

* [ACS-5725]fixed failing e2es

* minor fixes

* [ACS-5645]removed unwanted code

* [ACS-5645]Implemented changes as per the review comments

* [ACS-5551] property panel design

* [ACS-5551] minor changes

* [ACS-5551]minor change

* [ACS-5551] updated checks for non -editable field

* [ACS-5551] modified the changes

* [ACS-5551] modified changes

* [ACS-5551] content-metadata updated

* [ACS-5551] code updated

* [ACS-5551] remove extra space

* fixed scrollbar issue

* [ACS-5551] margin adjusted

* Fixed  ACS-6110

* [ACS-5551] design updated

* [ACCS-5551] unit test added

* [ACS-5551] margin issue fixed

* scroll issue fixed

* [ACS-5551] color updated

* [ACS-5551] design modify

* [ACS-5551] add missing methods

* [ACS-5654] translation added

* [ACS-5645] style updated

* [ACS-5654] hide toggle button for aspects

* [ACS-5645] theme updated

* [ACS-5645] tags and category tyle update

* [ACS-5645] unit test update

* [ACS-5645] code updated as per comments

* [ACS-5645] linting issue fix

* [ACS-5645] fixed the failed unit test cases

* [ACS-5645] e2e fixes

* [ACS-5645] e2e modify

* [ACS-5645] aspect issue resolved

* [ACS-5645] Address the comments

* [ACS-5645] Address the comments

* [ACS-5645] tags list design modify

* [ACS-5645] design modify for chips

* [ACS-5645] Removed unused property

* [ACS-5645] Stop reload on panel cancel changes

* [ACS-5645] Linting issue fixed

* revert file change

* [ACS-5645] update aspect issue fix

* Revert "[ACS-5645] update aspect issue fix"

This reverts commit 5212112f2293ad4c29afdd7c7faaf897cd3d00f6.

* reduce layout duplicates, header panel component

* code improvements

* remove useless logging

* cleanup css, remove mat-divider, fix tests

* remove useless styles

* cleanup e2e

* cleanup useless events

* rename nodeIcon to just icon

* disable transition animation for tabs

* remove "editable" hacks

* improved naming for state properties

* bug fixes for process cloud

* css stylelint fixes

* rework component, cleanup useless code

* fix allowable operations and readonly state

* wait for button

* cleanup css, disable e2e

* remove demo-shell only content, fix metadata

* restore reset date functionality

* fix incorrect styling

* fix clear date button styles

* cleanup text item styles

* remove useless classes

* text item rework, code cleanup

* style bug fixes

* cleanup useless tests

* fix styles and tests

* bug fixes for select item styles, revert PR changes

* rework categories styles

* rework tags creator styles

* rollback divider module

* fix css variable naming

* fix issue with hidden properties

* fix key value pairs layout and styles

* fix tag creator validation

* remove incorrect styles, raise proper errors

* fix unit tests

* fix theme vars naming

* remove css hacks for date items

* fix error borders

* fix css bugs

* reduce code

* cleanup e2e and en.json

* fix css linting

* cleanup unused template refs

* remove useless div for metadata container

* cleanup expanders api

* cleanup and remove useless tests

* cleanup i18n

* cleanup tests

* cleanup css

* cleanup css

* [ACS-5654] added the missing theme variables

* review comments resolved

* fixed  css issue

* [ACS-5654] removesd extra div

* [ACS-5654] save and cancel button bug fix

* [ACS-5654] unit test fix for expand the panel

* [ACS-5645] design issues fix

* [ACS-5654] cards design fixed

* [ACS-5654] node icon added to thumbnail service

* [ACS-5645] linting issue fixed

* [ACS-5645] thumbnail unit test updated

* [ACS-5645] linting updated

* [ACS-5645] removed extra div

* [ACS-5645] important removed

* [ACS-5645] tags text issue fix

* [ACS-5645] add missed class

* [ACS-5645] removed unused classes

* [ACS-5645]  removed unused code

* revert flags to original state

* fix missing semicolon

* fix linting issues

* reduce code duplication

* code cleanup

* [ACS-5645] unit test fix

* [ACS-5645] e2e fix for edit button

* fix linting issue for e2e

* Replaced getNodeIcon from thumbnail to content service

* fix indentation

* refactor css variable

* use rgba color value

---------

Co-authored-by: Yasa-Nataliya <yasa.nataliya@globallogic.com>
Co-authored-by: pkundu <priyanka.kundu@hyland.com>
Co-authored-by: rbahirsheth <raviraj.bahirsheth@globallogic.com>
Co-authored-by: Denys Vuika <denys.vuika@gmail.com>
2023-12-21 16:37:13 +05:30

272 lines
11 KiB
TypeScript

/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $, by, element, Key, protractor, ElementFinder } from 'protractor';
import { BrowserActions, BrowserVisibility, DropdownPage, TestElement, Logger } from '@alfresco/adf-testing';
export class MetadataViewPage {
title = $(`div[info-drawer-title]`);
expandedAspect = $(`mat-expansion-panel-header[aria-expanded='true']`);
aspectTitle = `mat-panel-title`;
name = $(`[data-automation-id='card-textitem-value-properties.cm:name']`);
creator = $(`[data-automation-id='card-textitem-value-createdByUser.displayName']`);
createdDate = $(`span[data-automation-id='card-dateitem-createdAt']`);
modifier = $(`[data-automation-id='card-textitem-value-modifiedByUser.displayName']`);
modifiedDate = $(`span[data-automation-id='card-dateitem-modifiedAt']`);
mimetypeName = $(`[data-automation-id='card-textitem-value-content.mimeTypeName']`);
size = $(`[data-automation-id='card-textitem-value-content.sizeInBytes']`);
description = $(`span[data-automation-id='card-textitem-value-properties.cm:description']`);
author = $(`[data-automation-id='card-textitem-value-properties.cm:author']`);
editIcon = $(`button[data-automation-id='meta-data-card-toggle-edit']`);
editIconGeneral = $(`button[data-automation-id='meta-data-general-info-edit']`);
displayEmptySwitch = $(`#adf-metadata-empty`);
readonlySwitch = $(`#adf-metadata-readonly`);
multiSwitch = $(`#adf-metadata-multi`);
defaultPropertiesSwitch = $('#adf-metadata-default-properties');
closeButton = element(by.cssContainingText('button.mat-button span', 'Close'));
displayAspect = $(`input[data-placeholder='Display Aspect']`);
applyAspect = element(by.cssContainingText(`button span.mat-button-wrapper`, 'Apply Aspect'));
saveMetadataButton = $(`[data-automation-id='save-metadata']`);
saveGeneralMetadataButton = $(`[data-automation-id='save-general-info-metadata']`);
resetMetadataButton = $(`[data-automation-id='reset-metadata']`);
private getMetadataGroupLocator = async (groupName: string): Promise<ElementFinder> =>
$(`[data-automation-id="adf-metadata-group-${groupName}"]`);
private getExpandedMetadataGroupLocator = async (groupName: string): Promise<ElementFinder> =>
$(`[data-automation-id="adf-metadata-group-${groupName}"] > mat-expansion-panel-header`);
async getTitle(): Promise<string> {
return BrowserActions.getText(this.title);
}
async getExpandedAspectName(): Promise<string> {
return BrowserActions.getText(this.expandedAspect.$(this.aspectTitle));
}
async getName(): Promise<string> {
return BrowserActions.getInputValue(this.name);
}
async getCreator(): Promise<string> {
return BrowserActions.getInputValue(this.creator);
}
async getCreatedDate(): Promise<string> {
return BrowserActions.getText(this.createdDate);
}
async getModifier(): Promise<string> {
return BrowserActions.getInputValue(this.modifier);
}
async getModifiedDate(): Promise<string> {
return BrowserActions.getText(this.modifiedDate);
}
async getMimetypeName(): Promise<string> {
return BrowserActions.getInputValue(this.mimetypeName);
}
async getSize(): Promise<string> {
return BrowserActions.getInputValue(this.size);
}
async getDescription(): Promise<string> {
return BrowserActions.getInputValue(this.description);
}
async getAuthor(): Promise<string> {
return BrowserActions.getInputValue(this.author);
}
async editIconIsDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.editIcon);
}
async editIconIsNotDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsNotVisible(this.editIcon);
}
async isEditGeneralIconDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.editIconGeneral);
}
async editIconClick(): Promise<void> {
await BrowserActions.clickExecuteScript('button[data-automation-id="meta-data-card-toggle-edit"]');
}
async clickEditIconGeneral(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.editIconGeneral);
await BrowserActions.click(this.editIconGeneral);
}
async clickOnPropertiesTab(): Promise<void> {
const propertiesTab = element(
by.cssContainingText(`.adf-info-drawer-layout-content div.mat-tab-labels div .mat-tab-label-content`, `Properties`)
);
await BrowserActions.click(propertiesTab);
}
async getEditIconTooltip(): Promise<string> {
return BrowserActions.getAttribute(this.editIcon, 'title');
}
async enterPropertyText(propertyName: string, text: string | number): Promise<void> {
const textField = $('input[data-automation-id="card-textitem-value-' + propertyName + '"]');
await BrowserActions.clearSendKeys(textField, text.toString());
await textField.sendKeys(protractor.Key.ENTER);
}
async enterDescriptionText(text: string): Promise<void> {
const textField = $('textarea[data-automation-id="card-textitem-value-properties.cm:description"]');
await BrowserActions.clearSendKeys(textField, text);
await textField.sendKeys(Key.TAB);
}
async getPropertyText(propertyName: string, type?: string): Promise<string> {
const propertyType = type || 'textitem';
const textField = $('[data-automation-id="card-' + propertyType + '-value-' + propertyName + '"]');
return BrowserActions.getInputValue(textField);
}
async clickMetadataGroup(groupName: string): Promise<void> {
const group = await this.getMetadataGroupLocator(groupName);
await BrowserActions.click(group);
}
async checkMetadataGroupIsPresent(groupName: string): Promise<void> {
const group = await this.getMetadataGroupLocator(groupName);
await BrowserVisibility.waitUntilElementIsVisible(group);
}
async checkMetadataGroupIsNotPresent(groupName: string): Promise<void> {
const group = await this.getMetadataGroupLocator(groupName);
await BrowserVisibility.waitUntilElementIsNotVisible(group);
}
async checkMetadataGroupIsExpand(groupName: string): Promise<void> {
const group = await this.getExpandedMetadataGroupLocator(groupName);
await expect(await BrowserActions.getAttribute(group, 'class')).toContain('mat-expanded');
}
async checkMetadataGroupIsNotExpand(groupName: string): Promise<void> {
const group = await this.getExpandedMetadataGroupLocator(groupName);
await expect(await BrowserActions.getAttribute(group, 'class')).not.toContain('mat-expanded');
}
async checkPropertyIsVisible(propertyName: string, type: string): Promise<void> {
const property = $('[data-automation-id="card-' + type + '-label-' + propertyName + '"]');
await BrowserVisibility.waitUntilElementIsVisible(property);
}
async hasContentType(contentType: string, attempt = 0, maxAttempt = 3): Promise<boolean> {
const contentTypeSelector = '[data-automation-id="select-readonly-value-nodeType"]';
const type = TestElement.byText(contentTypeSelector, contentType);
try {
if (attempt > maxAttempt) {
return false;
}
await type.waitVisible();
const isPresent = await type.isPresent();
if (isPresent) {
return true;
}
return this.hasContentType(contentType, attempt + 1, maxAttempt);
} catch (e) {
Logger.log(`re trying content type attempt :: ${attempt}`);
return this.hasContentType(contentType, attempt + 1, maxAttempt);
}
}
async checkPropertyDisplayed(propertyName: string, type?: string, attempt = 0, maxAttempt = 3): Promise<string> {
try {
if (attempt > maxAttempt) {
return '';
}
const propertyType = type || 'textitem';
await TestElement.byCss('[data-automation-id="card-' + propertyType + '-value-' + propertyName + '"]').waitVisible();
return this.getPropertyText(propertyName);
} catch (e) {
Logger.log(`re trying custom property attempt :: ${attempt}`);
return this.checkPropertyDisplayed(propertyName, type, attempt + 1, maxAttempt);
}
}
async changeContentType(option: string, attempt = 0, maxAttempt = 3): Promise<boolean> {
const nodeType = TestElement.byCss('div[data-automation-id="header-nodeType"] .mat-select-trigger');
if (attempt > maxAttempt) {
Logger.error(`content type select option not found. check acs version may be lesser than 7.0.0`);
return false;
}
try {
await nodeType.waitVisible();
if (await nodeType.isPresent()) {
await nodeType.click();
const typesDropDownPage = new DropdownPage(nodeType.elementFinder);
await typesDropDownPage.checkOptionIsDisplayed(option);
await typesDropDownPage.selectOption(option);
return true;
}
return this.changeContentType(option, attempt + 1, maxAttempt);
} catch (error) {
Logger.log(`re trying content type options attempt :: ${attempt}`);
await BrowserActions.closeMenuAndDialogs();
return this.changeContentType(option, attempt + 1, maxAttempt);
}
}
async checkConfirmDialogDisplayed(): Promise<void> {
const confirmButton = TestElement.byCss('adf-content-type-dialog');
await confirmButton.waitPresent();
}
async applyNodeProperties(): Promise<void> {
const confirmButton = TestElement.byId('content-type-dialog-apply-button');
await confirmButton.click();
}
async cancelNodeProperties(): Promise<void> {
const cancelButton = TestElement.byId('content-type-dialog-actions-cancel');
await cancelButton.click();
}
async checkPropertyIsNotVisible(propertyName: string, type: string): Promise<void> {
await TestElement.byCss('div[data-automation-id="card-' + type + '-label-' + propertyName + '"]').waitNotVisible();
}
async typeAspectName(aspectName): Promise<void> {
await BrowserActions.clearSendKeys(this.displayAspect, aspectName);
}
async clickApplyAspect(): Promise<void> {
await BrowserActions.click(this.applyAspect);
}
async clickSaveMetadata(): Promise<void> {
await BrowserActions.click(this.saveMetadataButton);
}
async clickResetMetadata(): Promise<void> {
await BrowserActions.click(this.resetMetadataButton);
}
async clickSaveGeneralMetadata(): Promise<void> {
await BrowserActions.click(this.saveGeneralMetadataButton);
}
}