mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-4900] Card View and Metadata Components refactoring (#5592)
* [ADF-4900] Card View and Metadata Components refactoring * CSS linting * Unit test excluded * Rebase branch * Fix unit tests * Fix linting * Fix e2e tests * Fix 2e2 tests * Fix process-services e2e tests * More fixes * Fix more e2e tests * Fix unit test * Improve flaky unit test * Fix process services e2e tests * Update Process Header Cloud Page * Fix linting * Fix timing issue * Lintintg * Fix selectors * Fix e2e tests * Fix timing issue * Fix C260328 * Fix spellcheck * save screenshot * performance issue * Fix unit tests and e2e tests * fix e2e * refactoring * fix lint * fix e2e * Fix C309698 * fix other e2e * fix lint * increase timeout Co-authored-by: Eugenio Romano <eugenio.romano@alfresco.com>
This commit is contained in:
@@ -15,20 +15,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { element, by, ElementFinder, Locator } from 'protractor';
|
||||
import { element, by, ElementFinder, Locator, Key } from 'protractor';
|
||||
import { BrowserActions, BrowserVisibility } from '../../utils/public-api';
|
||||
export class CardTextItemPage {
|
||||
|
||||
rootElement: ElementFinder;
|
||||
textField: Locator = by.css('input[data-automation-id*="card-textitem-editinput"]');
|
||||
textField: Locator = by.css('[data-automation-id*="card-textitem-value"]');
|
||||
saveButton: Locator = by.css('button[data-automation-id*="card-textitem-update"]');
|
||||
clearButton: Locator = by.css('button[data-automation-id*="card-textitem-reset"]');
|
||||
field: Locator = by.css('span[data-automation-id*="card-textitem-value"] span');
|
||||
field: Locator = by.css('[data-automation-id*="card-textitem-value"]');
|
||||
labelLocator: Locator = by.css('div[data-automation-id*="card-textitem-label"]');
|
||||
toggle: Locator = by.css('div[data-automation-id*="card-textitem-toggle"]');
|
||||
editButton: Locator = by.css('button.adf-textitem-action[title*=Edit]');
|
||||
errorMessage: Locator = by.css('.adf-textitem-editable-error');
|
||||
clickableElement: Locator = by.css('.adf-textitem-clickable');
|
||||
readOnlyField: Locator = by.css('.adf-property-read-only');
|
||||
|
||||
constructor(label: string = 'assignee') {
|
||||
this.rootElement = element(by.xpath(`//div[contains(@data-automation-id, "label-${label}")]/ancestor::adf-card-view-textitem`));
|
||||
@@ -36,7 +35,7 @@ export class CardTextItemPage {
|
||||
|
||||
async getFieldValue(): Promise<string> {
|
||||
const fieldElement = this.rootElement.all(this.field).first();
|
||||
return BrowserActions.getText(fieldElement);
|
||||
return BrowserActions.getInputValue(fieldElement);
|
||||
}
|
||||
|
||||
async checkLabelIsPresent(): Promise<void> {
|
||||
@@ -44,14 +43,10 @@ export class CardTextItemPage {
|
||||
await BrowserVisibility.waitUntilElementIsPresent(labelElement);
|
||||
}
|
||||
|
||||
async clickOnToggleTextField(): Promise<void> {
|
||||
const toggleText: ElementFinder = this.rootElement.element(this.toggle);
|
||||
await BrowserActions.click(toggleText);
|
||||
}
|
||||
|
||||
async enterTextField(text: string): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.rootElement.element(this.textField));
|
||||
await BrowserActions.clearSendKeys(this.rootElement.element(this.textField), text);
|
||||
await this.rootElement.element(this.textField).sendKeys(Key.TAB);
|
||||
}
|
||||
|
||||
async clickOnSaveButton(): Promise<void> {
|
||||
@@ -62,17 +57,12 @@ export class CardTextItemPage {
|
||||
await BrowserActions.click(this.rootElement.element(this.clearButton));
|
||||
}
|
||||
|
||||
async clickOnEditButton(): Promise<void> {
|
||||
await BrowserActions.click(this.rootElement.element(this.editButton));
|
||||
}
|
||||
|
||||
async getErrorMessage(): Promise<string> {
|
||||
const errorField = this.rootElement.element(this.errorMessage);
|
||||
return BrowserActions.getText(errorField);
|
||||
}
|
||||
|
||||
async checkElementIsReadonly(): Promise <void> {
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(this.rootElement.element(this.clickableElement));
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(this.rootElement.element(this.editButton));
|
||||
async checkElementIsReadonly(): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.rootElement.element(this.readOnlyField));
|
||||
}
|
||||
}
|
||||
|
@@ -65,6 +65,15 @@ export class BrowserActions {
|
||||
}
|
||||
}
|
||||
|
||||
static async getInputValue(elementFinder: ElementFinder): Promise<string> {
|
||||
const present = await BrowserVisibility.waitUntilElementIsPresent(elementFinder);
|
||||
if (present) {
|
||||
return elementFinder.getAttribute('value');
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
static async getArrayText(elementFinders: ElementArrayFinder): Promise<string> {
|
||||
return elementFinders.getText();
|
||||
}
|
||||
@@ -75,12 +84,13 @@ export class BrowserActions {
|
||||
return webElem.getCssValue('color');
|
||||
}
|
||||
|
||||
static async clearWithBackSpace(elementFinder: ElementFinder) {
|
||||
static async clearWithBackSpace(elementFinder: ElementFinder, sleepTime: number = 0) {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(elementFinder);
|
||||
await elementFinder.click();
|
||||
const value = await elementFinder.getAttribute('value');
|
||||
for (let i = value.length; i >= 0; i--) {
|
||||
await elementFinder.sendKeys(protractor.Key.BACK_SPACE);
|
||||
await browser.sleep(sleepTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -183,7 +183,7 @@ export class EditTaskFilterCloudComponentPage {
|
||||
}
|
||||
|
||||
async clearAssignee(): Promise<void> {
|
||||
await BrowserActions.clearWithBackSpace(this.assignee);
|
||||
await BrowserActions.clearWithBackSpace(this.assignee, 200);
|
||||
await browser.driver.sleep(1000);
|
||||
}
|
||||
|
||||
|
@@ -20,29 +20,29 @@ import { BrowserActions } from '../../core/utils/browser-actions';
|
||||
|
||||
export class ProcessHeaderCloudPage {
|
||||
|
||||
idField: ElementFinder = element.all(by.css('span[data-automation-id*="id"] span span')).first();
|
||||
nameField: ElementFinder = element.all(by.css('span[data-automation-id*="name"] span span')).first();
|
||||
statusField: ElementFinder = element(by.css('span[data-automation-id*="status"] span span'));
|
||||
initiatorField: ElementFinder = element(by.css('span[data-automation-id*="initiator"] span span'));
|
||||
startDateField: ElementFinder = element.all(by.css('span[data-automation-id*="startDate"] span span')).first();
|
||||
lastModifiedField: ElementFinder = element.all(by.css('span[data-automation-id*="lastModified"] span span')).first();
|
||||
parentIdField: ElementFinder = element(by.css('span[data-automation-id*="parentId"] span span'));
|
||||
businessKeyField: ElementFinder = element.all(by.css('span[data-automation-id*="businessKey"] span span')).first();
|
||||
idField: ElementFinder = element.all(by.css('[data-automation-id="card-textitem-value-id"]')).first();
|
||||
nameField: ElementFinder = element.all(by.css('[data-automation-id="card-textitem-value-name"]')).first();
|
||||
statusField: ElementFinder = element(by.css('[data-automation-id="card-textitem-value-status"]'));
|
||||
initiatorField: ElementFinder = element(by.css('[data-automation-id="card-textitem-value-initiator"]'));
|
||||
startDateField: ElementFinder = element.all(by.css('span[data-automation-id*="startDate"] span')).first();
|
||||
lastModifiedField: ElementFinder = element.all(by.css('span[data-automation-id*="lastModified"] span')).first();
|
||||
parentIdField: ElementFinder = element(by.css('[data-automation-id="card-textitem-value-parentId"]'));
|
||||
businessKeyField: ElementFinder = element(by.css('[data-automation-id="card-textitem-value-businessKey"]'));
|
||||
|
||||
async getId(): Promise<string> {
|
||||
return BrowserActions.getText(this.idField);
|
||||
return BrowserActions.getInputValue(this.idField);
|
||||
}
|
||||
|
||||
async getName(): Promise<string> {
|
||||
return BrowserActions.getText(this.nameField);
|
||||
return BrowserActions.getInputValue(this.nameField);
|
||||
}
|
||||
|
||||
async getStatus(): Promise<string> {
|
||||
return BrowserActions.getText(this.statusField);
|
||||
return BrowserActions.getInputValue(this.statusField);
|
||||
}
|
||||
|
||||
async getInitiator(): Promise<string> {
|
||||
return BrowserActions.getText(this.initiatorField);
|
||||
return BrowserActions.getInputValue(this.initiatorField);
|
||||
}
|
||||
|
||||
async getStartDate(): Promise<string> {
|
||||
@@ -54,11 +54,11 @@ export class ProcessHeaderCloudPage {
|
||||
}
|
||||
|
||||
async getParentId(): Promise<string> {
|
||||
return BrowserActions.getText(this.parentIdField);
|
||||
return BrowserActions.getInputValue(this.parentIdField);
|
||||
}
|
||||
|
||||
async getBusinessKey(): Promise<string> {
|
||||
return BrowserActions.getText(this.businessKeyField);
|
||||
return BrowserActions.getInputValue(this.businessKeyField);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -79,10 +79,6 @@ export class StartTasksCloudPage {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(errorElement);
|
||||
}
|
||||
|
||||
async validateAssignee(error: string): Promise<void> {
|
||||
await this.checkValidationErrorIsDisplayed(error, '.adf-start-task-cloud-error');
|
||||
}
|
||||
|
||||
async validateDate(error: string): Promise<void> {
|
||||
await this.checkValidationErrorIsDisplayed(error, '.adf-error-text');
|
||||
}
|
||||
|
@@ -15,63 +15,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { by, element, ElementFinder, Locator } from 'protractor';
|
||||
import { browser, by, element, ElementFinder } from 'protractor';
|
||||
import { BrowserVisibility } from '../../core/utils/browser-visibility';
|
||||
import { BrowserActions } from '../../core/utils/browser-actions';
|
||||
|
||||
export class TaskFiltersCloudComponentPage {
|
||||
|
||||
filter: ElementFinder;
|
||||
taskIcon: Locator = by.xpath("ancestor::div[@class='mat-list-item-content']/mat-icon");
|
||||
taskFilters: ElementFinder = element(by.css(`mat-expansion-panel[data-automation-id='Task Filters']`));
|
||||
|
||||
activeFilter: ElementFinder = element(by.css("mat-list-item[class*='active'] span"));
|
||||
defaultActiveFilter: ElementFinder = element.all(by.css('.adf-filters__entry')).first();
|
||||
|
||||
async checkTaskFilterIsDisplayed(filterName: string): Promise<void> {
|
||||
this.filter = this.getTaskFilterLocatorByFilterName(filterName);
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.filter);
|
||||
}
|
||||
|
||||
async getTaskFilterIcon(filterName: string): Promise<string> {
|
||||
this.filter = this.getTaskFilterLocatorByFilterName(filterName);
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.filter);
|
||||
const icon = this.filter.element(this.taskIcon);
|
||||
return BrowserActions.getText(icon);
|
||||
}
|
||||
|
||||
async checkTaskFilterHasNoIcon(filterName: string): Promise<void> {
|
||||
this.filter = this.getTaskFilterLocatorByFilterName(filterName);
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.filter);
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.taskIcon));
|
||||
}
|
||||
|
||||
async clickTaskFilter(filterName): Promise<void> {
|
||||
this.filter = this.getTaskFilterLocatorByFilterName(filterName);
|
||||
await BrowserVisibility.waitUntilElementIsClickable(this.filter);
|
||||
await BrowserActions.click(this.filter);
|
||||
}
|
||||
|
||||
async clickMyTasksFilter(): Promise<void> {
|
||||
this.filter = this.getTaskFilterLocatorByFilterName('my-tasks');
|
||||
await BrowserVisibility.waitUntilElementIsClickable(this.filter);
|
||||
await BrowserActions.click(this.filter);
|
||||
}
|
||||
|
||||
async clickCompletedTasksFilter(): Promise<void> {
|
||||
this.filter = this.getTaskFilterLocatorByFilterName('completed-tasks');
|
||||
await BrowserVisibility.waitUntilElementIsClickable(this.filter);
|
||||
await BrowserActions.click(this.filter);
|
||||
}
|
||||
|
||||
async checkMyTasksFilterIsDisplayed(): Promise<void> {
|
||||
this.filter = this.getTaskFilterLocatorByFilterName('my-tasks');
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.filter);
|
||||
}
|
||||
|
||||
async checkCompletedTasksFilterIsDisplayed(): Promise<void> {
|
||||
this.filter = this.getTaskFilterLocatorByFilterName('completed-tasks');
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.filter);
|
||||
await browser.sleep(1000);
|
||||
}
|
||||
|
||||
async checkTaskFilterNotDisplayed(filterName: string): Promise<void> {
|
||||
@@ -87,11 +50,6 @@ export class TaskFiltersCloudComponentPage {
|
||||
return BrowserActions.getText(this.activeFilter);
|
||||
}
|
||||
|
||||
async firstFilterIsActive(): Promise<boolean> {
|
||||
const value = await this.defaultActiveFilter.getAttribute('class');
|
||||
return value.includes('adf-active');
|
||||
}
|
||||
|
||||
getTaskFilterLocatorByFilterName(filterName: string): ElementFinder {
|
||||
return element(by.css(`span[data-automation-id="${filterName}-filter"]`));
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { element, by, ElementFinder } from 'protractor';
|
||||
import { element, by, ElementFinder, browser } from 'protractor';
|
||||
import { BrowserVisibility } from '../../core/utils/browser-visibility';
|
||||
import { BrowserActions } from '../../core/utils/browser-actions';
|
||||
import { FormFields } from '../../core/pages/form/form-fields';
|
||||
@@ -77,6 +77,7 @@ export class TaskFormCloudComponent {
|
||||
|
||||
async clickCompleteButton(): Promise<void> {
|
||||
await BrowserActions.click(this.completeButton);
|
||||
await browser.sleep(500);
|
||||
}
|
||||
|
||||
async checkFormOutcomeButtonIsDisplayedByName(name: string): Promise<void> {
|
||||
|
@@ -26,10 +26,10 @@ export class TaskHeaderCloudPage {
|
||||
statusCardTextItem: CardTextItemPage = new CardTextItemPage('status');
|
||||
priorityCardTextItem: CardTextItemPage = new CardTextItemPage('priority');
|
||||
dueDateField: ElementFinder = element.all(by.css('span[data-automation-id*="dueDate"] span')).first();
|
||||
categoryField: ElementFinder = element.all(by.css('span[data-automation-id*="category"] span')).first();
|
||||
categoryCardTextItem: CardTextItemPage = new CardTextItemPage('category');
|
||||
createdField: ElementFinder = element(by.css('span[data-automation-id="card-dateitem-created"] span'));
|
||||
parentNameField: ElementFinder = element(by.css('span[data-automation-id*="parentName"] span'));
|
||||
parentTaskIdField: ElementFinder = element(by.css('span[data-automation-id*="parentTaskId"] span'));
|
||||
parentNameCardTextItem: CardTextItemPage = new CardTextItemPage('parentName');
|
||||
parentTaskIdCardTextItem: CardTextItemPage = new CardTextItemPage('parentTaskId');
|
||||
endDateField: ElementFinder = element.all(by.css('span[data-automation-id*="endDate"] span')).first();
|
||||
idCardTextItem: CardTextItemPage = new CardTextItemPage('id');
|
||||
descriptionCardTextItem: CardTextItemPage = new CardTextItemPage('description');
|
||||
@@ -39,10 +39,6 @@ export class TaskHeaderCloudPage {
|
||||
return this.assigneeCardTextItem.getFieldValue();
|
||||
}
|
||||
|
||||
async clickOnAssignee(): Promise<void> {
|
||||
await this.assigneeCardTextItem.clickOnToggleTextField();
|
||||
}
|
||||
|
||||
async getStatus(): Promise<string> {
|
||||
return this.statusCardTextItem.getFieldValue();
|
||||
}
|
||||
@@ -52,15 +48,15 @@ export class TaskHeaderCloudPage {
|
||||
}
|
||||
|
||||
async getCategory(): Promise<string> {
|
||||
return BrowserActions.getText(this.categoryField);
|
||||
return this.categoryCardTextItem.getFieldValue();
|
||||
}
|
||||
|
||||
async getParentName(): Promise<string> {
|
||||
return BrowserActions.getText(this.parentNameField);
|
||||
return this.parentNameCardTextItem.getFieldValue();
|
||||
}
|
||||
|
||||
async getParentTaskId(): Promise<string> {
|
||||
return BrowserActions.getText(this.parentTaskIdField);
|
||||
return this.parentTaskIdCardTextItem.getFieldValue();
|
||||
}
|
||||
|
||||
async getEndDate(): Promise<string> {
|
||||
|
Reference in New Issue
Block a user