From a0858e3c8677ec3710c651bc301c3e5d5f0cea14 Mon Sep 17 00:00:00 2001 From: arditdomi <32884230+arditdomi@users.noreply.github.com> Date: Thu, 17 Oct 2019 23:05:28 +0100 Subject: [PATCH] [ADF-4949] Add SUSPENDED state to the edit task filter (#5150) * [ADF-4949] Add SUSPENDED state to the edit task filter * [ADF-4949] Add unit test * [ADF-4949] change order of status filters * [ADF-4949] Change order of status filters * [ADF-4949] Remove unnecessary unit test * [ADF-4949] Add e2e for SUSPENDED filter * [ADF-4949] fix lint errors --- .../tasks-custom-filters.e2e.ts | 18 ++++++ .../edit-task-filter-cloud.component.spec.ts | 63 +++++++------------ .../edit-task-filter-cloud.component.ts | 3 +- 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/e2e/process-services-cloud/tasks-custom-filters.e2e.ts b/e2e/process-services-cloud/tasks-custom-filters.e2e.ts index c1da15c3af..da7043ae35 100644 --- a/e2e/process-services-cloud/tasks-custom-filters.e2e.ts +++ b/e2e/process-services-cloud/tasks-custom-filters.e2e.ts @@ -171,5 +171,23 @@ describe('Task filters cloud', () => { await tasksCloudDemoPage.taskListCloudComponent().checkContentIsNotDisplayedByName(completedTaskName); await tasksCloudDemoPage.taskListCloudComponent().checkContentIsNotDisplayedByName(createdTaskName); }); + + it('[C317658] Should display only tasks with Suspended status when SUSPENDED is selected from status dropdown', async () => { + const processDefinition = await processDefinitionService + .getProcessDefinitionByName(browser.params.resources.ACTIVITI7_APPS.SIMPLE_APP.processes.dropdownrestprocess, simpleApp); + + const processInstance = await processInstancesService.createProcessInstance(processDefinition.entry.key, simpleApp); + + const taskAssigned = await queryService.getProcessInstanceTasks(processInstance.entry.id, simpleApp); + + await processInstancesService.suspendProcessInstance(processInstance.entry.id, simpleApp); + + await tasksCloudDemoPage.editTaskFilterCloudComponent().openFilter(); + await tasksCloudDemoPage.editTaskFilterCloudComponent().clearAssignee(); + await tasksCloudDemoPage.editTaskFilterCloudComponent().setStatusFilterDropDown('SUSPENDED'); + + await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(taskAssigned.list.entries[0].entry.name); + + }); }); }); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.spec.ts index 4199ff5524..9d44426800 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.spec.ts @@ -31,7 +31,7 @@ import { TaskFiltersCloudModule } from '../task-filters-cloud.module'; import { EditTaskFilterCloudComponent } from './edit-task-filter-cloud.component'; import { TaskFilterCloudService } from '../services/task-filter-cloud.service'; import { TaskFilterDialogCloudComponent } from './task-filter-dialog-cloud.component'; -import { fakeFilter, fakeAllTaskFilter } from '../mock/task-filters-cloud.mock'; +import { fakeFilter } from '../mock/task-filters-cloud.mock'; import { AbstractControl } from '@angular/forms'; import moment from 'moment-es6'; @@ -74,7 +74,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should fetch task filter by taskId', () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); fixture.whenStable().then(() => { expect(getTaskFilterSpy).toHaveBeenCalled(); @@ -88,7 +88,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display filter name as title', async(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); const title = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-title-id'); const subTitle = fixture.debugElement.nativeElement.querySelector('#adf-edit-task-filter-sub-title-id'); @@ -132,12 +132,12 @@ describe('EditTaskFilterCloudComponent', () => { beforeEach(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); }); it('should defined editTaskFilter form ', () => { - expect(component.editTaskFilterForm).toBeDefined(); + expect(component.editTaskFilterForm).toBeDefined(); }); it('should create editTaskFilter form with default properties', async(() => { @@ -214,27 +214,7 @@ describe('EditTaskFilterCloudComponent', () => { }); })); - it('should display status drop down', async(() => { - fixture.detectChanges(); - const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); - expansionPanel.click(); - fixture.detectChanges(); - const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-status"] .mat-select-trigger'); - stateElement.click(); - fixture.detectChanges(); - fixture.whenStable().then(() => { - const statusOptions = fixture.debugElement.queryAll(By.css('.mat-option-text')); - expect(statusOptions.length).toEqual(5); - }); - })); - - it('should select \'All\' option in Task Status if All filter is set', async(() => { - - getTaskFilterSpy.and.returnValue(of(fakeAllTaskFilter)); - - const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); - fixture.detectChanges(); + it('should display all the statuses that are defined in the task filter', async(() => { const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -244,9 +224,14 @@ describe('EditTaskFilterCloudComponent', () => { stateElement.click(); fixture.detectChanges(); - fixture.whenStable().then(() => { - expect(stateElement.textContent.trim()).toBe('ALL'); - }); + const statusOptions = fixture.debugElement.queryAll(By.css('[data-automation-id="adf-cloud-edit-task-property-options-status"]')); + + expect(statusOptions[0].nativeElement.textContent.trim()).toBe('ALL'); + expect(statusOptions[1].nativeElement.textContent.trim()).toBe('CREATED'); + expect(statusOptions[2].nativeElement.textContent.trim()).toBe('ASSIGNED'); + expect(statusOptions[3].nativeElement.textContent.trim()).toBe('SUSPENDED'); + expect(statusOptions[4].nativeElement.textContent.trim()).toBe('CANCELLED'); + expect(statusOptions[5].nativeElement.textContent.trim()).toBe('COMPLETED'); })); it('should display sort drop down', async(() => { @@ -279,7 +264,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should able to build a editTaskFilter form with default properties if input is empty', async(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); component.filterProperties = []; fixture.detectChanges(); const stateController = component.editTaskFilterForm.get('status'); @@ -303,7 +288,7 @@ describe('EditTaskFilterCloudComponent', () => { component.filterProperties = ['appName', 'processInstanceId', 'priority']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); const appController = component.editTaskFilterForm.get('appName'); fixture.detectChanges(); fixture.whenStable().then(() => { @@ -318,7 +303,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display default sort properties', async(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -344,7 +329,7 @@ describe('EditTaskFilterCloudComponent', () => { })); fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -365,7 +350,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display default sort properties if input is empty', async(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); component.sortProperties = []; fixture.detectChanges(); @@ -390,7 +375,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display default filter actions', async(() => { component.toggleFilterActions = true; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -414,7 +399,7 @@ describe('EditTaskFilterCloudComponent', () => { component.actions = ['save']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; fixture.detectChanges(); @@ -434,7 +419,7 @@ describe('EditTaskFilterCloudComponent', () => { component.toggleFilterActions = true; component.actions = []; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -458,7 +443,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'lastModified']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); const lastModifiedToControl: AbstractControl = component.editTaskFilterForm.get('lastModifiedTo'); @@ -482,7 +467,7 @@ describe('EditTaskFilterCloudComponent', () => { beforeEach(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange}); + component.ngOnChanges({ 'id': taskFilterIdChange }); fixture.detectChanges(); }); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts index 1af2d88679..7a68ad602b 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts @@ -92,8 +92,9 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro status = [ { label: 'ALL', value: '' }, { label: 'CREATED', value: 'CREATED' }, - { label: 'CANCELLED', value: 'CANCELLED' }, { label: 'ASSIGNED', value: 'ASSIGNED' }, + { label: 'SUSPENDED', value: 'SUSPENDED' }, + { label: 'CANCELLED', value: 'CANCELLED' }, { label: 'COMPLETED', value: 'COMPLETED' } ];