Files
alfresco-ng2-components/e2e/process-services-cloud/process-custom-filters.e2e.ts
Denys Vuika f8526c4dc0 [AAE-4379] i18n fixes (#6515)
* add missing translations

* add missing translations

* fix unit tests

* reduce overhead

* update e2e

* update e2e

* cleanup e2e

* cleanup e2e

* cleanup e2e

* update e2e

* update e2e

* update code

* update code

* update code

* update code

* code fixes

* code fixes

* code fixes
2021-01-11 09:30:45 +00:00

305 lines
16 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 {
ApiService,
AppListCloudPage,
BrowserActions,
FilterProps,
GroupIdentityService,
IdentityService,
LocalStorageUtil,
LoginPage,
ProcessDefinitionsService,
ProcessInstancesService,
QueryService,
StringUtil,
TasksService
} from '@alfresco/adf-testing';
import { browser } from 'protractor';
import { ProcessCloudDemoPage } from './pages/process-cloud-demo.page';
import { TasksCloudDemoPage } from './pages/tasks-cloud-demo.page';
import { NavigationBarPage } from '../core/pages/navigation-bar.page';
import { EditProcessFilterConfiguration } from './config/edit-process-filter.config';
import { ProcessListCloudConfiguration } from './config/process-list-cloud.config';
describe('Process list cloud', () => {
// en-US values for the process status
const PROCESS_STATUS = {
ALL: 'All',
RUNNING: 'Running',
SUSPENDED: 'Suspended',
COMPLETED: 'Completed'
};
// en-US values for the sort direction
const SORT_DIRECTION = {
ASC: 'Ascending',
DESC: 'Descending'
};
describe('Process List', () => {
const loginSSOPage = new LoginPage();
const navigationBarPage = new NavigationBarPage();
const appListCloudComponent = new AppListCloudPage();
const processCloudDemoPage = new ProcessCloudDemoPage();
const editProcessFilter = processCloudDemoPage.editProcessFilterCloudComponent();
const processList = processCloudDemoPage.processListCloudComponent();
const tasksCloudDemoPage = new TasksCloudDemoPage();
const apiService = new ApiService();
const identityService = new IdentityService(apiService);
const groupIdentityService = new GroupIdentityService(apiService);
const processDefinitionService = new ProcessDefinitionsService(apiService);
const processInstancesService = new ProcessInstancesService(apiService);
const queryService = new QueryService(apiService);
const tasksService = new TasksService(apiService);
const processListCloudConfiguration = new ProcessListCloudConfiguration();
const editProcessFilterConfiguration = new EditProcessFilterConfiguration();
const processListCloudConfigFile = processListCloudConfiguration.getConfiguration();
const editProcessFilterConfigFile = editProcessFilterConfiguration.getConfiguration();
let completedProcess, runningProcessInstance, switchProcessInstance, noOfApps, testUser, groupInfo,
anotherProcessInstance;
const candidateBaseApp = browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.name;
beforeAll(async () => {
await apiService.loginWithProfile('identityAdmin');
testUser = await identityService.createIdentityUserWithRole( [identityService.ROLES.ACTIVITI_USER]);
groupInfo = await groupIdentityService.getGroupInfoByGroupName('hr');
await identityService.addUserToGroup(testUser.idIdentityService, groupInfo.id);
await apiService.login(testUser.username, testUser.password);
const processDefinition = await processDefinitionService
.getProcessDefinitionByName(browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.processes.candidateGroupProcess, candidateBaseApp);
const anotherProcessDefinition = await processDefinitionService
.getProcessDefinitionByName(browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.processes.anotherCandidateGroupProcess, candidateBaseApp);
await processInstancesService.createProcessInstance(processDefinition.entry.key, candidateBaseApp);
runningProcessInstance = await processInstancesService.createProcessInstance(processDefinition.entry.key, candidateBaseApp, {
'name': StringUtil.generateRandomString(),
'businessKey': StringUtil.generateRandomString()
});
anotherProcessInstance = await processInstancesService.createProcessInstance(anotherProcessDefinition.entry.key, candidateBaseApp, {
'name': StringUtil.generateRandomString(),
'businessKey': StringUtil.generateRandomString()
});
switchProcessInstance = await processInstancesService.createProcessInstance(processDefinition.entry.key, candidateBaseApp, {
'name': StringUtil.generateRandomString(),
'businessKey': StringUtil.generateRandomString()
});
completedProcess = await processInstancesService.createProcessInstance(processDefinition.entry.key, candidateBaseApp, {
'name': StringUtil.generateRandomString(),
'businessKey': StringUtil.generateRandomString()
});
const task = await queryService.getProcessInstanceTasks(completedProcess.entry.id, candidateBaseApp);
const claimedTask = await tasksService.claimTask(task.list.entries[0].entry.id, candidateBaseApp);
await tasksService.completeTask(claimedTask.entry.id, candidateBaseApp);
await loginSSOPage.login(testUser.username, testUser.password);
await LocalStorageUtil.setConfigField('adf-edit-process-filter', JSON.stringify(editProcessFilterConfigFile));
await LocalStorageUtil.setConfigField('adf-cloud-process-list', JSON.stringify(processListCloudConfigFile));
});
afterAll(async () => {
await apiService.login(testUser.username, testUser.password);
await processInstancesService.deleteProcessInstance(anotherProcessInstance.entry.id, candidateBaseApp);
await apiService.loginWithProfile('identityAdmin');
await identityService.deleteIdentityUser(testUser.idIdentityService);
});
beforeEach(async () => {
await navigationBarPage.navigateToProcessServicesCloudPage();
await appListCloudComponent.checkApsContainer();
await appListCloudComponent.goToApp(candidateBaseApp);
await tasksCloudDemoPage.taskListCloudComponent().checkTaskListIsLoaded();
await processCloudDemoPage.processFilterCloudComponent.clickOnProcessFilters();
});
function setFilter(props: FilterProps): Promise<void> {
return editProcessFilter.setFilter(props);
}
async function waitTillContentLoaded() {
await processList.getDataTable().waitTillContentLoaded();
}
it('[C290069] Should display processes ordered by name when Name is selected from sort dropdown', async () => {
await setFilter({ status: PROCESS_STATUS.RUNNING, sort: 'Name', order: SORT_DIRECTION.ASC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Name')).toBe(true);
await setFilter({ order: SORT_DIRECTION.DESC});
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Name')).toBe(true);
});
it('[C291783] Should display processes ordered by id when Id is selected from sort dropdown', async () => {
await setFilter({ status: PROCESS_STATUS.RUNNING, sort: 'Id', order: SORT_DIRECTION.ASC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Id')).toBe(true);
await setFilter({ order: SORT_DIRECTION.DESC});
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.DESC, 'Id')).toBe(true);
});
it('[C305054] Should display processes ordered by status when Status is selected from sort dropdown', async () => {
await setFilter({ status: PROCESS_STATUS.ALL, sort: 'Status', order: SORT_DIRECTION.ASC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Status')).toBe(true);
await setFilter({ order: SORT_DIRECTION.DESC});
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.DESC, 'Status')).toBe(true);
});
it('[C305054] Should display processes ordered by started by when Started By is selected from sort dropdown', async () => {
await setFilter({ status: PROCESS_STATUS.ALL, sort: 'Started by', order: SORT_DIRECTION.ASC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Started by')).toBe(true);
await setFilter({ order: SORT_DIRECTION.DESC});
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.DESC, 'Started by')).toBe(true);
});
it('[C305054] Should display processes ordered by processdefinitionid date when ProcessDefinitionId is selected from sort dropdown', async () => {
await setFilter({ status: PROCESS_STATUS.ALL, sort: 'ProcessDefinitionId', order: SORT_DIRECTION.ASC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Process Definition Id')).toBe(true);
await setFilter({ order: SORT_DIRECTION.DESC});
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.DESC, 'Process Definition Id')).toBe(true);
});
it('[C305054] Should display processes ordered by processdefinitionkey date when ProcessDefinitionKey is selected from sort dropdown', async () => {
await setFilter({ status: PROCESS_STATUS.ALL, sort: 'ProcessDefinitionKey', order: SORT_DIRECTION.ASC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Process Definition Key')).toBe(true);
await setFilter({ order: SORT_DIRECTION.DESC});
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.DESC, 'Process Definition Key')).toBe(true);
});
it('[C305054] Should display processes ordered by last modified date when Last Modified is selected from sort dropdown', async () => {
await setFilter({ status: PROCESS_STATUS.ALL, sort: 'Last Modified', order: SORT_DIRECTION.ASC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Last Modified')).toBe(true);
await setFilter({ order: SORT_DIRECTION.DESC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.DESC, 'Last Modified')).toBe(true);
});
it('[C305054] Should display processes ordered by business key date when BusinessKey is selected from sort dropdown', async () => {
await setFilter({ status: PROCESS_STATUS.ALL, sort: 'Business Key', order: SORT_DIRECTION.ASC });
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Business Key')).toBe(true);
await setFilter({ order: SORT_DIRECTION.DESC});
await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.DESC, 'Business Key')).toBe(true);
});
it('[C297697] The value of the filter should be preserved when saving it', async () => {
await processCloudDemoPage.processFilterCloudComponent.clickAllProcessesFilter();
await editProcessFilter.openFilter();
await editProcessFilter.setProcessInstanceId(completedProcess.entry.id);
await editProcessFilter.clickSaveAsButton();
await editProcessFilter.editProcessFilterDialog().setFilterName('New');
await editProcessFilter.editProcessFilterDialog().clickOnSaveButton();
await expect(await processCloudDemoPage.processFilterCloudComponent.getActiveFilterName()).toBe('New');
await processList.checkContentIsDisplayedById(completedProcess.entry.id);
await expect(await processList.getDataTable().numberOfRows()).toBe(1);
await editProcessFilter.openFilter();
await expect(await editProcessFilter.getProcessInstanceId()).toEqual(completedProcess.entry.id);
});
it('[C297646] Should display the filter dropdown fine , after switching between saved filters', async () => {
await editProcessFilter.openFilter();
noOfApps = await editProcessFilter.getNumberOfAppNameOptions();
await expect(await editProcessFilter.checkAppNamesAreUnique()).toBe(true);
await BrowserActions.closeMenuAndDialogs();
await editProcessFilter.setStatusFilterDropDown(PROCESS_STATUS.RUNNING);
await editProcessFilter.setAppNameDropDown(candidateBaseApp);
await editProcessFilter.setProcessInstanceId(runningProcessInstance.entry.id);
await waitTillContentLoaded();
await processList.checkContentIsDisplayedById(runningProcessInstance.entry.id);
await expect(await editProcessFilter.getNumberOfAppNameOptions()).toBe(noOfApps);
await expect(await editProcessFilter.checkAppNamesAreUnique()).toBe(true);
await BrowserActions.closeMenuAndDialogs();
await editProcessFilter.clickSaveAsButton();
await editProcessFilter.editProcessFilterDialog().setFilterName('SavedFilter');
await editProcessFilter.editProcessFilterDialog().clickOnSaveButton();
await expect(await processCloudDemoPage.processFilterCloudComponent.getActiveFilterName()).toBe('SavedFilter');
await editProcessFilter.openFilter();
await expect(await editProcessFilter.getProcessInstanceId()).toEqual(runningProcessInstance.entry.id);
await editProcessFilter.setStatusFilterDropDown(PROCESS_STATUS.RUNNING);
await editProcessFilter.setAppNameDropDown(candidateBaseApp);
await editProcessFilter.setProcessInstanceId(switchProcessInstance.entry.id);
await waitTillContentLoaded();
await processList.checkContentIsDisplayedById(switchProcessInstance.entry.id);
await editProcessFilter.clickSaveAsButton();
await editProcessFilter.editProcessFilterDialog().setFilterName('SwitchFilter');
await editProcessFilter.editProcessFilterDialog().clickOnSaveButton();
await expect(await processCloudDemoPage.processFilterCloudComponent.getActiveFilterName()).toBe('SwitchFilter');
await editProcessFilter.openFilter();
await expect(await editProcessFilter.getProcessInstanceId()).toEqual(switchProcessInstance.entry.id);
await expect(await editProcessFilter.getNumberOfAppNameOptions()).toBe(noOfApps);
await expect(await editProcessFilter.checkAppNamesAreUnique()).toBe(true);
await BrowserActions.closeMenuAndDialogs();
});
});
});