Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACA-3184][ACA-3185] Create Task Util class #5863

Merged
merged 4 commits into from Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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)));
}
}
}