From d056b3decdb7b85476a0109fee91177f08ab6b59 Mon Sep 17 00:00:00 2001 From: cristinaj Date: Fri, 27 Jul 2018 01:27:31 +0300 Subject: [PATCH] [ADF-3385] Implementing start task - test cases (#3613) * Implementing start task - test cases * Removed syntax error. * Add data-automation-id for people widget. --- e2e/pages/adf/process_services/formFields.js | 35 +++++ .../adf/process_services/taskDetailsPage.js | 7 + .../adf/process_services/tasksListPage.js | 5 + .../start_task_custom_app.e2e.ts | 14 +- .../start_task_task_app.e2e.ts | 6 + e2e/standalone_task.e2e.ts | 143 ++++++++++++++++++ e2e/task-audit.e2e.ts | 134 ++++++++++++++++ .../widgets/people/people.widget.html | 1 + 8 files changed, 344 insertions(+), 1 deletion(-) create mode 100644 e2e/standalone_task.e2e.ts create mode 100644 e2e/task-audit.e2e.ts diff --git a/e2e/pages/adf/process_services/formFields.js b/e2e/pages/adf/process_services/formFields.js index cc3e814d95..d58f3b1990 100644 --- a/e2e/pages/adf/process_services/formFields.js +++ b/e2e/pages/adf/process_services/formFields.js @@ -24,6 +24,11 @@ var FormFields = function () { var saveButton = element(by.cssContainingText("mat-card-actions[class*='adf-form'] span", "SAVE")); var valueLocator = by.css("input"); var labelLocator = by.css("label"); + var noFormMessage = element(by.css("span[id*='no-form-message']")); + var completedTaskNoFormMessage = element(by.css("div[id*='completed-form-message'] p")); + var attachFormButton = element(by.id("adf-no-form-attach-form-button")); + var selectFormDropDownArrow = element(by.css("adf-attach-form div[class*='mat-select-arrow']")); + var selectFormContent = element(by.css("div[class*='mat-select-content']")); this.setFieldValue = function (By, field, value) { var fieldElement = element(By(field)); @@ -82,6 +87,36 @@ var FormFields = function () { return this; }; + this.getNoFormMessage = function () { + Util.waitUntilElementIsVisible(noFormMessage); + return noFormMessage.getText(); + }; + + this.getCompletedTaskNoFormMessage = function () { + Util.waitUntilElementIsVisible(completedTaskNoFormMessage); + return completedTaskNoFormMessage.getText(); + }; + + this.clickOnAttachFormButton = function () { + Util.waitUntilElementIsVisible(attachFormButton); + attachFormButton.click(); + return this; + }; + + this.selectForm = function (formName) { + Util.waitUntilElementIsVisible(selectFormDropDownArrow); + selectFormDropDownArrow.click(); + Util.waitUntilElementIsVisible(selectFormContent); + this.selectFormFromDropDown(formName); + return this; + }; + + this.selectFormFromDropDown = function (formName) { + var formNameElement = element(by.cssContainingText("span", formName)); + Util.waitUntilElementIsVisible(formNameElement); + formNameElement.click(); + }; + }; module.exports = FormFields; diff --git a/e2e/pages/adf/process_services/taskDetailsPage.js b/e2e/pages/adf/process_services/taskDetailsPage.js index 93f01c0f7e..29528e2b74 100644 --- a/e2e/pages/adf/process_services/taskDetailsPage.js +++ b/e2e/pages/adf/process_services/taskDetailsPage.js @@ -38,6 +38,8 @@ var TaskDetailsPage = function () { var addInvolvedUserButton = element(by.css("button[id='add-people'] span")); var emailInvolvedUser = by.xpath("following-sibling::div[@class='people-email ng-star-inserted']"); var infoDrawer = element(by.css("adf-info-drawer")); + var auditLogButton = element(by.css("button[adf-task-audit]")); + this.getFormName = function () { Util.waitUntilElementIsVisible(formNameField); @@ -169,6 +171,11 @@ var TaskDetailsPage = function () { return email.getText(); }; + this.clickAuditLogButton = function () { + Util.waitUntilElementIsVisible(auditLogButton); + auditLogButton.click(); + }; + this.usingTaskDetailsToggles = function () { return new TaskDetailsToggles(); }; diff --git a/e2e/pages/adf/process_services/tasksListPage.js b/e2e/pages/adf/process_services/tasksListPage.js index 3a570480b8..d9c8fdab90 100644 --- a/e2e/pages/adf/process_services/tasksListPage.js +++ b/e2e/pages/adf/process_services/tasksListPage.js @@ -21,6 +21,7 @@ var TasksListPage = function () { var taskList = element(by.css("adf-tasklist")); var tableBody = element.all(by.css("adf-datatable div[class='adf-datatable-body']")).first(); + var spinner = element(by.css('mat-progress-spinner')); this.checkTaskIsDisplayedInTasksList = function(taskName) { var row = by.cssContainingText("span", taskName); @@ -50,6 +51,10 @@ var TasksListPage = function () { Util.waitUntilElementIsVisible(tableBody); }; + this.checkSpinnerIsDisplayed = function () { + Util.waitUntilElementIsPresent(spinner); + }; + }; module.exports = TasksListPage; diff --git a/e2e/process-services/start_task_custom_app.e2e.ts b/e2e/process-services/start_task_custom_app.e2e.ts index d7f57640cc..0df36d6d27 100644 --- a/e2e/process-services/start_task_custom_app.e2e.ts +++ b/e2e/process-services/start_task_custom_app.e2e.ts @@ -20,6 +20,7 @@ import ProcessServicesPage = require('../pages/adf/process_services/processServi import TasksPage = require('../pages/adf/process_services/tasksPage'); import { AttachmentListPage } from '../pages/adf/process_services/attachmentListPage'; import CONSTANTS = require('../util/constants'); +import ProcessFiltersPage = require('../pages/adf/process_services/processFiltersPage'); import Task = require('../models/APS/Task'); import Tenant = require('../models/APS/Tenant'); @@ -39,6 +40,7 @@ import { UsersActions } from '../actions/users.actions'; describe('Start Task - Custom App', () => { + let processFiltersPage = new ProcessFiltersPage(); let TASKDATAFORMAT = 'mmm dd yyyy'; let loginPage = new LoginPage(); let processServicesPage = new ProcessServicesPage(); @@ -49,7 +51,7 @@ describe('Start Task - Custom App', () => { let formFieldValue = 'First value '; let taskPage = new TasksPage(); let firstComment = 'comm1', firstChecklist = 'checklist1'; - let tasks = ['Modifying task', 'Information box', 'No form', 'Not Created', 'Refreshing form', 'Assignee task', 'Attach File']; + let tasks = ['Modifying task', 'Information box', 'No form', 'Not Created', 'Refreshing form', 'Assignee task', 'Attach File', 'Spinner']; let showHeaderTask = 'Show Header'; let appModel; let pngFile = new FileModel({ @@ -216,4 +218,14 @@ describe('Start Task - Custom App', () => { taskPage.usingTaskDetails().usingTaskDetailsToggles().enableShowHeader(); taskPage.usingTaskDetails().taskInfoDrawerIsDisplayed(); }); + + it('[C263950] Should be able to see Spinner loading on task list when clicking on Tasks on custom app', () => { + processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.createNewTask().addName(tasks[7]).clickStartButton(); + + processServicesPage.goToProcessServices().goToTaskApp(); + taskPage.usingTasksListPage().checkSpinnerIsDisplayed(); + }); + }); diff --git a/e2e/process-services/start_task_task_app.e2e.ts b/e2e/process-services/start_task_task_app.e2e.ts index b4e5857898..4cbbb45969 100644 --- a/e2e/process-services/start_task_task_app.e2e.ts +++ b/e2e/process-services/start_task_task_app.e2e.ts @@ -219,4 +219,10 @@ describe('Start Task - Task App', () => { taskPage.usingTaskDetails().usingTaskDetailsToggles().enableShowHeader(); taskPage.usingTaskDetails().taskInfoDrawerIsDisplayed(); }); + + it('[C260424] Should be able to see Spinner loading on task list when clicking on Tasks', () => { + processServicesPage.goToProcessServices().goToTaskApp(); + taskPage.usingTasksListPage().checkSpinnerIsDisplayed(); + }); + }); diff --git a/e2e/standalone_task.e2e.ts b/e2e/standalone_task.e2e.ts new file mode 100644 index 0000000000..6338554c3f --- /dev/null +++ b/e2e/standalone_task.e2e.ts @@ -0,0 +1,143 @@ +/*! + * @license + * Copyright 2016 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 LoginPage = require('./pages/adf/loginPage'); +import ProcessServicesPage = require('./pages/adf/process_services/processServicesPage'); +import TasksPage = require('./pages/adf/process_services/tasksPage'); + +import CONSTANTS = require('./util/constants'); + +import Tenant = require('./models/APS/Tenant'); +import Task = require('./models/APS/Task'); +import TaskModel = require('./models/APS/TaskModel'); +import FormModel = require('./models/APS/FormModel'); +import FileModel = require('./models/ACS/fileModel'); + +import TestConfig = require('./test.config'); +import resources = require('./util/resources'); + +import dateFormat = require('dateformat'); + +import AlfrescoApi = require('alfresco-js-api-node'); +import { UsersActions } from './actions/users.actions'; +import fs = require('fs'); +import path = require('path'); +import Util = require('./util/util'); + +describe('Start Task - Task App', () => { + + let loginPage = new LoginPage(); + let processServicesPage = new ProcessServicesPage(); + let processUserModel; + let app = resources.Files.SIMPLE_APP_WITH_USER_FORM; + let taskPage = new TasksPage(); + let tasks = ['Standalone task', 'Completed standalone task', 'Add a form', 'Remove form']; + let noFormMessage = 'No forms attached'; + let taskModel; + + beforeAll(async (done) => { + let users = new UsersActions(); + + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: TestConfig.adf.url + }); + + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + let newTenant = await this.alfrescoJsApi.activiti.adminTenantsApi.createTenant(new Tenant()); + + processUserModel = await users.createApsUser(this.alfrescoJsApi, newTenant.id); + + let pathFile = path.join(TestConfig.main.rootPath + app.file_location); + let file = fs.createReadStream(pathFile); + + await this.alfrescoJsApi.login(processUserModel.email, processUserModel.password); + + await this.alfrescoJsApi.activiti.appsApi.importAppDefinition(file); + + loginPage.loginToProcessServicesUsingUserModel(processUserModel); + + done(); + }); + + it('[C260421] Should a standalone task be displayed when creating a new task without form', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.createNewTask().addName(tasks[0]).clickStartButton() + .then(() => { + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[0]); + taskPage.usingFormFields().noFormIsDisplayed(); + expect(taskPage.usingTaskDetails().getFormName()).toEqual(CONSTANTS.TASKDETAILS.NO_FORM); + expect(taskPage.usingFormFields().getNoFormMessage()).toEqual(noFormMessage); + }); + }); + + it('[C268910] Should a standalone task be displayed in completed tasks when completing it', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.createNewTask().addName(tasks[1]).clickStartButton() + .then(() => { + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[1]); + taskPage.usingFormFields().noFormIsDisplayed(); + + taskPage.completeTaskNoForm(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.COMPL_TASKS); + taskPage.usingTasksListPage().selectTaskFromTasksList(tasks[1]); + expect(taskPage.usingFormFields().getCompletedTaskNoFormMessage()).toEqual('Task ' + tasks[1] + ' completed'); + + taskPage.usingFormFields().noFormIsDisplayed(); + expect(taskPage.usingTaskDetails().getFormName()).toEqual(CONSTANTS.TASKDETAILS.NO_FORM); + }); + }); + + it('[C268911] Should allow adding a form to a standalone task when clicking on Add form button', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.createNewTask().addName(tasks[2]).clickStartButton() + .then(() => { + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[2]); + taskPage.usingFormFields().noFormIsDisplayed(); + + taskPage.usingFormFields().clickOnAttachFormButton().selectForm(app.formName).clickOnAttachFormButton(); + expect(taskPage.usingTaskDetails().getFormName()).toEqual(app.formName); + }); + }); + + it('[C268912] Should a standalone task be displayed when removing the form from APS', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.createNewTask().addName(tasks[3]).addForm(app.formName).clickStartButton(); + + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[3]); + expect(taskPage.usingTaskDetails().getFormName()).toEqual(app.formName); + + browser.controlFlow().execute(async() => { + const listOfTasks = await this.alfrescoJsApi.activiti.taskApi.listTasks(new Task({ sort: 'created-desc' })); + await this.alfrescoJsApi.activiti.taskApi.removeForm(listOfTasks.data[0].id); + }); + + Util.refreshBrowser(); + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[3]); + taskPage.checkTaskTitle(tasks[3]); + + taskPage.usingFormFields().noFormIsDisplayed(); + expect(taskPage.usingTaskDetails().getFormName()).toEqual(CONSTANTS.TASKDETAILS.NO_FORM); + expect(taskPage.usingFormFields().getNoFormMessage()).toEqual(noFormMessage); + }); + +}); diff --git a/e2e/task-audit.e2e.ts b/e2e/task-audit.e2e.ts new file mode 100644 index 0000000000..7e8f4326b4 --- /dev/null +++ b/e2e/task-audit.e2e.ts @@ -0,0 +1,134 @@ +/*! + * @license + * Copyright 2016 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 LoginPage = require('./pages/adf/loginPage'); +import ProcessServicesPage = require('./pages/adf/process_services/processServicesPage'); +import TasksPage = require('./pages/adf/process_services/tasksPage'); + +import CONSTANTS = require('./util/constants'); + +import Tenant = require('./models/APS/Tenant'); +import Task = require('./models/APS/Task'); +import TaskModel = require('./models/APS/TaskModel'); +import FormModel = require('./models/APS/FormModel'); +import FileModel = require('./models/ACS/fileModel'); + +import TestConfig = require('./test.config'); +import resources = require('./util/resources'); + +import dateFormat = require('dateformat'); + +import AlfrescoApi = require('alfresco-js-api-node'); +import { UsersActions } from './actions/users.actions'; +import { AppsActions } from './actions/APS/apps.actions'; + +import fs = require('fs'); +import path = require('path'); +import Util = require('./util/util'); + +describe('Start Task - Task App', () => { + + let loginPage = new LoginPage(); + let processServicesPage = new ProcessServicesPage(); + let processUserModel; + let app = resources.Files.SIMPLE_APP_WITH_USER_FORM; + let taskPage = new TasksPage(); + let taskTaskApp = 'Audit task task app'; + let taskCustomApp = 'Audit task custom app'; + let taskCompleteCustomApp = 'Audit completed task custom app'; + let auditLogFile = path.join('./e2e/download/', 'Audit.pdf'); + let appModel; + + beforeAll(async (done) => { + let users = new UsersActions(); + let apps = new AppsActions(); + + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: TestConfig.adf.url + }); + + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + let newTenant = await this.alfrescoJsApi.activiti.adminTenantsApi.createTenant(new Tenant()); + + processUserModel = await users.createApsUser(this.alfrescoJsApi, newTenant.id); + + await this.alfrescoJsApi.login(processUserModel.email, processUserModel.password); + + this.alfrescoJsApi.activiti.taskApi.createNewTask({name: taskTaskApp}); + + appModel = await apps.importPublishDeployApp(this.alfrescoJsApi, app.file_location); + + loginPage.loginToProcessServicesUsingUserModel(processUserModel); + + done(); + }); + + it('[C260386] Should Audit file be downloaded when clicking on Task Audit log icon on a standalone running task', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(taskTaskApp); + + taskPage.usingTaskDetails().clickAuditLogButton(); + expect(Util.fileExists(auditLogFile, 10)).toBe(true); + }); + + it('[C260389] Should Audit file be downloaded when clicking on Task Audit log icon on a standalone completed task', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(taskTaskApp); + + taskPage.completeTaskNoForm(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.COMPL_TASKS); + taskPage.usingTasksListPage().selectTaskFromTasksList(taskTaskApp); + expect(taskPage.usingFormFields().getCompletedTaskNoFormMessage()).toEqual('Task ' + taskTaskApp + ' completed'); + + taskPage.usingTaskDetails().clickAuditLogButton(); + expect(Util.fileExists(auditLogFile, 20)).toBe(true); + }); + + it('[C263944] Should Audit file be downloaded when clicking on Task Audit log icon on a custom app standalone completed task', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + + taskPage.createNewTask().addName(taskCompleteCustomApp).clickStartButton(); + + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(taskCompleteCustomApp); + + taskPage.completeTaskNoForm(); + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.COMPL_TASKS); + taskPage.usingTasksListPage().selectTaskFromTasksList(taskCompleteCustomApp); + expect(taskPage.usingFormFields().getCompletedTaskNoFormMessage()).toEqual('Task ' + taskCompleteCustomApp + ' completed'); + + taskPage.usingTaskDetails().clickAuditLogButton(); + expect(Util.fileExists(auditLogFile, 20)).toBe(true); + }); + + it('[C263943] Should Audit file be downloaded when clicking on Task Audit log icon on a custom app standalone running task', () => { + processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton(); + + taskPage.createNewTask().addName(taskCustomApp).clickStartButton(); + + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(taskCustomApp); + + taskPage.usingTaskDetails().clickAuditLogButton(); + expect(Util.fileExists(auditLogFile, 10)).toBe(true); + }); + +}); diff --git a/lib/core/form/components/widgets/people/people.widget.html b/lib/core/form/components/widgets/people/people.widget.html index e0d9dbebdc..6f8b14846c 100644 --- a/lib/core/form/components/widgets/people/people.widget.html +++ b/lib/core/form/components/widgets/people/people.widget.html @@ -7,6 +7,7 @@