diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html index 9aa511cb415..7e2f093a32e 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html @@ -29,9 +29,9 @@

- +

- +

diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec.ts index dc42b033d84..92c057a3cd5 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec.ts +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec.ts @@ -28,6 +28,8 @@ import { ItemSearchResultGridElementComponent } from './item-search-result-grid- const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); mockItemWithMetadata.hitHighlights = {}; +const mockItemWithAbstractOnly: ItemSearchResult = new ItemSearchResult(); +mockItemWithAbstractOnly.hitHighlights = {}; const dcTitle = 'This is just another title'; mockItemWithMetadata.indexableObject = Object.assign(new Item(), { hitHighlights: { @@ -55,7 +57,7 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { value: '2015-06-26' } ], - 'dc.description.abstract': [ + 'dc.description': [ { language: 'en_US', value: 'This is an abstract' @@ -63,6 +65,23 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), { ] } }); +mockItemWithAbstractOnly.indexableObject = Object.assign(new Item(), { + bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: dcTitle + } + ], + 'dc.description.abstract': [ + { + language: 'en_US', + value: 'Legacy abstract only' + } + ] + } +}); const mockPerson: ItemSearchResult = Object.assign(new ItemSearchResult(), { hitHighlights: { 'person.familyName': [{ @@ -98,7 +117,7 @@ const mockPerson: ItemSearchResult = Object.assign(new ItemSearchResult(), { value: '2015-06-26' } ], - 'dc.description.abstract': [ + 'dc.description': [ { language: 'en_US', value: 'This is the abstract' @@ -152,7 +171,7 @@ const mockOrgUnit: ItemSearchResult = Object.assign(new ItemSearchResult(), { value: '2015-06-26' } ], - 'dc.description.abstract': [ + 'dc.description': [ { language: 'en_US', value: 'This is the abstract' @@ -186,7 +205,7 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { } }); -describe('ItemGridElementComponent', getEntityGridElementTestComponent(ItemSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract'])); +describe('ItemGridElementComponent', getEntityGridElementTestComponent(ItemSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract'], mockItemWithAbstractOnly)); /** * Create test cases for a grid component of an entity. @@ -197,7 +216,13 @@ describe('ItemGridElementComponent', getEntityGridElementTestComponent(ItemSearc * For example: If one of the fields to check is labeled "authors", the html template should contain at least one element with class ".item-authors" that's * present when the author metadata is available. */ -export function getEntityGridElementTestComponent(component, searchResultWithMetadata: ItemSearchResult, searchResultWithoutMetadata: ItemSearchResult, fieldsToCheck: string[]) { +export function getEntityGridElementTestComponent( + component, + searchResultWithMetadata: ItemSearchResult, + searchResultWithoutMetadata: ItemSearchResult, + fieldsToCheck: string[], + searchResultWithAbstractOnly?: ItemSearchResult, +) { return () => { let comp; let fixture; @@ -244,6 +269,20 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet comp = fixture.componentInstance; })); + if (searchResultWithAbstractOnly) { + describe('when the item has only dc.description.abstract metadata', () => { + beforeEach(() => { + comp.object = searchResultWithAbstractOnly; + fixture.detectChanges(); + }); + + it('should not show abstract field', () => { + const abstractField = fixture.debugElement.query(By.css('.item-abstract')); + expect(abstractField).toBeNull(); + }); + }); + } + fieldsToCheck.forEach((field) => { describe(`when the item has "${field}" metadata`, () => { beforeEach(() => { diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html index 64b28531338..fb3518fe1cf 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html @@ -36,9 +36,9 @@
-
+
+ [innerHTML]="firstMetadataValue('dc.description')">
diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts index 7665b7d64e3..06fff63d181 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts @@ -48,7 +48,7 @@ const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResul value: '2015-06-26' } ], - 'dc.description.abstract': [ + 'dc.description': [ { language: 'en_US', value: 'This is the abstract' @@ -57,6 +57,20 @@ const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResul } }) }); +const mockItemWithAbstractOnly: ItemSearchResult = Object.assign(new ItemSearchResult(), { + indexableObject: + Object.assign(new Item(), { + bundles: observableOf({}), + metadata: { + 'dc.description.abstract': [ + { + language: 'en_US', + value: 'Legacy abstract only' + } + ] + } + }) +}); const mockItemWithoutMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), { indexableObject: Object.assign(new Item(), { @@ -99,7 +113,7 @@ const mockPerson: ItemSearchResult = Object.assign(new ItemSearchResult(), { value: '2015-06-26' } ], - 'dc.description.abstract': [ + 'dc.description': [ { language: 'en_US', value: 'This is the abstract' @@ -153,7 +167,7 @@ const mockOrgUnit: ItemSearchResult = Object.assign(new ItemSearchResult(), { value: '2015-06-26' } ], - 'dc.description.abstract': [ + 'dc.description': [ { language: 'en_US', value: 'This is the abstract' @@ -317,6 +331,18 @@ describe('ItemSearchResultListElementComponent', () => { }); }); + describe('When the item has only dc.description.abstract metadata', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithAbstractOnly; + fixture.detectChanges(); + }); + + it('should not show the abstract span', () => { + const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract')); + expect(abstractField).toBeNull(); + }); + }); + describe('When the item has title', () => { beforeEach(() => { publicationListElementComponent.object = mockItemWithMetadata;