alfresco-ng2-components/e2e/process-services/start_task_custom_app.e2e.ts
bbcodrin a801f656a7 [ADF-3422] Process Services - Create settings tab (#3702)
* settings tab added

* fix icon

* fix e2e
2018-09-18 16:09:09 +01:00

244 lines
12 KiB
TypeScript

/*!
* @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 { by } from 'protractor';
import LoginPage = require('../pages/adf/loginPage');
import ProcessServicesPage = require('../pages/adf/process_services/processServicesPage');
import TasksPage = require('../pages/adf/process_services/tasksPage');
import { AttachmentListPage } from '../pages/adf/process_services/attachmentListPage';
import AppNavigationBarPage = require('../pages/adf/process_services/appNavigationBarPage');
import Task = require('../models/APS/Task');
import Tenant = require('../models/APS/Tenant');
import TaskModel = require('../models/APS/TaskModel');
import FileModel = require('../models/ACS/fileModel');
import FormModel = require('../models/APS/FormModel');
import TestConfig = require('../test.config');
import resources = require('../util/resources');
import dateFormat = require('dateformat');
import AlfrescoApi = require('alfresco-js-api-node');
import { AppsActions } from '../actions/APS/apps.actions';
import { UsersActions } from '../actions/users.actions';
import CONSTANTS = require('../util/constants');
describe('Start Task - Custom App', () => {
let TASKDATAFORMAT = 'mmm dd yyyy';
let loginPage = new LoginPage();
let processServicesPage = new ProcessServicesPage();
let attachmentListPage = new AttachmentListPage();
let appNavigationBarPage = new AppNavigationBarPage();
let processUserModel, assigneeUserModel;
let app = resources.Files.SIMPLE_APP_WITH_USER_FORM;
let formTextField = app.form_fields.form_fieldId;
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', 'Spinner'];
let showHeaderTask = 'Show Header';
let appModel;
let pngFile = new FileModel({
'location': resources.Files.ADF_DOCUMENTS.PNG.file_location,
'name': resources.Files.ADF_DOCUMENTS.PNG.file_name
});
beforeAll(async (done) => {
let apps = new AppsActions();
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());
assigneeUserModel = await users.createApsUser(this.alfrescoJsApi, newTenant.id);
processUserModel = await users.createApsUser(this.alfrescoJsApi, newTenant.id);
await this.alfrescoJsApi.login(processUserModel.email, processUserModel.password);
appModel = await apps.importPublishDeployApp(this.alfrescoJsApi, app.file_location);
loginPage.loginToProcessServicesUsingUserModel(processUserModel);
done();
});
it('[C263942] Modifying task', () => {
processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS);
taskPage.createNewTask().addName(tasks[0])
.addForm(app.formName).clickStartButton()
.then(() => {
taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[0]);
taskPage.usingTaskDetails().clickInvolvePeopleButton()
.typeUser(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName)
.selectUserToInvolve(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName)
.checkUserIsSelected(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName);
taskPage.usingTaskDetails().clickAddInvolvedUserButton();
expect(taskPage.usingTaskDetails().getInvolvedUserEmail(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName))
.toEqual(assigneeUserModel.email);
taskPage.usingTaskDetails().selectActivityTab().addComment(firstComment)
.checkCommentIsDisplayed(firstComment);
taskPage.clickOnAddChecklistButton().addName(firstChecklist).clickCreateChecklistButton();
taskPage.checkChecklistIsDisplayed(firstChecklist);
taskPage.usingTaskDetails().selectDetailsTab();
});
});
it('[C263946] Information box', () => {
processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS);
taskPage.createNewTask().addName(tasks[1]).addDescription('Description')
.addForm(app.formName).clickStartButton()
.then(() => {
expect(taskPage.usingTaskDetails().getTitle()).toEqual('Activities');
})
.then(() => {
return this.alfrescoJsApi.activiti.taskApi.listTasks(new Task({ sort: 'created-desc' }));
})
.then((response) => {
let taskModel = new TaskModel(response.data[0]);
taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(taskModel.getName());
expect(taskPage.usingTaskDetails().getCreated()).toEqual(dateFormat(taskModel.getCreated(), TASKDATAFORMAT));
expect(taskPage.usingTaskDetails().getId()).toEqual(taskModel.getId());
expect(taskPage.usingTaskDetails().getDescription()).toEqual(taskModel.getDescription());
expect(taskPage.usingTaskDetails().getAssignee()).toEqual(taskModel.getAssignee().getEntireName());
expect(taskPage.usingTaskDetails().getCategory())
.toEqual(taskModel.getCategory() === null ? CONSTANTS.TASKDETAILS.NO_CATEGORY : taskModel.getCategory());
expect(taskPage.usingTaskDetails().getDueDate())
.toEqual(taskModel.getDueDate() === null ? CONSTANTS.TASKDETAILS.NO_DATE : taskModel.getDueDate());
expect(taskPage.usingTaskDetails().getParentName())
.toEqual(taskModel.getParentTaskName() === null ? CONSTANTS.TASKDETAILS.NO_PARENT : taskModel.getParentTaskName());
expect(taskPage.usingTaskDetails().getStatus()).toEqual(CONSTANTS.TASKSTATUS.RUNNING);
return this.alfrescoJsApi.activiti.taskFormsApi.getTaskForm(response.data[0].id);
})
.then((response) => {
let formModel = new FormModel(response);
expect(taskPage.usingTaskDetails().getFormName())
.toEqual(formModel.getName() === null ? CONSTANTS.TASKDETAILS.NO_FORM : formModel.getName());
});
});
it('[C263947] Start task with no form', () => {
processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS);
taskPage.createNewTask().addName(tasks[2]).clickStartButton()
.then(() => {
taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[2]);
taskPage.usingFormFields().noFormIsDisplayed();
expect(taskPage.usingTaskDetails().getFormName()).toEqual(CONSTANTS.TASKDETAILS.NO_FORM);
});
});
it('[C263948] Start task buttons', () => {
processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS);
taskPage.createNewTask().checkStartButtonIsDisabled().addName(tasks[3])
.checkStartButtonIsEnabled().clickCancelButton()
.then(() => {
taskPage.usingTasksListPage().checkTaskIsNotDisplayedInTasksList(tasks[3]);
expect(taskPage.usingFiltersPage().getActiveFilter()).toEqual(CONSTANTS.TASKFILTERS.MY_TASKS);
});
});
it('[C263949] Refreshing the form', () => {
processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS);
taskPage.createNewTask()
.addForm(app.formName).addName(tasks[4]).clickStartButton()
.then(() => {
taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[4]);
expect(taskPage.usingFormFields().setFieldValue(by.id, formTextField, formFieldValue)
.getFieldValue(formTextField)).toEqual(formFieldValue);
taskPage.usingFormFields().refreshForm().checkFieldValue(by.id, formTextField, '');
taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[4]);
taskPage.usingFormFields().setFieldValue(by.id, formTextField, formFieldValue)
.checkFieldValue(by.id, formTextField, formFieldValue);
taskPage.usingFormFields().saveForm().checkFieldValue(by.id, formTextField, formFieldValue);
});
});
it('[C263951] Assign User', () => {
processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS);
taskPage.createNewTask().addName(tasks[5]).addAssignee(assigneeUserModel.firstName).clickStartButton()
.then(() => {
taskPage.usingTasksListPage().checkTaskListIsLoaded();
taskPage.usingTasksListPage().waitForTableBody();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.INV_TASKS);
taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(tasks[5]).selectTaskFromTasksList(tasks[5]);
taskPage.checkTaskTitle(tasks[5]);
expect(taskPage.usingTaskDetails().getAssignee()).toEqual(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName);
});
});
it('Attach a file', () => {
processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS);
taskPage.createNewTask().addName(tasks[6]).clickStartButton()
.then(() => {
attachmentListPage.clickAttachFileButton(pngFile.location);
attachmentListPage.checkFileIsAttached(pngFile.name);
});
});
it('[C263945] Should Information box be hidden when showHeaderContent property is set on false on custom app', () => {
processServicesPage.goToProcessServices().goToApp(appModel.name).clickTasksButton();
taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS);
taskPage.createNewTask().addName(showHeaderTask).clickStartButton();
taskPage.usingTasksListPage().checkTaskIsDisplayedInTasksList(showHeaderTask).selectTaskFromTasksList(showHeaderTask);
appNavigationBarPage.clickSettingsButton();
taskPage.usingTaskDetails().usingTaskDetailsToggles().disableShowHeader();
appNavigationBarPage.clickTasksButton();
taskPage.usingTaskDetails().taskInfoDrawerIsNotDisplayed();
appNavigationBarPage.clickSettingsButton();
taskPage.usingTaskDetails().usingTaskDetailsToggles().enableShowHeader();
appNavigationBarPage.clickTasksButton();
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();
});
});