mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #1066 from 4Science/CSTPER-321-deleteitem
Error deleting an item when its entity type has no relations
This commit is contained in:
@@ -173,6 +173,19 @@ describe('ItemDeleteComponent', () => {
|
|||||||
.toHaveBeenCalledWith(mockItem.id, types.filter((type) => typesSelection[type]).map((type) => type.id));
|
.toHaveBeenCalledWith(mockItem.id, types.filter((type) => typesSelection[type]).map((type) => type.id));
|
||||||
expect(comp.notify).toHaveBeenCalled();
|
expect(comp.notify).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call delete function from the ItemDataService with empty types', () => {
|
||||||
|
|
||||||
|
spyOn(comp, 'notify');
|
||||||
|
jasmine.getEnv().allowRespy(true);
|
||||||
|
spyOn(entityTypeService, 'getEntityTypeRelationships').and.returnValue([]);
|
||||||
|
comp.ngOnInit();
|
||||||
|
|
||||||
|
comp.performAction();
|
||||||
|
|
||||||
|
expect(mockItemDataService.delete).toHaveBeenCalledWith(mockItem.id, []);
|
||||||
|
expect(comp.notify).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('notify', () => {
|
describe('notify', () => {
|
||||||
it('should navigate to the homepage on successful deletion of the item', () => {
|
it('should navigate to the homepage on successful deletion of the item', () => {
|
||||||
|
@@ -121,8 +121,11 @@ export class ItemDeleteComponent
|
|||||||
getFirstSucceededRemoteData(),
|
getFirstSucceededRemoteData(),
|
||||||
getRemoteDataPayload(),
|
getRemoteDataPayload(),
|
||||||
map((relationshipTypes) => relationshipTypes.page),
|
map((relationshipTypes) => relationshipTypes.page),
|
||||||
switchMap((types) =>
|
switchMap((types) => {
|
||||||
combineLatest(types.map((type) => this.getRelationships(type))).pipe(
|
if (types.length === 0) {
|
||||||
|
return observableOf(types);
|
||||||
|
}
|
||||||
|
return combineLatest(types.map((type) => this.getRelationships(type))).pipe(
|
||||||
map((relationships) =>
|
map((relationships) =>
|
||||||
types.reduce<RelationshipType[]>((includedTypes, type, index) => {
|
types.reduce<RelationshipType[]>((includedTypes, type, index) => {
|
||||||
if (!includedTypes.some((includedType) => includedType.id === type.id)
|
if (!includedTypes.some((includedType) => includedType.id === type.id)
|
||||||
@@ -133,8 +136,8 @@ export class ItemDeleteComponent
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
),
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.types$ = observableOf([]);
|
this.types$ = observableOf([]);
|
||||||
|
Reference in New Issue
Block a user