mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
200 lines
9.7 KiB
TypeScript
200 lines
9.7 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 } from '../pages/adf/loginPage';
|
|
import { TasksPage } from '../pages/adf/process-services/tasksPage';
|
|
import { AttachmentListPage } from '../pages/adf/process-services/attachmentListPage';
|
|
import { AppNavigationBarPage } from '../pages/adf/process-services/appNavigationBarPage';
|
|
import { NavigationBarPage } from '../pages/adf/navigationBarPage';
|
|
|
|
import CONSTANTS = require('../util/constants');
|
|
|
|
import { Tenant } from '../models/APS/tenant';
|
|
import { FileModel } from '../models/ACS/fileModel';
|
|
|
|
import TestConfig = require('../test.config');
|
|
import resources = require('../util/resources');
|
|
|
|
import AlfrescoApi = require('alfresco-js-api-node');
|
|
import { UsersActions } from '../actions/users.actions';
|
|
import { Util } from '../util/util';
|
|
import fs = require('fs');
|
|
import path = require('path');
|
|
|
|
describe('Start Task - Task App', () => {
|
|
|
|
let loginPage = new LoginPage();
|
|
let attachmentListPage = new AttachmentListPage();
|
|
let appNavigationBarPage = new AppNavigationBarPage();
|
|
let navigationBarPage = new NavigationBarPage();
|
|
|
|
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';
|
|
const taskName255Characters = Util.generateRandomString(255);
|
|
const taskNameBiggerThen255Characters = Util.generateRandomString(256);
|
|
const lengthValidationError = 'Length exceeded, 255 characters max.';
|
|
let tasks = ['Modifying task', 'Information box', 'No form', 'Not Created', 'Refreshing form', 'Assignee task', 'Attach File'];
|
|
let showHeaderTask = 'Show Header';
|
|
let jpgFile = new FileModel({
|
|
'location': resources.Files.ADF_DOCUMENTS.JPG.file_location,
|
|
'name': resources.Files.ADF_DOCUMENTS.JPG.file_name
|
|
});
|
|
|
|
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());
|
|
|
|
assigneeUserModel = await users.createApsUser(this.alfrescoJsApi, newTenant.id);
|
|
|
|
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);
|
|
|
|
await this.alfrescoJsApi.activiti.taskApi.createNewTask({name: showHeaderTask});
|
|
|
|
loginPage.loginToProcessServicesUsingUserModel(processUserModel);
|
|
|
|
done();
|
|
});
|
|
|
|
it('[C260383] Should be possible to modify a task', () => {
|
|
navigationBarPage.navigateToProcessServicesPage().goToTaskApp().clickTasksButton();
|
|
taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
|
|
taskPage.createNewTask().addName(tasks[0])
|
|
.addForm(app.formName).clickStartButton()
|
|
.then(() => {
|
|
taskPage.tasksListPage().getDataTable().checkContentIsDisplayed(tasks[0]);
|
|
taskPage.taskDetails().clickInvolvePeopleButton()
|
|
.typeUser(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName)
|
|
.selectUserToInvolve(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName)
|
|
.checkUserIsSelected(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName);
|
|
taskPage.taskDetails().clickAddInvolvedUserButton();
|
|
expect(taskPage.taskDetails().getInvolvedUserEmail(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName))
|
|
.toEqual(assigneeUserModel.email);
|
|
taskPage.taskDetails().selectActivityTab().addComment(firstComment)
|
|
.checkCommentIsDisplayed(firstComment);
|
|
taskPage.clickOnAddChecklistButton().addName(firstChecklist).clickCreateChecklistButton();
|
|
taskPage.checkChecklistIsDisplayed(firstChecklist);
|
|
taskPage.taskDetails().selectDetailsTab();
|
|
});
|
|
});
|
|
|
|
it('[C260422] Should be possible to cancel a task', () => {
|
|
navigationBarPage.navigateToProcessServicesPage().goToTaskApp().clickTasksButton();
|
|
taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
|
|
taskPage.createNewTask().checkStartButtonIsDisabled().addName(tasks[3])
|
|
.checkStartButtonIsEnabled().clickCancelButton()
|
|
.then(() => {
|
|
taskPage.tasksListPage().getDataTable().checkContentIsNotDisplayed(tasks[3]);
|
|
expect(taskPage.filtersPage().getActiveFilter()).toEqual(CONSTANTS.TASK_FILTERS.MY_TASKS);
|
|
});
|
|
});
|
|
|
|
it('[C260423] Should be possible to save filled form', () => {
|
|
navigationBarPage.navigateToProcessServicesPage().goToTaskApp().clickTasksButton();
|
|
taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
|
|
taskPage.createNewTask()
|
|
.addForm(app.formName).addName(tasks[4]).clickStartButton()
|
|
.then(() => {
|
|
taskPage.tasksListPage().getDataTable().checkContentIsDisplayed(tasks[4]);
|
|
expect(taskPage.formFields().setFieldValue(by.id, formTextField, formFieldValue)
|
|
.getFieldValue(formTextField)).toEqual(formFieldValue);
|
|
taskPage.formFields().refreshForm().checkFieldValue(by.id, formTextField, '');
|
|
taskPage.tasksListPage().getDataTable().checkContentIsDisplayed(tasks[4]);
|
|
taskPage.formFields().setFieldValue(by.id, formTextField, formFieldValue)
|
|
.checkFieldValue(by.id, formTextField, formFieldValue);
|
|
taskPage.formFields().saveForm().checkFieldValue(by.id, formTextField, formFieldValue);
|
|
});
|
|
});
|
|
|
|
it('[C260425] Should be possible to assign a user', () => {
|
|
navigationBarPage.navigateToProcessServicesPage().goToTaskApp().clickTasksButton();
|
|
taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
|
|
taskPage.createNewTask().addName(tasks[5])
|
|
.addAssignee(assigneeUserModel.firstName).clickStartButton()
|
|
.then(() => {
|
|
taskPage.tasksListPage().checkTaskListIsLoaded();
|
|
taskPage.tasksListPage().getDataTable().waitForTableBody();
|
|
taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.INV_TASKS);
|
|
taskPage.tasksListPage().getDataTable().checkContentIsDisplayed(tasks[5]).selectRowByContentName(tasks[5]);
|
|
taskPage.checkTaskTitle(tasks[5]);
|
|
expect(taskPage.taskDetails().getAssignee()).toEqual(assigneeUserModel.firstName + ' ' + assigneeUserModel.lastName);
|
|
});
|
|
});
|
|
|
|
it('Attach a file', () => {
|
|
navigationBarPage.navigateToProcessServicesPage().goToTaskApp().clickTasksButton();
|
|
taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
|
|
taskPage.createNewTask().addName(tasks[6]).clickStartButton()
|
|
.then(() => {
|
|
attachmentListPage.clickAttachFileButton(jpgFile.location);
|
|
attachmentListPage.checkFileIsAttached(jpgFile.name);
|
|
});
|
|
});
|
|
|
|
it('[C260420] Should Information box be hidden when showHeaderContent property is set on false', () => {
|
|
navigationBarPage.navigateToProcessServicesPage().goToTaskApp().clickTasksButton();
|
|
taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
|
|
taskPage.tasksListPage().getDataTable().checkContentIsDisplayed(showHeaderTask);
|
|
|
|
appNavigationBarPage.clickSettingsButton();
|
|
taskPage.taskDetails().appSettingsToggles().disableShowHeader();
|
|
appNavigationBarPage.clickTasksButton();
|
|
|
|
taskPage.taskDetails().taskInfoDrawerIsNotDisplayed();
|
|
|
|
appNavigationBarPage.clickSettingsButton();
|
|
taskPage.taskDetails().appSettingsToggles().enableShowHeader();
|
|
appNavigationBarPage.clickTasksButton();
|
|
|
|
taskPage.taskDetails().taskInfoDrawerIsDisplayed();
|
|
});
|
|
|
|
xit('[C260424] Should be able to see Spinner loading on task list when clicking on Tasks', () => {
|
|
navigationBarPage.navigateToProcessServicesPage().goToTaskApp();
|
|
taskPage.tasksListPage().getDataTable().checkSpinnerIsDisplayed();
|
|
});
|
|
|
|
it('[C291780] Should be displayed an error message if task name exceed 255 characters', () => {
|
|
navigationBarPage.navigateToProcessServicesPage().goToTaskApp().clickTasksButton();
|
|
taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
|
|
const startDialog = taskPage.createNewTask().addName(taskName255Characters).checkStartButtonIsEnabled();
|
|
startDialog.addName(taskNameBiggerThen255Characters).blur(startDialog.name).checkValidationErrorIsDisplayed(lengthValidationError).checkStartButtonIsDisabled();
|
|
|
|
});
|
|
|
|
});
|