mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[AAE-11992] fix processInstanceId filter empty: set taskFilter as input to check for the processInstanceId changes to set the filter (#8128)
This commit is contained in:
parent
3ab91806c3
commit
93edda2263
@ -117,7 +117,9 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
|||||||
label: 'ADF_CLOUD_TASK_FILTERS.STATUS.ALL'
|
label: 'ADF_CLOUD_TASK_FILTERS.STATUS.ALL'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Input()
|
||||||
taskFilter: T;
|
taskFilter: T;
|
||||||
|
|
||||||
changedTaskFilter: T;
|
changedTaskFilter: T;
|
||||||
|
|
||||||
/** Emitted when a task filter property changes. */
|
/** Emitted when a task filter property changes. */
|
||||||
@ -145,8 +147,12 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
const id = changes['id'];
|
const { id, taskFilter } = changes;
|
||||||
if (id && id.currentValue !== id.previousValue) {
|
if(taskFilter && taskFilter.currentValue?.processInstanceId !== taskFilter.previousValue?.processInstanceId){
|
||||||
|
this.taskFilterProperties = this.createAndFilterProperties();
|
||||||
|
this.taskFilterActions = this.createAndFilterActions();
|
||||||
|
this.buildForm(this.taskFilterProperties);
|
||||||
|
} else if (id && id.currentValue !== id.previousValue) {
|
||||||
this.retrieveTaskFilterAndBuildForm();
|
this.retrieveTaskFilterAndBuildForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,12 @@ import {
|
|||||||
mockDateFilterStartEnd,
|
mockDateFilterStartEnd,
|
||||||
mockDefaultTaskFilter,
|
mockDefaultTaskFilter,
|
||||||
mockDueDateFilter,
|
mockDueDateFilter,
|
||||||
mockTaskFilterIdChange
|
mockTaskFilterIdChange,
|
||||||
|
mockTaskFilterProcessInstanceIdChange,
|
||||||
|
mockTaskFilterProcessInstanceIdChangeToNull,
|
||||||
|
mockTaskFilterProcessInstanceIdNotChanged,
|
||||||
|
mockTaskFilterWithProcessInstanceId2,
|
||||||
|
mockTaskFilterWithProcessInstanceIdNull
|
||||||
} from '../../mock/edit-task-filter-cloud.mock';
|
} from '../../mock/edit-task-filter-cloud.mock';
|
||||||
import { mockFoodUsers } from '../../../../people/mock/people-cloud.mock';
|
import { mockFoodUsers } from '../../../../people/mock/people-cloud.mock';
|
||||||
import { mockFoodGroups } from '../../../../group/mock/group-cloud.mock';
|
import { mockFoodGroups } from '../../../../group/mock/group-cloud.mock';
|
||||||
@ -114,6 +119,66 @@ describe('EditTaskFilterCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('processInstanceId filter', () => {
|
||||||
|
|
||||||
|
const cssSelector = {
|
||||||
|
processInstanceIdInput: '[data-automation-id="adf-cloud-edit-task-property-processInstanceId"]'
|
||||||
|
};
|
||||||
|
|
||||||
|
function expandFilterPanel(){
|
||||||
|
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
|
||||||
|
expansionPanel.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProcessInstanceIdInputElement(){
|
||||||
|
return fixture.debugElement.query(By.css(cssSelector.processInstanceIdInput)).nativeElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
it('should set processInstanceId filter when processInstanceId changes', () => {
|
||||||
|
component.taskFilter = mockTaskFilterWithProcessInstanceId2;
|
||||||
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges({ taskFilter: mockTaskFilterProcessInstanceIdChange});
|
||||||
|
fixture.detectChanges();
|
||||||
|
expandFilterPanel();
|
||||||
|
expect(getTaskFilterSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getProcessInstanceIdInputElement().value).toEqual('fakeProcessInstance-2');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should processInstanceId filter be empty string if taskFilter processInstanceId change to null', () => {
|
||||||
|
component.taskFilter = mockTaskFilterWithProcessInstanceIdNull;
|
||||||
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges({ taskFilter: mockTaskFilterProcessInstanceIdChangeToNull});
|
||||||
|
fixture.detectChanges();
|
||||||
|
expandFilterPanel();
|
||||||
|
expect(getTaskFilterSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getProcessInstanceIdInputElement().value).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should processInstanceId filter be empty string if id of the task filter is changed', () => {
|
||||||
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges({ id: mockTaskFilterIdChange });
|
||||||
|
fixture.detectChanges();
|
||||||
|
expandFilterPanel();
|
||||||
|
expect(getTaskFilterSpy).toHaveBeenCalled();
|
||||||
|
expect(getProcessInstanceIdInputElement().value).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should processInstanceId filter be empty string if id of the task filter is changed', () => {
|
||||||
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges({ id: mockTaskFilterIdChange, taskFilter: mockTaskFilterProcessInstanceIdNotChanged });
|
||||||
|
fixture.detectChanges();
|
||||||
|
expandFilterPanel();
|
||||||
|
expect(getTaskFilterSpy).toHaveBeenCalled();
|
||||||
|
expect(getProcessInstanceIdInputElement().value).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
it('should fetch process definitions when processDefinitionName filter property is set', async () => {
|
it('should fetch process definitions when processDefinitionName filter property is set', async () => {
|
||||||
const processSpy = spyOn(taskService, 'getProcessDefinitions').and.returnValue(of([new ProcessDefinitionCloud({ id: 'fake-id', name: 'fake-name' })]));
|
const processSpy = spyOn(taskService, 'getProcessDefinitions').and.returnValue(of([new ProcessDefinitionCloud({ id: 'fake-id', name: 'fake-name' })]));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@ -29,6 +29,28 @@ export const mockAlfrescoApi: any = {
|
|||||||
|
|
||||||
export const mockTaskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
export const mockTaskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||||
|
|
||||||
|
export const mockTaskFilterWithProcessInstanceId1: any = { id: 'fakeId-1', processInstanceId: 'fakeProcessInstance-1', appName: 'fakeAppName', sort: 'startDate', order: 'DESC' };
|
||||||
|
export const mockTaskFilterWithProcessInstanceId2: any = { ...mockTaskFilterWithProcessInstanceId1, processInstanceId: 'fakeProcessInstance-2' };
|
||||||
|
export const mockTaskFilterWithProcessInstanceIdNull: any = { ...mockTaskFilterWithProcessInstanceId1, processInstanceId: null };
|
||||||
|
|
||||||
|
export const mockTaskFilterProcessInstanceIdChange = new SimpleChange(
|
||||||
|
mockTaskFilterWithProcessInstanceId1,
|
||||||
|
mockTaskFilterWithProcessInstanceId2,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
export const mockTaskFilterProcessInstanceIdNotChanged = new SimpleChange(
|
||||||
|
mockTaskFilterWithProcessInstanceId1,
|
||||||
|
mockTaskFilterWithProcessInstanceId1,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
export const mockTaskFilterProcessInstanceIdChangeToNull = new SimpleChange(
|
||||||
|
mockTaskFilterWithProcessInstanceId1,
|
||||||
|
mockTaskFilterWithProcessInstanceIdNull,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
export const mockDefaultTaskFilter = {
|
export const mockDefaultTaskFilter = {
|
||||||
name: 'ADF_CLOUD_TASK_FILTERS.MY_TASKS',
|
name: 'ADF_CLOUD_TASK_FILTERS.MY_TASKS',
|
||||||
id: 'filter-id',
|
id: 'filter-id',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user