mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-5328] - fix error on replacing priority values (#6630)
This commit is contained in:
@@ -257,10 +257,10 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme
|
|||||||
|
|
||||||
replacePriorityValues(row: DataRow, column: DataColumn) {
|
replacePriorityValues(row: DataRow, column: DataColumn) {
|
||||||
return column.key.split('.').reduce((source, key) => {
|
return column.key.split('.').reduce((source, key) => {
|
||||||
if (key === 'priority' && typeof(source[key]) === 'number') {
|
if (key === 'priority' && source && typeof(source[key]) === 'number') {
|
||||||
return source[key] = this.taskCloudService.getPriorityLabel(source[key]);
|
return source[key] = this.taskCloudService.getPriorityLabel(source[key]);
|
||||||
}
|
}
|
||||||
return source ? source[key] : '';
|
return source && typeof(source) === 'object' ? source[key] : undefined;
|
||||||
}, row.obj);
|
}, row.obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -517,6 +517,12 @@ describe('TaskListCloudComponent', () => {
|
|||||||
'type': 'text',
|
'type': 'text',
|
||||||
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
|
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
|
||||||
'sortable': true
|
'sortable': true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'key': 'entry.priority',
|
||||||
|
'type': 'text',
|
||||||
|
'title': 'ADF_TASK_LIST.PROPERTIES.PRIORITY',
|
||||||
|
'sortable': true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -569,5 +575,66 @@ describe('TaskListCloudComponent', () => {
|
|||||||
component.ngOnChanges({ 'appName': appName });
|
component.ngOnChanges({ 'appName': appName });
|
||||||
component.ngAfterContentInit();
|
component.ngAfterContentInit();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should replace priority values', (done) => {
|
||||||
|
taskSpy.and.returnValue(of(fakeGlobalTask));
|
||||||
|
component.presetColumn = 'fakeCustomSchema';
|
||||||
|
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||||
|
component.ngOnChanges({ appName });
|
||||||
|
|
||||||
|
component.success.subscribe(() => {
|
||||||
|
const cell = fixture.nativeElement.querySelector('[data-automation-id="text_ADF_CLOUD_TASK_LIST.PROPERTIES.PRIORITY_VALUES.NONE"]');
|
||||||
|
expect(cell.textContent).toEqual('ADF_CLOUD_TASK_LIST.PROPERTIES.PRIORITY_VALUES.NONE');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.reload();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('replacePriorityValues should return undefined when no rows defined', () => {
|
||||||
|
const emptyList = { list: { entries: [] } };
|
||||||
|
taskSpy.and.returnValue(of(emptyList));
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||||
|
component.ngOnChanges({ appName });
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
|
||||||
|
expect(emptyContent.nativeElement).toBeDefined();
|
||||||
|
expect(component.replacePriorityValues({
|
||||||
|
obj: {},
|
||||||
|
isSelected: false,
|
||||||
|
hasValue: () => false,
|
||||||
|
getValue: () => undefined
|
||||||
|
}, {
|
||||||
|
type: 'text',
|
||||||
|
key: 'entry.priority'
|
||||||
|
})).toEqual(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('replacePriorityValues should return replaced value when rows are defined', () => {
|
||||||
|
taskSpy.and.returnValue(of(fakeGlobalTask));
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||||
|
component.ngOnChanges({ appName });
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.replacePriorityValues({
|
||||||
|
obj: {
|
||||||
|
entry: {
|
||||||
|
priority: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isSelected: false,
|
||||||
|
hasValue: () => false,
|
||||||
|
getValue: () => undefined
|
||||||
|
}, {
|
||||||
|
type: 'text',
|
||||||
|
key: 'entry.priority'
|
||||||
|
})).toEqual('ADF_CLOUD_TASK_LIST.PROPERTIES.PRIORITY_VALUES.LOW');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user