From dace956aa0429686afb7befd9da9eb9a858e6a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iulia=20Burc=C4=83?= Date: Thu, 16 Jul 2020 13:57:05 +0300 Subject: [PATCH] [ACA-3184][ACA-3185] Create Task Util class (#5863) * Create Task Util page * Export Task Util class * Update Task Util * Add checks for No Form fields --- .../src/lib/core/pages/form/form-fields.ts | 46 ++++++++++++++ .../process-services/actions/public-api.ts | 1 + .../lib/process-services/actions/task.util.ts | 61 +++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 lib/testing/src/lib/process-services/actions/task.util.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 87ecdad7a2..e3b1e3483f 100644 --- a/lib/testing/src/lib/core/pages/form/form-fields.ts +++ b/lib/testing/src/lib/core/pages/form/form-fields.ts @@ -27,10 +27,13 @@ export class FormFields { valueLocator = by.css('input'); labelLocator = by.css('label'); noFormMessage = element(by.css('.adf-empty-content__title')); + noFormMessageStandaloneTask = element(by.css('adf-task-standalone #adf-no-form-message')); noFormTemplate = element(by.css('adf-empty-content')); completedTaskNoFormMessage = element(by.css('div[id*="completed-form-message"] p')); + completedStandaloneTaskNoFormMessage = element(by.css('adf-task-standalone #adf-completed-form-message')); 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')); errorMessage = by.css('.adf-error-text-container .adf-error-text'); @@ -124,10 +127,36 @@ export class FormFields { return BrowserActions.getText(this.noFormMessage); } + async getNoFormMessageStandaloneTask(): Promise { + return BrowserActions.getText(this.noFormMessageStandaloneTask); + } + async getCompletedTaskNoFormMessage(): Promise { return BrowserActions.getText(this.completedTaskNoFormMessage); } + async getCompletedStandaloneTaskNoFormMessage(): Promise { + return BrowserActions.getText(this.completedStandaloneTaskNoFormMessage); + } + + async isStandaloneTaskNoFormMessageDisplayed(): Promise { + try { + await BrowserVisibility.waitUntilElementIsVisible(this.noFormMessageStandaloneTask); + return true; + } catch (error) { + return false; + } + } + + async isAttachFormButtonDisplayed(): Promise { + try { + await BrowserVisibility.waitUntilElementIsVisible(this.attachFormButton); + return true; + } catch (error) { + return false; + } + } + async clickOnAttachFormButton(): Promise { await BrowserActions.click(this.attachFormButton); } @@ -152,6 +181,10 @@ export class FormFields { await BrowserActions.click(this.completeButton); } + async completeNoFormTask(): Promise { + await BrowserActions.click(this.completeNoFormButton); + } + async setValueInInputById(fieldId: string, value: string): Promise { const input = element(by.id(fieldId)); await BrowserActions.clearSendKeys(input, value); @@ -166,10 +199,23 @@ export class FormFields { } } + async isCompleteNoFormButtonDisplayed(): Promise { + try { + await BrowserVisibility.waitUntilElementIsVisible(this.completeNoFormButton); + return true; + } catch (error) { + return false; + } + } + async isCompleteFormButtonEnabled(): Promise { return this.completeButton.isEnabled(); } + async isCompleteNoFormButtonEnabled(): Promise { + return this.completeNoFormButton.isEnabled(); + } + async isCancelButtonDisplayed(): Promise { try { await BrowserVisibility.waitUntilElementIsVisible(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 dbc9faddd3..8950277b82 100644 --- a/lib/testing/src/lib/process-services/actions/public-api.ts +++ b/lib/testing/src/lib/process-services/actions/public-api.ts @@ -19,3 +19,4 @@ export * from './applications.util'; export * from './integration.service'; export * from './models.service'; export * from './process.util'; +export * from './task.util'; diff --git a/lib/testing/src/lib/process-services/actions/task.util.ts b/lib/testing/src/lib/process-services/actions/task.util.ts new file mode 100644 index 0000000000..c0a82a310d --- /dev/null +++ b/lib/testing/src/lib/process-services/actions/task.util.ts @@ -0,0 +1,61 @@ +/*! + * @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'; +import { TaskRepresentation } from '@alfresco/js-api'; + +export class TaskUtil { + + api: ApiService; + + constructor(api: ApiService) { + this.api = api; + } + + async createStandaloneTask(taskName: string): Promise { + try { + return this.api.getInstance().activiti.taskApi.createNewTask(new TaskRepresentation({ name: taskName })); + } catch (error) { + Logger.error('Create Standalone 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))); + } + } + + async completeTaskForm(taskInstance: string): Promise { + try { + return this.api.getInstance().activiti.taskApi.completeTaskForm(taskInstance, { values: { label: null } }); + } catch (error) { + Logger.error('Complete Task Form - Service error, Response: ', JSON.parse(JSON.stringify(error))); + } + } + + async deleteTask(taskInstance: string): Promise { + try { + return this.api.apiService.activiti.taskApi.deleteTask(taskInstance); + } catch (error) { + Logger.error('Delete Task - Service error, Response: ', JSON.parse(JSON.stringify(error))); + } + } +}