diff --git a/e2e/process-services-cloud/form-field/task-visibility-condition.e2e.ts b/e2e/process-services-cloud/form-field/task-visibility-condition.e2e.ts index bb7b94fe84..bce7aa000d 100644 --- a/e2e/process-services-cloud/form-field/task-visibility-condition.e2e.ts +++ b/e2e/process-services-cloud/form-field/task-visibility-condition.e2e.ts @@ -24,7 +24,7 @@ import { StringUtil, StartTasksCloudPage, TaskFormCloudComponent, - StartProcessCloudPage + StartProcessCloudPage, ProcessCloudWidgetPage } from '@alfresco/adf-testing'; import { browser, by } from 'protractor'; @@ -44,6 +44,7 @@ describe('Task cloud visibility', async () => { const startProcessPage = new StartProcessCloudPage(); const processCloudDemoPage = new ProcessCloudDemoPage(); const loginSSOPage = new LoginSSOPage(); + const widget = new ProcessCloudWidgetPage(); const apiService = new ApiService(); const identityService = new IdentityService(apiService); @@ -57,7 +58,7 @@ describe('Task cloud visibility', async () => { beforeAll(async () => { await apiService.login(browser.params.identityAdmin.email, browser.params.identityAdmin.password); - testUser = await identityService.createIdentityUserWithRole( [identityService.ROLES.ACTIVITI_USER]); + testUser = await identityService.createIdentityUserWithRole([identityService.ROLES.ACTIVITI_USER]); groupInfo = await groupIdentityService.getGroupInfoByGroupName('hr'); await identityService.addUserToGroup(testUser.idIdentityService, groupInfo.id); @@ -146,13 +147,16 @@ describe('Task cloud visibility', async () => { await tasksCloudDemoPage.taskListCloudComponent().selectRow('boolean_visibility_task'); await taskFormCloudComponent.clickClaimButton(); + await browser.sleep(400); + await taskFormCloudComponent.formFields().checkWidgetIsVisible('Checkbox2'); await taskFormCloudComponent.formFields().checkWidgetIsHidden('Checkbox3'); await expect(await taskFormCloudComponent.formFields().isCompleteFormButtonEnabled()).toEqual(false); - await taskFormCloudComponent.formFields().clickField(by.id, 'Checkbox1'); - await taskFormCloudComponent.formFields().clickField(by.id, 'Checkbox2'); - await taskFormCloudComponent.formFields().checkWidgetIsVisible('Checkbox3'); + await widget.checkboxWidget().clickCheckboxInput('Checkbox1'); + await widget.checkboxWidget().clickCheckboxInput('Checkbox2'); + + await widget.checkboxWidget().isCheckboxDisplayed('Checkbox3'); await expect(await taskFormCloudComponent.formFields().isCompleteFormButtonEnabled()).toEqual(true); await taskFormCloudComponent.clickCompleteButton(); @@ -172,9 +176,10 @@ describe('Task cloud visibility', async () => { await taskFormCloudComponent.formFields().checkWidgetIsHidden('Checkbox3'); await expect(await taskFormCloudComponent.formFields().isCompleteFormButtonEnabled()).toEqual(false); - await taskFormCloudComponent.formFields().clickField(by.id, 'Checkbox1'); - await taskFormCloudComponent.formFields().clickField(by.id, 'Checkbox2'); - await taskFormCloudComponent.formFields().checkWidgetIsVisible('Checkbox3'); + await widget.checkboxWidget().clickCheckboxInput('Checkbox1'); + await widget.checkboxWidget().clickCheckboxInput('Checkbox2'); + + await widget.checkboxWidget().isCheckboxDisplayed('Checkbox3'); await expect(await taskFormCloudComponent.formFields().isCompleteFormButtonEnabled()).toEqual(true); await taskFormCloudComponent.clickCompleteButton(); diff --git a/e2e/process-services-cloud/task-list-properties.e2e.ts b/e2e/process-services-cloud/task-list-properties.e2e.ts index b41be03819..1a3522c34f 100644 --- a/e2e/process-services-cloud/task-list-properties.e2e.ts +++ b/e2e/process-services-cloud/task-list-properties.e2e.ts @@ -139,7 +139,6 @@ describe('Edit task filters and task list properties', () => { it('[C297476] Filter by taskName', async () => { await tasksCloudDemoPage.editTaskFilterCloudComponent().setTaskName(createdTask.entry.name); await expect(await tasksCloudDemoPage.editTaskFilterCloudComponent().getTaskName()).toEqual(createdTask.entry.name); - await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(createdTask.entry.name); await tasksCloudDemoPage.taskListCloudComponent().getRowsWithSameName(createdTask.entry.name).then(async (list) => { await expect(list.length).toEqual(1); }); diff --git a/e2e/protractor.excludes.json b/e2e/protractor.excludes.json index bfd870e452..2bba034ffc 100644 --- a/e2e/protractor.excludes.json +++ b/e2e/protractor.excludes.json @@ -1,3 +1,4 @@ { + "C290180": "https://issues.alfresco.com/jira/browse/ACS-364" } diff --git a/e2e/test.config.js b/e2e/test.config.js index 38c5d39bbd..2f59585481 100644 --- a/e2e/test.config.js +++ b/e2e/test.config.js @@ -35,8 +35,10 @@ const SCREENSHOT_PASSWORD = process.env.SCREENSHOT_PASSWORD || process.env.PASSW const SCREENSHOT_USERNAME = process.env.SCREENSHOT_USERNAME || process.env.USERNAME_ADF; const EXTERNAL_ACS_HOST = process.env.EXTERNAL_ACS_HOST; +const LOG_LEVEL = process.env.LOG_LEVEL || 'ERROR' ; const appConfig = { + "log": LOG_LEVEL, "ecmHost": HOST_ECM, "bpmHost": HOST_BPM, "identityHost": `${OAUTH_HOST}/auth/admin/realms/alfresco`, diff --git a/lib/testing/src/lib/core/actions/api.service.ts b/lib/testing/src/lib/core/actions/api.service.ts index 3776b79008..ac219f1485 100644 --- a/lib/testing/src/lib/core/actions/api.service.ts +++ b/lib/testing/src/lib/core/actions/api.service.ts @@ -78,37 +78,39 @@ export class ApiService { } async performBpmOperation(path: string, method: string, queryParams: any, postBody: any): Promise { - const uri = this.config.hostBpm + path; - const pathParams = {}, formParams = {}; - const contentTypes = ['application/json']; - const accepts = ['application/json']; + return new Promise((resolve, reject) => { + const uri = this.config.hostBpm + path; + const pathParams = {}, formParams = {}; + const contentTypes = ['application/json']; + const accepts = ['application/json']; - const headerParams = { - Authorization: 'bearer ' + this.apiService.oauth2Auth.token - }; + const headerParams = { + Authorization: 'bearer ' + this.apiService.oauth2Auth.token + }; - return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, Object) - .catch((error) => { - throw (error); - }); + this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody, + contentTypes, accepts, Object) + .then((data) => resolve(data)) + .catch((err) => reject(err)); + }); } async performIdentityOperation(path: string, method: string, queryParams: any, postBody: any): Promise { - const uri = this.config.oauth2.host.replace('/realms', '/admin/realms') + path; - const pathParams = {}, formParams = {}; - const contentTypes = ['application/json']; - const accepts = ['application/json']; + return new Promise((resolve, reject) => { - const headerParams = { - Authorization: 'bearer ' + this.apiService.oauth2Auth.token - }; + const uri = this.config.oauth2.host.replace('/realms', '/admin/realms') + path; + const pathParams = {}, formParams = {}; + const contentTypes = ['application/json']; + const accepts = ['application/json']; - return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, Object) - .catch((error) => { - throw (error); - }); + const headerParams = { + Authorization: 'bearer ' + this.apiService.oauth2Auth.token + }; + + return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody, + contentTypes, accepts, Object) + .then((data) => resolve(data)) + .catch((err) => reject(err)); + }); } - } 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 b518c2c81b..441def8949 100644 --- a/lib/testing/src/lib/core/pages/form/form-fields.ts +++ b/lib/testing/src/lib/core/pages/form/form-fields.ts @@ -41,11 +41,6 @@ export class FormFields { await BrowserActions.clearSendKeys(fieldElement, value); } - async clickField(locator, field: string, fieldText?: string): Promise { - const fieldElement = fieldText ? element(locator(field, fieldText)) : element(locator(field)); - await BrowserActions.click(fieldElement); - } - async checkWidgetIsVisible(fieldId: string): Promise { const fieldElement = element.all(by.css(`adf-form-field div[id='field-${fieldId}-container']`)).first(); await BrowserVisibility.waitUntilElementIsVisible(fieldElement); diff --git a/lib/testing/src/lib/core/utils/browser-actions.ts b/lib/testing/src/lib/core/utils/browser-actions.ts index 69118a6df6..cb460e6c6c 100644 --- a/lib/testing/src/lib/core/utils/browser-actions.ts +++ b/lib/testing/src/lib/core/utils/browser-actions.ts @@ -26,6 +26,7 @@ export class BrowserActions { static async click(elementFinder: ElementFinder): Promise { try { + Logger.info(`Click element: ${elementFinder.locator().toString()}`); await BrowserVisibility.waitUntilElementIsPresent(elementFinder); await BrowserVisibility.waitUntilElementIsClickable(elementFinder); await elementFinder.click(); @@ -40,26 +41,33 @@ export class BrowserActions { await browser.executeScript(`arguments[0].click();`, elementFinder); } - static async waitUntilActionMenuIsVisible(): Promise { - const actionMenu = element.all(by.css('div[role="menu"]')).first(); - await BrowserVisibility.waitUntilElementIsVisible(actionMenu); - } - - static async waitUntilActionMenuIsNotVisible(): Promise { - const actionMenu = element.all(by.css('div[role="menu"]')).first(); - await BrowserVisibility.waitUntilElementIsNotVisible(actionMenu); - } - - static async getUrl(url: string, timeout: number = 10000): Promise { - return browser.get(url, timeout); - } - static async clickExecuteScript(elementCssSelector: string): Promise { await BrowserVisibility.waitUntilElementIsPresent(element(by.css(elementCssSelector))); await browser.executeScript(`document.querySelector('${elementCssSelector}').click();`); } + static async waitUntilActionMenuIsVisible(): Promise { + Logger.info(`wait Until Action Menu Is Visible`); + + const actionMenu = element.all(by.css('div[role="menu"]')).first(); + await BrowserVisibility.waitUntilElementIsVisible(actionMenu); + } + + static async waitUntilActionMenuIsNotVisible(): Promise { + Logger.info(`wait Until Action Menu Is Not Visible`); + + const actionMenu = element.all(by.css('div[role="menu"]')).first(); + await BrowserVisibility.waitUntilElementIsNotVisible(actionMenu); + } + + static async getUrl(url: string, timeout: number = 10000): Promise { + Logger.info(`Get URL ${url}`); + return browser.get(url, timeout); + } + static async getText(elementFinder: ElementFinder): Promise { + Logger.info(`Get Text ${elementFinder.locator().toString()}`); + const present = await BrowserVisibility.waitUntilElementIsPresent(elementFinder); if (present) { return elementFinder.getText(); @@ -69,6 +77,8 @@ export class BrowserActions { } static async getInputValue(elementFinder: ElementFinder): Promise { + Logger.info(`Get Input value ${elementFinder.locator().toString()}`); + const present = await BrowserVisibility.waitUntilElementIsPresent(elementFinder); if (present) { return elementFinder.getAttribute('value'); @@ -100,6 +110,8 @@ export class BrowserActions { } static async clearSendKeys(elementFinder: ElementFinder, text: string): Promise { + Logger.info(`Clear and sendKeys text:${text} locator:${elementFinder.locator().toString()}`); + await this.click(elementFinder); await elementFinder.sendKeys(''); await elementFinder.clear(); @@ -107,17 +119,23 @@ export class BrowserActions { } static async checkIsDisabled(elementFinder: ElementFinder): Promise { + Logger.info(`Check is disabled locator:${elementFinder.locator().toString()}`); + await BrowserVisibility.waitUntilElementIsVisible(elementFinder); const valueCheck = await elementFinder.getAttribute('disabled'); await expect(valueCheck).toEqual('true'); } static async rightClick(elementFinder: ElementFinder): Promise { + Logger.info(`Right click locator:${elementFinder.locator().toString()}`); + await browser.actions().mouseMove(elementFinder).mouseDown().mouseMove(elementFinder).perform(); await browser.actions().click(elementFinder, protractor.Button.RIGHT).perform(); } static async closeMenuAndDialogs(): Promise { + Logger.info(`close Menu And Dialogs`); + const container = element(by.css('div.cdk-overlay-backdrop.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing')); await browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); await BrowserVisibility.waitUntilElementIsNotVisible(container); diff --git a/lib/testing/src/lib/core/utils/browser-visibility.ts b/lib/testing/src/lib/core/utils/browser-visibility.ts index 4c7989eec2..0c1a468dbb 100644 --- a/lib/testing/src/lib/core/utils/browser-visibility.ts +++ b/lib/testing/src/lib/core/utils/browser-visibility.ts @@ -16,6 +16,7 @@ */ import { browser, by, element, ElementFinder, protractor } from 'protractor'; +import { Logger } from './logger'; const DEFAULT_TIMEOUT = global['TestConfig'] ? global['TestConfig'].main.timeout : 20000; const NOT_VISIBLE_DEFAULT_TIMEOUT = global['TestConfig'] ? global['TestConfig'].main.timeout : 2000; @@ -23,12 +24,16 @@ const NOT_VISIBLE_DEFAULT_TIMEOUT = global['TestConfig'] ? global['TestConfig']. export class BrowserVisibility { static async waitUntilElementIsPresent(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise { + Logger.info(`Wait Until Element Is Present ${elementToCheck.locator().toString()} for ${waitTimeout}`); + return browser.wait(protractor.ExpectedConditions.presenceOf(elementToCheck), waitTimeout, 'Element is not present ' + elementToCheck.locator()); } /* * Wait for element to be visible */ static async waitUntilElementIsVisible(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT, message: string = 'Element is not visible'): Promise { + Logger.info(`Wait Until Element Is Visible ${elementToCheck.locator().toString()} for ${waitTimeout}`); + return browser.wait(protractor.ExpectedConditions.visibilityOf(elementToCheck), waitTimeout, message + elementToCheck.locator()); } @@ -36,6 +41,8 @@ export class BrowserVisibility { * Wait for element to be clickable */ static async waitUntilElementIsClickable(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise { + Logger.info(`Wait Until Element Is Clickable ${elementToCheck.locator().toString()} for ${waitTimeout}`); + return browser.wait(protractor.ExpectedConditions.elementToBeClickable(elementToCheck), waitTimeout, 'Element is not Clickable ' + elementToCheck.locator()); } @@ -43,6 +50,8 @@ export class BrowserVisibility { * Wait for element to not be present on the page */ static async waitUntilElementIsStale(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise { + Logger.info(`Wait Until Element Is Stale ${elementToCheck.locator().toString()} for ${waitTimeout}`); + return browser.wait(protractor.ExpectedConditions.stalenessOf(elementToCheck), waitTimeout, 'Element is not in stale ' + elementToCheck.locator()); } @@ -50,6 +59,8 @@ export class BrowserVisibility { * Wait for element to not be visible */ static async waitUntilElementIsNotVisible(elementToCheck: ElementFinder, waitTimeout: number = NOT_VISIBLE_DEFAULT_TIMEOUT): Promise { + Logger.info(`Wait Until Element Is Not Visible ${elementToCheck.locator().toString()} for ${waitTimeout}`); + return browser.wait(protractor.ExpectedConditions.invisibilityOf(elementToCheck), waitTimeout, 'Element is Visible and it should not' + elementToCheck.locator()); } @@ -57,10 +68,14 @@ export class BrowserVisibility { * Wait for element to have value */ static async waitUntilElementHasValue(elementToCheck: ElementFinder, elementValue, waitTimeout: number = DEFAULT_TIMEOUT): Promise { + Logger.info(`Wait Until Element has value ${elementToCheck.locator().toString()} for ${waitTimeout}`); + return browser.wait(protractor.ExpectedConditions.textToBePresentInElementValue(elementToCheck, elementValue), waitTimeout, 'Element doesn\'t have a value ' + elementToCheck.locator()); } static async waitUntilElementIsNotPresent(elementToCheck: ElementFinder, waitTimeout: number = NOT_VISIBLE_DEFAULT_TIMEOUT): Promise { + Logger.info(`Wait Until Element is not present ${elementToCheck.locator().toString()} for ${waitTimeout}`); + return browser.wait(protractor.ExpectedConditions.stalenessOf(elementToCheck), waitTimeout, 'Element is present ' + elementToCheck.locator()); } diff --git a/lib/testing/src/lib/core/utils/logger.ts b/lib/testing/src/lib/core/utils/logger.ts index 061eb331e3..1b9096487a 100644 --- a/lib/testing/src/lib/core/utils/logger.ts +++ b/lib/testing/src/lib/core/utils/logger.ts @@ -32,30 +32,30 @@ export class LogLevelsEnum extends Number { } export let logLevels: any[] = [ - {level: LogLevelsEnum.TRACE, name: 'TRACE'}, - {level: LogLevelsEnum.DEBUG, name: 'DEBUG'}, - {level: LogLevelsEnum.INFO, name: 'INFO'}, - {level: LogLevelsEnum.WARN, name: 'WARN'}, - {level: LogLevelsEnum.ERROR, name: 'ERROR'}, - {level: LogLevelsEnum.SILENT, name: 'SILENT'} + { level: LogLevelsEnum.TRACE, name: 'TRACE' }, + { level: LogLevelsEnum.DEBUG, name: 'DEBUG' }, + { level: LogLevelsEnum.INFO, name: 'INFO' }, + { level: LogLevelsEnum.WARN, name: 'WARN' }, + { level: LogLevelsEnum.ERROR, name: 'ERROR' }, + { level: LogLevelsEnum.SILENT, name: 'SILENT' } ]; /* tslint:disable:no-console */ export class Logger { static info(...messages: string[]): void { - if (browser.params.testConfig && browser.params.testConfig.appConfig.log >= LogLevelsEnum.INFO) { + if (browser.params.testConfig && Logger.getLogLevelByName(browser.params.testConfig.appConfig.log) >= LogLevelsEnum.INFO) { console.log(infoColor, messages.join('')); } } static log(...messages: string[]): void { - if (browser.params.testConfig && browser.params.testConfig.appConfig.log >= LogLevelsEnum.TRACE) { + if (browser.params.testConfig && Logger.getLogLevelByName(browser.params.testConfig.appConfig.log) >= LogLevelsEnum.TRACE) { console.log(logColor, messages.join('')); } } static warn(...messages: string[]): void { - if (browser.params.testConfig && browser.params.testConfig.appConfig.log >= LogLevelsEnum.WARN) { + if (browser.params.testConfig && Logger.getLogLevelByName(browser.params.testConfig.appConfig.log) >= LogLevelsEnum.WARN) { console.log(warnColor, messages.join('')); } } @@ -63,4 +63,12 @@ export class Logger { static error(...messages: string[]): void { console.log(errorColor, messages.join('')); } + + private static getLogLevelByName(name: string): number { + const log = logLevels.find((currentLog) => { + return currentLog.name === name; + }); + + return log.level || 1; + } } diff --git a/lib/testing/src/lib/process-services-cloud/actions/tasks.service.ts b/lib/testing/src/lib/process-services-cloud/actions/tasks.service.ts index cdbd45a6c5..548edb3065 100644 --- a/lib/testing/src/lib/process-services-cloud/actions/tasks.service.ts +++ b/lib/testing/src/lib/process-services-cloud/actions/tasks.service.ts @@ -27,80 +27,75 @@ export class TasksService { } async createStandaloneTask(taskName: string, appName: string, options?: Object): Promise { - try { - const path = '/' + appName + '/rb/v1/tasks'; - const method = 'POST'; + const path = '/' + appName + '/rb/v1/tasks'; + const method = 'POST'; - const queryParams = {}, postBody = { - name: taskName, - payloadType: 'CreateTaskPayload', - ...options - }; + const queryParams = {}, postBody = { + name: taskName, + payloadType: 'CreateTaskPayload', + ...options + }; - return this.api.performBpmOperation(path, method, queryParams, postBody); - } catch (error) { - Logger.error('Create Task - Service error, Response: ', JSON.parse(JSON.stringify(error))); - } + return this.api.performBpmOperation(path, method, queryParams, postBody) + .catch((error) => { + Logger.error('Create Task - Service error, Response: ', JSON.stringify(error.response.text)); + }); } async createStandaloneTaskWithForm(taskName: string, appName: string, formKey: string, options?: Object): Promise { - try { - const path = '/' + appName + '/rb/v1/tasks'; - const method = 'POST'; + const path = '/' + appName + '/rb/v1/tasks'; + const method = 'POST'; - const queryParams = {}; - const postBody = { - name: taskName, - payloadType: 'CreateTaskPayload', - formKey: formKey, - ...options - }; + const queryParams = {}; + const postBody = { + name: taskName, + payloadType: 'CreateTaskPayload', + formKey: formKey, + ...options + }; - return this.api.performBpmOperation(path, method, queryParams, postBody); - } catch (error) { - Logger.error('Create FormTask - Service error, Response: ', JSON.parse(JSON.stringify(error))); - } + return this.api.performBpmOperation(path, method, queryParams, postBody) + .catch((error) => { + Logger.error('Create standalone Task - Service error, Response: ', JSON.stringify(error.response.text)); + }); } async completeTask(taskId: string, appName: string): Promise { - try { - const path = '/' + appName + '/rb/v1/tasks/' + taskId + '/complete'; - const method = 'POST'; + const path = '/' + appName + '/rb/v1/tasks/' + taskId + '/complete'; + const method = 'POST'; - const queryParams = {}, postBody = { payloadType: 'CompleteTaskPayload' }; + const queryParams = {}, postBody = { payloadType: 'CompleteTaskPayload' }; - return this.api.performBpmOperation(path, method, queryParams, postBody); - } catch (error) { - Logger.error('Complete Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text); - } + return this.api.performBpmOperation(path, method, queryParams, postBody) + .catch((error) => { + Logger.error('Complete Task - Service error, Response: ', JSON.stringify(error.response.text)); + }); } async claimTask(taskId: string, appName: string): Promise { - try { - const path = '/' + appName + '/rb/v1/tasks/' + taskId + `/claim`; - const method = 'POST'; + const path = '/' + appName + '/rb/v1/tasks/' + taskId + `/claim`; + const method = 'POST'; - const queryParams = {}; - const postBody = {}; + const queryParams = {}; + const postBody = {}; - return this.api.performBpmOperation(path, method, queryParams, postBody); - } catch (error) { - Logger.error('Claim Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text); - } + return this.api.performBpmOperation(path, method, queryParams, postBody) + .catch((error) => { + Logger.error('claim Task - Service error, Response: ', JSON.stringify(error.response.text)); + }); } async deleteTask(taskId: string, appName: string): Promise { - try { - const path = '/' + appName + '/rb/v1/tasks/' + taskId; - const method = 'DELETE'; + const path = '/' + appName + '/rb/v1/tasks/' + taskId; + const method = 'DELETE'; - const queryParams = {}; - const postBody = {}; + const queryParams = {}; + const postBody = {}; - return this.api.performBpmOperation(path, method, queryParams, postBody); - } catch (error) { - Logger.error('Delete Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text); - } + return this.api.performBpmOperation(path, method, queryParams, postBody) + .catch((error) => { + Logger.error('delete Task - Service error, Response: ', JSON.stringify(error.response.text)); + }); } async createAndCompleteTask(taskName: string, appName: string): Promise { @@ -111,45 +106,42 @@ export class TasksService { } async getTask(taskId: string, appName: string): Promise { - try { - const path = '/' + appName + '/query/v1/tasks/' + taskId; - const method = 'GET'; + const path = '/' + appName + '/query/v1/tasks/' + taskId; + const method = 'GET'; - const queryParams = {}; - const postBody = {}; + const queryParams = {}; + const postBody = {}; - return this.api.performBpmOperation(path, method, queryParams, postBody); - } catch (error) { - Logger.error('Get Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text); - } + return this.api.performBpmOperation(path, method, queryParams, postBody) + .catch((error) => { + Logger.error('Get Task - Service error, Response: ', JSON.stringify(error.response.text)); + }); } async getTaskId(taskName: string, appName: string): Promise { - try { - const path = '/' + appName + '/query/v1/tasks'; - const method = 'GET'; + const path = '/' + appName + '/query/v1/tasks'; + const method = 'GET'; - const queryParams = { name: taskName }, postBody = {}; + const queryParams = { name: taskName }, postBody = {}; - const data = await this.api.performBpmOperation(path, method, queryParams, postBody); - return data.list.entries && data.list.entries.length > 0 ? data.list.entries[0].entry.id : null; - } catch (error) { - Logger.error('Get Task Id - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text); - } + const data = await this.api.performBpmOperation(path, method, queryParams, postBody) + .catch((error) => { + Logger.error('Get Task Id Service error, Response: ', JSON.stringify(error.response.text)); + }); + return data.list.entries && data.list.entries.length > 0 ? data.list.entries[0].entry.id : null; } async createStandaloneSubtask(parentTaskId: string, appName: string, name: string): Promise { - try { - const path = '/' + appName + '/rb/v1/tasks'; - const method = 'POST'; + const path = '/' + appName + '/rb/v1/tasks'; + const method = 'POST'; - const queryParams = {}, - postBody = { name: name, parentTaskId: parentTaskId, payloadType: 'CreateTaskPayload' }; + const queryParams = {}, + postBody = { name: name, parentTaskId: parentTaskId, payloadType: 'CreateTaskPayload' }; - return this.api.performBpmOperation(path, method, queryParams, postBody); - } catch (error) { - Logger.error('Create Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text); - } + return this.api.performBpmOperation(path, method, queryParams, postBody) + .catch((error) => { + Logger.error('Create sub Task - Service error, Response: ', JSON.stringify(error.response.text)); + }); } } diff --git a/scripts/travis/e2e/process-services-cloud-e2e.sh b/scripts/travis/e2e/process-services-cloud-e2e.sh index 7232beab17..6d0c745b4c 100755 --- a/scripts/travis/e2e/process-services-cloud-e2e.sh +++ b/scripts/travis/e2e/process-services-cloud-e2e.sh @@ -13,7 +13,7 @@ export AUTH_TYPE="OAUTH" AFFECTED_LIBS="$(./scripts/affected-libs.sh -gnu -b $TRAVIS_BRANCH)"; AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")"; -RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST_BPM" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" -host_sso "$E2E_HOST_SSO" -identity_admin_email "$E2E_ADMIN_EMAIL_IDENTITY" -identity_admin_password "$E2E_ADMIN_PASSWORD_IDENTITY" -prefix $TRAVIS_BUILD_NUMBER --use-dist -m 2 -save ) +RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST_BPM" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" -host_sso "$E2E_HOST_SSO" -identity_admin_email "$E2E_ADMIN_EMAIL_IDENTITY" -identity_admin_password "$E2E_ADMIN_PASSWORD_IDENTITY" -prefix $TRAVIS_BUILD_NUMBER --use-dist -m 2 -save -b ) ./node_modules/@alfresco/adf-cli/bin/adf-cli init-aae-env --host "$E2E_HOST_BPM" --oauth "$E2E_HOST_SSO" --modelerUsername "$E2E_MODELER_USERNAME" --modelerPassword "$E2E_MODELER_PASSWORD" --devopsUsername "$E2E_DEVOPS_USERNAME" --devopsPassword "$E2E_DEVOPS_PASSWORD" --clientId 'activiti' || exit 1 node ./scripts/check-env/check-cs-env.js --host "$E2E_HOST_BPM" -u "$E2E_ADMIN_EMAIL_IDENTITY" -p "$E2E_ADMIN_PASSWORD_IDENTITY" || exit 1