Skip to content

Commit

Permalink
[ACA-3184][ACA-3185] Create Task Util class (#5863)
Browse files Browse the repository at this point in the history
* Create Task Util page

* Export Task Util class

* Update Task Util

* Add checks for No Form fields
  • Loading branch information
Iulia Burcă committed Jul 16, 2020
1 parent b968e87 commit dace956
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
46 changes: 46 additions & 0 deletions lib/testing/src/lib/core/pages/form/form-fields.ts
Expand Up @@ -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');

Expand Down Expand Up @@ -124,10 +127,36 @@ export class FormFields {
return BrowserActions.getText(this.noFormMessage);
}

async getNoFormMessageStandaloneTask(): Promise<string> {
return BrowserActions.getText(this.noFormMessageStandaloneTask);
}

async getCompletedTaskNoFormMessage(): Promise<string> {
return BrowserActions.getText(this.completedTaskNoFormMessage);
}

async getCompletedStandaloneTaskNoFormMessage(): Promise<string> {
return BrowserActions.getText(this.completedStandaloneTaskNoFormMessage);
}

async isStandaloneTaskNoFormMessageDisplayed(): Promise<boolean> {
try {
await BrowserVisibility.waitUntilElementIsVisible(this.noFormMessageStandaloneTask);
return true;
} catch (error) {
return false;
}
}

async isAttachFormButtonDisplayed(): Promise<boolean> {
try {
await BrowserVisibility.waitUntilElementIsVisible(this.attachFormButton);
return true;
} catch (error) {
return false;
}
}

async clickOnAttachFormButton(): Promise<void> {
await BrowserActions.click(this.attachFormButton);
}
Expand All @@ -152,6 +181,10 @@ export class FormFields {
await BrowserActions.click(this.completeButton);
}

async completeNoFormTask(): Promise<void> {
await BrowserActions.click(this.completeNoFormButton);
}

async setValueInInputById(fieldId: string, value: string): Promise<void> {
const input = element(by.id(fieldId));
await BrowserActions.clearSendKeys(input, value);
Expand All @@ -166,10 +199,23 @@ export class FormFields {
}
}

async isCompleteNoFormButtonDisplayed(): Promise<boolean> {
try {
await BrowserVisibility.waitUntilElementIsVisible(this.completeNoFormButton);
return true;
} catch (error) {
return false;
}
}

async isCompleteFormButtonEnabled(): Promise<boolean> {
return this.completeButton.isEnabled();
}

async isCompleteNoFormButtonEnabled(): Promise<boolean> {
return this.completeNoFormButton.isEnabled();
}

async isCancelButtonDisplayed(): Promise<boolean> {
try {
await BrowserVisibility.waitUntilElementIsVisible(this.cancelButton);
Expand Down
1 change: 1 addition & 0 deletions lib/testing/src/lib/process-services/actions/public-api.ts
Expand Up @@ -19,3 +19,4 @@ export * from './applications.util';
export * from './integration.service';
export * from './models.service';
export * from './process.util';
export * from './task.util';
61 changes: 61 additions & 0 deletions 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<any> {
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<any> {
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<any> {
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<any> {
try {
return this.api.apiService.activiti.taskApi.deleteTask(taskInstance);
} catch (error) {
Logger.error('Delete Task - Service error, Response: ', JSON.parse(JSON.stringify(error)));
}
}
}

0 comments on commit dace956

Please sign in to comment.