diff --git a/lib/cli/resources/e2e-Application.zip b/lib/cli/resources/e2e-Application.zip index 0cc2b381cf..af805dee0a 100644 Binary files a/lib/cli/resources/e2e-Application.zip and b/lib/cli/resources/e2e-Application.zip differ 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 5be51e02ca..67c91f334e 100644 --- a/lib/testing/src/lib/core/pages/form/form-fields.ts +++ b/lib/testing/src/lib/core/pages/form/form-fields.ts @@ -34,7 +34,7 @@ export class FormFields { attachFormButton = element(by.id('adf-attach-form-attach-button')); completeButton = element(by.id('adf-form-complete')); completeNoFormButton = element(by.id('adf-no-form-complete-button')); - cancelButton = element(by.css('#adf-no-form-cancel-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()); @@ -172,10 +172,13 @@ export class FormFields { } 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); - return widgetReadOnly; + const widget = element(by.css(`adf-form-field #field-${fieldId}-container .adf-readonly`)); + await BrowserVisibility.waitUntilElementIsVisible(widget); + return widget; + } + + async isFormFieldEnabled(formFieldId: string): Promise { + return element(by.id(`${formFieldId}`)).isEnabled(); } async completeForm(): Promise { @@ -186,6 +189,10 @@ export class FormFields { await BrowserActions.click(this.completeNoFormButton); } + async clickCancelButton(): Promise { + await BrowserActions.click(this.cancelButton); + } + async setValueInInputById(fieldId: string, value: string): Promise { const input = element(by.id(fieldId)); await BrowserActions.clearSendKeys(input, value); @@ -230,7 +237,4 @@ export class FormFields { return this.cancelButton.isEnabled(); } - async clickCancelButton(): Promise { - await BrowserActions.click(this.cancelButton); - } } diff --git a/lib/testing/src/lib/process-services/actions/public-api.ts b/lib/testing/src/lib/process-services/actions/public-api.ts index 27fd5665de..d93a7ad00d 100644 --- a/lib/testing/src/lib/process-services/actions/public-api.ts +++ b/lib/testing/src/lib/process-services/actions/public-api.ts @@ -19,5 +19,6 @@ export * from './applications.util'; export * from './integration.service'; export * from './models.service'; export * from './process.util'; +export * from './task-actions.util'; export * from './task.util'; export * from './user-filters.util'; diff --git a/lib/testing/src/lib/process-services/actions/task-actions.util.ts b/lib/testing/src/lib/process-services/actions/task-actions.util.ts new file mode 100644 index 0000000000..e1dfcf5ab2 --- /dev/null +++ b/lib/testing/src/lib/process-services/actions/task-actions.util.ts @@ -0,0 +1,52 @@ +/*! + * @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 { Logger } from '../../core/utils/logger'; +import { ApiService } from '../../core/actions/api.service'; + +export class TaskActionsUtil { + + api: ApiService; + + constructor(api: ApiService) { + this.api = api; + } + + async claimTask(taskInstance: string): Promise { + try { + return this.api.apiService.activiti.taskActionsApi.claimTask(taskInstance); + } catch (error) { + Logger.error('Claim a Task - Service error, Response: ', JSON.parse(JSON.stringify(error))); + } + } + + async unclaimTask(taskInstance: string): Promise { + try { + return this.api.apiService.activiti.taskActionsApi.unclaimTask(taskInstance); + } catch (error) { + Logger.error('Unclaim a Task - Service error, Response: ', JSON.parse(JSON.stringify(error))); + } + } + + async completeTask(taskInstance: string): Promise { + try { + return this.api.apiService.activiti.taskActionsApi.completeTask(taskInstance); + } catch (error) { + Logger.error('Complete Task - Service error, Response: ', JSON.parse(JSON.stringify(error))); + } + } +} diff --git a/lib/testing/src/lib/process-services/actions/task.util.ts b/lib/testing/src/lib/process-services/actions/task.util.ts index c0a82a310d..b8ff81e407 100644 --- a/lib/testing/src/lib/process-services/actions/task.util.ts +++ b/lib/testing/src/lib/process-services/actions/task.util.ts @@ -35,14 +35,6 @@ export class TaskUtil { } } - async completeTask(taskInstance: string): Promise { - try { - return this.api.apiService.activiti.taskActionsApi.completeTask(taskInstance); - } catch (error) { - Logger.error('Complete Task - Service error, Response: ', JSON.parse(JSON.stringify(error))); - } - } - async completeTaskForm(taskInstance: string): Promise { try { return this.api.getInstance().activiti.taskApi.completeTaskForm(taskInstance, { values: { label: null } }); 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 index 82a1aef8c6..5fa2e5d84c 100644 --- a/lib/testing/src/lib/process-services/pages/form-fields.page.ts +++ b/lib/testing/src/lib/process-services/pages/form-fields.page.ts @@ -32,6 +32,9 @@ export class FormFieldsPage { 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()); @@ -121,6 +124,14 @@ export class FormFieldsPage { 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(); @@ -138,6 +149,11 @@ export class FormFieldsPage { 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); } @@ -157,7 +173,60 @@ export class FormFieldsPage { } } + 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 8ca500bbf1..fbca291e62 100644 --- a/lib/testing/src/lib/process-services/pages/public-api.ts +++ b/lib/testing/src/lib/process-services/pages/public-api.ts @@ -27,3 +27,4 @@ export * from './process-instance-header.page'; export * from './start-process.page'; export * from './select-apps-dialog.page'; export * from './external-node-selector-dialog.page'; +export * from './task-form.page'; diff --git a/lib/testing/src/lib/process-services/pages/task-form.page.ts b/lib/testing/src/lib/process-services/pages/task-form.page.ts new file mode 100644 index 0000000000..9ec9f9890b --- /dev/null +++ b/lib/testing/src/lib/process-services/pages/task-form.page.ts @@ -0,0 +1,100 @@ +/*! + * @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 { element, by } from 'protractor'; +import { BrowserActions, BrowserVisibility } from '../../core/utils/public-api'; + +export class TaskFormPage { + + saveButton = element(by.id('adf-form-save')); + claimButton = element(by.css('button[data-automation-id="adf-task-form-claim-button"]')); + releaseButton = element(by.css('button[data-automation-id="adf-task-form-unclaim-button"]')); + + async clickOnClaimButton(): Promise { + await BrowserActions.click(this.claimButton); + } + + async clickOnReleaseButton(): Promise { + await BrowserActions.click(this.releaseButton); + } + + async isSaveButtonDisplayed(timeout?: number): Promise { + try { + await BrowserVisibility.waitUntilElementIsVisible(this.saveButton, timeout); + return true; + } catch (error) { + return false; + } + } + + async isSaveButtonNotDisplayed(timeout?: number): Promise { + try { + await BrowserVisibility.waitUntilElementIsNotVisible(this.saveButton, timeout); + return true; + } catch (error) { + return false; + } + } + + async isClaimButtonDisplayed(timeout?: number): Promise { + try { + await BrowserVisibility.waitUntilElementIsVisible(this.claimButton, timeout); + return true; + } catch (error) { + return false; + } + } + + async isClaimButtonNotDisplayed(timeout?: number): Promise { + try { + await BrowserVisibility.waitUntilElementIsNotVisible(this.claimButton, timeout); + return true; + } catch (error) { + return false; + } + } + + async isReleaseButtonDisplayed(timeout?: number): Promise { + try { + await BrowserVisibility.waitUntilElementIsVisible(this.releaseButton, timeout); + return true; + } catch (error) { + return false; + } + } + + async isReleaseButtonNotDisplayed(timeout?: number): Promise { + try { + await BrowserVisibility.waitUntilElementIsNotVisible(this.releaseButton, timeout); + return true; + } catch (error) { + return false; + } + } + + async isSaveButtonEnabled(): Promise { + return this.saveButton.isEnabled(); + } + + async isClaimButtonEnabled(): Promise { + return this.claimButton.isEnabled(); + } + + async isReleaseButtonEnabled(): Promise { + return this.releaseButton.isEnabled(); + } +}