Files
alfresco-ng2-components/e2e/process-services-cloud/start-task/start-task-custom-app-cloud.e2e.ts
Eugenio Romano a78f24ada1 [ACS-259] refactor login page (#5733)
* refator login page

* refator login page

* remove obsolete classes and move what is needed in the test pck

* fix const

* revert modify

* remove duplicate browser property

* fix build

* fix

* fix

* fix lint

* move drop action in testing
remove not necessary space
js-api centralize content

* first refactor use js-api

* fix protractor

* refactor test config

* simplify properties
fix namings

* ps cloud simplify
remove unused js files

* id fix

* fix search test
simplify environment var step 1

* fix lint

* first user iteration fix

* fix model

* unify use of apiService

* first step automatic user creation Identity

* refactor creation user content-services

* refactor creation user search

* refactor creation user core

* process service refactoring 1

* process service refactoring 1

* process service refactoring 2

* fix process

* appconfig

* fix process util

* fix gallery

* fix "this" reference issues

* fix incorrect import paths

* fix core

* some fixes

* allign

* fix some test
remove structure folder and move in actions

* fixes

* move folders in the right place

* fix

* fix rebase

* solve build issue

* fix e2e

* change init aae

* order api and some fixes

* fix possible not valid password

* fix some ps test

* replace host port also in objects

* Update app-config.service.ts

* fix process

* fix process test

* process service cloud fix

* fiexs

* modify init script

* fix two test

* remove unused property

* host issue

* not use npx

* fix ps cloud test

Co-authored-by: Denys Vuika <denys.vuika@gmail.com>
2020-06-04 14:41:30 +01:00

222 lines
11 KiB
TypeScript

/*!
* @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 { browser } from 'protractor';
import { NavigationBarPage } from '../../pages/adf/navigation-bar.page';
import { TasksCloudDemoPage } from '../../pages/adf/demo-shell/process-services/tasks-cloud-demo.page';
import {
LoginSSOPage,
AppListCloudPage,
StringUtil,
TaskHeaderCloudPage,
StartTasksCloudPage,
PeopleCloudComponentPage,
TasksService,
ApiService,
IdentityService,
GroupIdentityService
} from '@alfresco/adf-testing';
describe('Start Task', () => {
const simpleApp = browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.name;
const loginSSOPage = new LoginSSOPage();
const taskHeaderCloudPage = new TaskHeaderCloudPage();
const navigationBarPage = new NavigationBarPage();
const appListCloudComponent = new AppListCloudPage();
const tasksCloudDemoPage = new TasksCloudDemoPage();
const startTask = new StartTasksCloudPage();
const peopleCloudComponent = new PeopleCloudComponentPage();
const apiService = new ApiService();
const identityService = new IdentityService(apiService);
const groupIdentityService = new GroupIdentityService(apiService);
const standaloneTaskName = StringUtil.generateRandomString(5);
const reassignTaskName = StringUtil.generateRandomString(5);
const unassignedTaskName = StringUtil.generateRandomString(5);
const taskName255Characters = StringUtil.generateRandomString(255);
const taskNameBiggerThen255Characters = StringUtil.generateRandomString(256);
const lengthValidationError = 'Length exceeded, 255 characters max.';
const requiredError = 'Field required';
const dateValidationError = 'Date format DD/MM/YYYY';
let apsUser, testUser, activitiUser, groupInfo;
beforeAll(async () => {
await apiService.login(browser.params.identityAdmin.email, browser.params.identityAdmin.password);
testUser = await identityService.createIdentityUserWithRole([identityService.ROLES.ACTIVITI_USER]);
apsUser = await identityService.createIdentityUserWithRole([identityService.ROLES.ACTIVITI_USER, identityService.ROLES.ACTIVITI_USER]);
activitiUser = await identityService.createIdentityUser();
groupInfo = await groupIdentityService.getGroupInfoByGroupName('hr');
await identityService.addUserToGroup(testUser.idIdentityService, groupInfo.id);
await identityService.addUserToGroup(apsUser.idIdentityService, groupInfo.id);
await apiService.login(testUser.email, testUser.password);
await loginSSOPage.login(testUser.email, testUser.password);
});
afterAll(async () => {
const tasksService = new TasksService(apiService);
let taskId = await tasksService.getTaskId(standaloneTaskName, simpleApp);
await tasksService.deleteTask(taskId, simpleApp);
taskId = await tasksService.getTaskId(unassignedTaskName, simpleApp);
await tasksService.deleteTask(taskId, simpleApp);
await apiService.login(apsUser.email, apsUser.password);
taskId = await tasksService.getTaskId(reassignTaskName, simpleApp);
await tasksService.deleteTask(taskId, simpleApp);
await apiService.login(browser.params.identityAdmin.email, browser.params.identityAdmin.password);
await identityService.deleteIdentityUser(activitiUser.idIdentityService);
await identityService.deleteIdentityUser(apsUser.idIdentityService);
await identityService.deleteIdentityUser(testUser.idIdentityService);
});
beforeEach(async () => {
await navigationBarPage.navigateToProcessServicesCloudPage();
await appListCloudComponent.checkApsContainer();
await appListCloudComponent.checkAppIsDisplayed(simpleApp);
await appListCloudComponent.goToApp(simpleApp);
await tasksCloudDemoPage.taskListCloudComponent().getDataTable().waitForTableBody();
});
it('[C297675] Should create a task unassigned when assignee field is empty in Start Task form', async () => {
await tasksCloudDemoPage.openNewTaskForm();
await startTask.checkFormIsDisplayed();
await peopleCloudComponent.clearAssigneeFromChip(testUser.username);
await startTask.addName(unassignedTaskName);
await startTask.clickStartButton();
await tasksCloudDemoPage.editTaskFilterCloudComponent();
await tasksCloudDemoPage.editTaskFilterCloudComponent().openFilter();
await tasksCloudDemoPage.editTaskFilterCloudComponent().clearAssignee();
await tasksCloudDemoPage.editTaskFilterCloudComponent().setStatusFilterDropDown('CREATED');
await tasksCloudDemoPage.taskListCloudComponent().getDataTable().waitForTableBody();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(unassignedTaskName);
const taskId = await tasksCloudDemoPage.taskListCloudComponent().getIdCellValue(unassignedTaskName);
await tasksCloudDemoPage.taskListCloudComponent().selectRow(unassignedTaskName);
await taskHeaderCloudPage.checkTaskPropertyListIsDisplayed();
await expect(await taskHeaderCloudPage.getId()).toBe(taskId);
await expect(await taskHeaderCloudPage.getAssignee()).toBe('No assignee');
});
it('[C291956] Should be able to create a new standalone task without assignee', async () => {
await tasksCloudDemoPage.openNewTaskForm();
await startTask.checkFormIsDisplayed();
await peopleCloudComponent.clearAssigneeFromChip(testUser.username);
await startTask.addName(unassignedTaskName);
await startTask.checkStartButtonIsEnabled();
await startTask.clickStartButton();
await tasksCloudDemoPage.editTaskFilterCloudComponent();
await tasksCloudDemoPage.editTaskFilterCloudComponent().openFilter();
await tasksCloudDemoPage.editTaskFilterCloudComponent().setStatusFilterDropDown('CREATED');
await tasksCloudDemoPage.editTaskFilterCloudComponent().clearAssignee();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(unassignedTaskName);
});
it('[C290166] Should be possible to cancel a task', async () => {
await tasksCloudDemoPage.openNewTaskForm();
await startTask.checkFormIsDisplayed();
await startTask.checkStartButtonIsDisabled();
await startTask.blur(await startTask.name);
await startTask.checkValidationErrorIsDisplayed(requiredError);
await startTask.addName(standaloneTaskName);
await startTask.addDescription('descriptions');
await startTask.addDueDate('12/12/2018');
await startTask.checkStartButtonIsEnabled();
await startTask.clickCancelButton();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsNotDisplayedByName(standaloneTaskName);
});
it('[C290180] Should be able to create a new standalone task', async () => {
await tasksCloudDemoPage.openNewTaskForm();
await startTask.checkFormIsDisplayed();
await startTask.addName(standaloneTaskName);
await startTask.addDescription('descriptions');
await startTask.addDueDate('12/12/2018');
await startTask.addPriority('50');
await startTask.clickStartButton();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(standaloneTaskName);
});
it('[C290181] Should be displayed an error message if task name exceed 255 characters', async () => {
await tasksCloudDemoPage.openNewTaskForm();
await startTask.checkFormIsDisplayed();
await startTask.addName(taskName255Characters);
await startTask.checkStartButtonIsEnabled();
await startTask.addName(taskNameBiggerThen255Characters);
await startTask.blur(await startTask.name);
await startTask.checkValidationErrorIsDisplayed(lengthValidationError);
await startTask.checkStartButtonIsDisabled();
await startTask.clickCancelButton();
});
it('[C291774] Should be displayed an error message if the date is invalid', async () => {
await tasksCloudDemoPage.openNewTaskForm();
await startTask.addDueDate('12/12/2018');
await startTask.checkStartButtonIsEnabled();
await startTask.addDueDate('invalid date');
await startTask.blur(await startTask.dueDate);
await startTask.validateDate(dateValidationError);
await startTask.checkStartButtonIsDisabled();
await startTask.clickCancelButton();
});
it('[C290182] Should be possible to assign the task to another user', async () => {
await tasksCloudDemoPage.openNewTaskForm();
await startTask.checkFormIsDisplayed();
await startTask.addName(standaloneTaskName);
await peopleCloudComponent.searchAssigneeAndSelect(`${apsUser.firstName} ${apsUser.lastName}`);
await startTask.checkStartButtonIsEnabled();
await startTask.clickStartButton();
await browser.driver.sleep(1000);
await tasksCloudDemoPage.taskFilterCloudComponent.clickTaskFilter('my-tasks');
await expect(await tasksCloudDemoPage.taskFilterCloudComponent.getActiveFilterName()).toBe('My Tasks');
});
it('[C305050] Should be able to reassign the removed user when starting a new task', async () => {
await tasksCloudDemoPage.openNewTaskForm();
await startTask.checkFormIsDisplayed();
await startTask.addName(reassignTaskName);
await peopleCloudComponent.checkSelectedPeople(`${testUser.firstName} ${testUser.lastName}`);
await peopleCloudComponent.searchAssignee(apsUser.username);
await peopleCloudComponent.checkUserIsDisplayed(`${apsUser.firstName} ${apsUser.lastName}`);
await peopleCloudComponent.selectAssigneeFromList(`${apsUser.firstName} ${apsUser.lastName}`);
await startTask.clickStartButton();
await tasksCloudDemoPage.editTaskFilterCloudComponent().openFilter();
await tasksCloudDemoPage.editTaskFilterCloudComponent().clearAssignee();
await tasksCloudDemoPage.editTaskFilterCloudComponent().setStatusFilterDropDown('ALL');
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(reassignTaskName);
await browser.driver.sleep(1000);
await tasksCloudDemoPage.taskListCloudComponent().selectRow(reassignTaskName);
await expect(await taskHeaderCloudPage.getAssignee()).toBe(apsUser.username);
});
});