diff --git a/lib/testing/src/lib/core/pages/viewer.page.ts b/lib/testing/src/lib/core/pages/viewer.page.ts index bb7ef8b520..a3dc837676 100644 --- a/lib/testing/src/lib/core/pages/viewer.page.ts +++ b/lib/testing/src/lib/core/pages/viewer.page.ts @@ -267,6 +267,12 @@ export class ViewerPage { await BrowserVisibility.waitUntilElementHasText(this.fileName, filename); } + async checkFileIsOpenedInViewerAndClose(filename: string): Promise { + await this.checkFileThumbnailIsDisplayed(); + await this.checkFileNameIsDisplayed(filename); + await this.clickCloseButton(); + } + async checkPreviousPageButtonIsDisplayed() { await BrowserVisibility.waitUntilElementIsVisible(this.previousPageButton); } diff --git a/lib/testing/src/lib/process-services-cloud/actions/process.services.ts b/lib/testing/src/lib/process-services-cloud/actions/process.services.ts new file mode 100644 index 0000000000..e46fa173eb --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/actions/process.services.ts @@ -0,0 +1,70 @@ +/*! + * @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 { ApiService } from '../../core/actions/api.service'; +import { ApiUtil } from '../../core/actions/api.util'; +import { ProcessDefinitionsService } from './process-definitions.service'; +import { ProcessInstancesService } from './process-instances.service'; +import { QueryService } from '../../core/actions/identity/query.service'; +import { TasksService } from './tasks.service'; +import { StringUtil } from '../../core/utils/string.util'; +import { Logger } from '../../core/utils/logger'; + +export class ProcessServices { + + private api: ApiService; + public processInstancesService: ProcessInstancesService; + public processDefinitionsService: ProcessDefinitionsService; + public tasksService: TasksService; + public queryService: QueryService; + + constructor(api: ApiService) { + this.api = api; + this.processInstancesService = new ProcessInstancesService(this.api); + this.processDefinitionsService = new ProcessDefinitionsService(this.api); + this.tasksService = new TasksService(this.api); + this.queryService = new QueryService(this.api); + } + + async createProcessInstanceAndClaimFirstTask(processDefName, appName, taskIndex: number = 0, processInstanceName?: string) { + const processInstance = await this.createProcessInstance(processDefName, appName, processInstanceName); + const task = await this.queryService.getProcessInstanceTasks(processInstance.entry.id, appName); + await this.tasksService.claimTask(task.list.entries[taskIndex].entry.id, appName); + + return processInstance; + } + + async createProcessInstance(processDefName, appName, processInstanceName?: string) { + const processDefinition = await this.processDefinitionsService.getProcessDefinitionByName(processDefName, appName); + const processInstance = await this.processInstancesService.createProcessInstance(processDefinition.entry.key, appName, { + name: processInstanceName ? processInstanceName : StringUtil.generateRandomString(), + businessKey: StringUtil.generateRandomString() + }); + + return processInstance; + } + + async waitForStatus(processInstanceId: string, appName: string, expectedStatus: string): Promise { + const predicate = (result: any) => { + Logger.info(`Process instance ${processInstanceId} status found: ${result.entry.status}`); + return result.entry.status === expectedStatus; + }; + + const apiCall = async () => this.queryService.getProcessInstance(processInstanceId, appName); + return ApiUtil.waitForApi(apiCall, predicate, 3, 500); + } +} diff --git a/lib/testing/src/lib/process-services-cloud/actions/public-api.ts b/lib/testing/src/lib/process-services-cloud/actions/public-api.ts index 090bc45a4c..2cdd78451f 100644 --- a/lib/testing/src/lib/process-services-cloud/actions/public-api.ts +++ b/lib/testing/src/lib/process-services-cloud/actions/public-api.ts @@ -17,6 +17,7 @@ export * from './process-definitions.service'; export * from './process-instances.service'; +export * from './process.services'; export * from './message-events.service'; export * from './form-cloud.service'; export * from './tasks.service'; diff --git a/lib/testing/src/lib/process-services-cloud/resources/resources.json b/lib/testing/src/lib/process-services-cloud/resources/resources.json index f585035ce7..9e69119561 100644 --- a/lib/testing/src/lib/process-services-cloud/resources/resources.json +++ b/lib/testing/src/lib/process-services-cloud/resources/resources.json @@ -176,7 +176,8 @@ "uploadSingleMultiple": { "name": "upload-single-multiple", "widgets": { - "contentMultipleAttachFileId": "UploadMultipleFileFromContentId" + "contentMultipleAttachFileId": "UploadMultipleFileFromContentId", + "contentSingleAttachFileId": "UploadSingleFileFromContentId" } }, "formWithJsonWidget": {