From ad70837b3d46d31b614a56748cd90259ab5b6026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iulia=20Burc=C4=83?= Date: Wed, 10 Feb 2021 18:47:54 +0200 Subject: [PATCH] [ADF-5313] Merge both form-fields POs in one because are identical (#6543) * Merge form-fields similar classes * change methods where getWidget is used * revert changes from checkWidgetIsHidden method * Remove wrong async --- .../src/lib/core/pages/form/form-fields.ts | 3 +- .../pages/form-fields.page.ts | 232 ------------------ .../lib/process-services/pages/public-api.ts | 1 - 3 files changed, 1 insertion(+), 235 deletions(-) delete mode 100644 lib/testing/src/lib/process-services/pages/form-fields.page.ts diff --git a/lib/testing/src/lib/core/pages/form/form-fields.ts b/lib/testing/src/lib/core/pages/form/form-fields.ts index 67c91f334e..4188cc944a 100644 --- a/lib/testing/src/lib/core/pages/form/form-fields.ts +++ b/lib/testing/src/lib/core/pages/form/form-fields.ts @@ -76,8 +76,7 @@ export class FormFields { } async getFieldErrorMessage(fieldId: string): Promise { - const error = await this.getWidget(fieldId); - error.element(this.errorMessage); + const error = await this.getWidget(fieldId).element(this.errorMessage); return BrowserActions.getText(error); } diff --git a/lib/testing/src/lib/process-services/pages/form-fields.page.ts b/lib/testing/src/lib/process-services/pages/form-fields.page.ts deleted file mode 100644 index 5fa2e5d84c..0000000000 --- a/lib/testing/src/lib/process-services/pages/form-fields.page.ts +++ /dev/null @@ -1,232 +0,0 @@ -/*! - * @license - * Copyright 2019 Alfresco Software, Ltd. - * - * 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 { BrowserVisibility } from '../../core/utils/browser-visibility'; -import { by, element, ElementFinder, Locator } from 'protractor'; -import { BrowserActions } from '../../core/utils/browser-actions'; -import { By } from 'selenium-webdriver'; -import { DropdownPage } from '../../core/pages/material/dropdown.page'; - -export class FormFieldsPage { - - formContent = element(by.css('adf-form')); - refreshButton = element(by.css('div[class*="form-reload-button"] mat-icon')); - saveButton = element(by.cssContainingText('mat-card-actions[class*="adf-for"] span', 'SAVE')); - valueLocator: Locator = by.css('input'); - labelLocator: Locator = by.css('label'); - noFormMessage = element(by.css('.adf-empty-content__title')); - completedTaskNoFormMessage = element(by.css('div[id*="completed-form-message"] p')); - attachFormButton = element(by.id('adf-attach-form-attach-button')); - completeButton = element(by.id('adf-form-complete')); - claimButton = element(by.id('adf-task-form-claim-button')); - releaseButton = element(by.id('adf-task-form-unclaim-button')); - cancelButton = element(by.id('adf-no-form-cancel-button')); - errorMessage: Locator = by.css('.adf-error-text-container .adf-error-text'); - - selectFormDropdown = new DropdownPage(element.all(by.css('.adf-attach-form .mat-select-arrow')).first()); - - async setFieldValue(locator: (id: string) => By, field: string, value: string): Promise { - const fieldElement = element(locator(field)); - await BrowserVisibility.waitUntilElementIsVisible(fieldElement); - await BrowserActions.clearSendKeys(fieldElement, value); - } - - async checkWidgetIsVisible(fieldId: string): Promise { - const fieldElement = element.all(by.css(`adf-form-field div[id='field-${fieldId}-container']`)).first(); - await BrowserVisibility.waitUntilElementIsVisible(fieldElement); - } - - async checkWidgetIsHidden(fieldId: string): Promise { - const hiddenElement = element(by.css(`adf-form-field div[id='field-${fieldId}-container'][hidden]`)); - await BrowserVisibility.waitUntilElementIsVisible(hiddenElement); - } - - async getWidget(fieldId: string): Promise { - const widget = element(by.css(`adf-form-field div[id='field-${fieldId}-container']`)); - await BrowserVisibility.waitUntilElementIsVisible(widget); - return widget; - } - - async getFieldValue(fieldId: string, valueLocatorParam: Locator): Promise { - const widget = await this.getWidget(fieldId); - const value = widget.element(valueLocatorParam || this.valueLocator); - await BrowserVisibility.waitUntilElementIsVisible(value); - return value.getAttribute('value'); - } - - async getFieldLabel(fieldId: string, labelLocatorParam: Locator): Promise { - const widget = await this.getWidget(fieldId); - const label = widget.all(labelLocatorParam || this.labelLocator).first(); - return BrowserActions.getText(label); - } - - async getFieldErrorMessage(fieldId: string): Promise { - const widget = await this.getWidget(fieldId); - const error = widget.element(this.errorMessage); - return BrowserActions.getText(error); - } - - async getFieldText(fieldId: string, labelLocatorParam: Locator): Promise { - const widget = await this.getWidget(fieldId); - const label = widget.element(labelLocatorParam || this.labelLocator); - return BrowserActions.getText(label); - } - - async getFieldPlaceHolder(fieldId: string, locator = 'input'): Promise { - const placeHolderLocator = element(by.css(`${locator}#${fieldId}`)); - await BrowserVisibility.waitUntilElementIsVisible(placeHolderLocator); - return placeHolderLocator.getAttribute('data-placeholder'); - } - - async checkFieldValue(locator, field, val): Promise { - await BrowserVisibility.waitUntilElementHasValue(element(locator(field)), val); - } - - async refreshForm(): Promise { - await BrowserActions.click(this.refreshButton); - } - - async saveForm(): Promise { - await BrowserActions.click(this.saveButton); - } - - async noFormIsDisplayed(): Promise { - await BrowserVisibility.waitUntilElementIsNotVisible(this.formContent); - } - - async checkFormIsDisplayed(): Promise { - await BrowserVisibility.waitUntilElementIsVisible(this.formContent); - } - - async getNoFormMessage(): Promise { - return BrowserActions.getText(this.noFormMessage); - } - - async getCompletedTaskNoFormMessage(): Promise { - return BrowserActions.getText(this.completedTaskNoFormMessage); - } - - async clickOnAttachFormButton(): Promise { - await BrowserActions.click(this.attachFormButton); - } - - async clickOnClaimButton(): Promise { - await BrowserActions.click(this.claimButton); - } - - async clickOnReleaseButton(): Promise { - await BrowserActions.click(this.releaseButton); - } - - async selectForm(formName: string): Promise { - await this.selectFormDropdown.clickDropdown(); - await this.selectFormDropdown.checkOptionsPanelIsDisplayed(); - await this.selectFormDropdown.selectOption(formName); - } - - async selectFormFromDropDown(formName: string): Promise { - const formNameElement = element(by.cssContainingText('span', formName)); - await BrowserActions.click(formNameElement); - } - - async checkWidgetIsReadOnlyMode(fieldId: string): Promise { - const widget = element(by.css(`adf-form-field div[id='field-${fieldId}-container']`)); - const widgetReadOnly = widget.element(by.css('div[class*="adf-readonly"]')); - await BrowserVisibility.waitUntilElementIsVisible(widgetReadOnly); - } - - async isFormFieldEnabled(formFieldId: string): Promise { - const formField = element(by.css(`input[id=${formFieldId}]`)); - return formField.isEnabled(); - } - - async completeForm(): Promise { - await BrowserActions.click(this.completeButton); - } - - async setValueInInputById(fieldId: string, value: string): Promise { - const input = element(by.id(fieldId)); - await BrowserVisibility.waitUntilElementIsVisible(input); - await BrowserActions.clearSendKeys(input, value); - } - - async isCompleteButtonDisplayed(): Promise { - try { - await BrowserVisibility.waitUntilElementIsVisible(this.completeButton); - return true; - } catch (error) { - return false; - } - } - - async isSaveButtonDisplayed(): Promise { - try { - await BrowserVisibility.waitUntilElementIsVisible(this.saveButton); - return true; - } catch (error) { - return false; - } - } - - async isCancelButtonDisplayed(): Promise { - try { - await BrowserVisibility.waitUntilElementIsVisible(this.cancelButton); - return true; - } catch (error) { - return false; - } - } - - async isClaimButtonDisplayed(): Promise { - try { - await BrowserVisibility.waitUntilElementIsVisible(this.claimButton); - return true; - } catch (error) { - return false; - } - } - - async isReleaseButtonDisplayed(): Promise { - try { - await BrowserVisibility.waitUntilElementIsVisible(this.releaseButton); - return true; - } catch (error) { - return false; - } - } - - async isCompleteFormButtonEnabled(): Promise { - return this.completeButton.isEnabled(); - } - - async isCancelButtonEnabled(): Promise { - return this.cancelButton.isEnabled(); - } - - async isSaveButtonEnabled(): Promise { - return this.saveButton.isEnabled(); - } - - async isClaimButtonEnabled(): Promise { - return this.claimButton.isEnabled(); - } - - async isReleaseButtonEnabled(): Promise { - return this.releaseButton.isEnabled(); - } - -} diff --git a/lib/testing/src/lib/process-services/pages/public-api.ts b/lib/testing/src/lib/process-services/pages/public-api.ts index fbca291e62..b15bd88c79 100644 --- a/lib/testing/src/lib/process-services/pages/public-api.ts +++ b/lib/testing/src/lib/process-services/pages/public-api.ts @@ -15,7 +15,6 @@ * limitations under the License. */ -export * from './form-fields.page'; export * from './filters.page'; export * from './process-filters.page'; export * from './process-list.page';