Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADF-5328] - fix replacing priority values error #6630

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme

replacePriorityValues(row: DataRow, column: DataColumn) {
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 ? source[key] : '';
return source && typeof(source) === 'object' ? source[key] : undefined;
}, row.obj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,12 @@ describe('TaskListCloudComponent', () => {
'type': 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
'sortable': true
},
{
'key': 'entry.priority',
'type': 'text',
'title': 'ADF_TASK_LIST.PROPERTIES.PRIORITY',
'sortable': true
}
]
}
Expand Down Expand Up @@ -569,5 +575,66 @@ describe('TaskListCloudComponent', () => {
component.ngOnChanges({ 'appName': appName });
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');
});
});
});