Skip to content
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 @@ -29,9 +29,9 @@ <h4 class="card-title" [innerHTML]="dsoTitle"></h4>
</span>
</p>
</ds-truncatable-part>
<ds-truncatable-part *ngIf="dso.hasMetadata('dc.description.abstract')" [id]="dso.id" [minLines]="3">
<ds-truncatable-part *ngIf="dso.hasMetadata('dc.description')" [id]="dso.id" [minLines]="3">
<p class="item-abstract card-text">
<span [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
<span [innerHTML]="firstMetadataValue('dc.description')"></span>
Comment thread
milanmajchrak marked this conversation as resolved.
</p>
</ds-truncatable-part>
</ds-truncatable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <em>title</em>';
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
hitHighlights: {
Expand Down Expand Up @@ -55,14 +57,31 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
value: '2015-06-26'
}
],
'dc.description.abstract': [
'dc.description': [
{
language: 'en_US',
value: 'This is an abstract'
}
]
}
});
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': [{
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
</span>
</ds-truncatable-part>
</span>
<div *ngIf="dso.firstMetadataValue('dc.description.abstract')" class="item-list-abstract">
<div *ngIf="dso.firstMetadataValue('dc.description')" class="item-list-abstract">
<ds-truncatable-part [id]="dso.id" [minLines]="3"><span
[innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
[innerHTML]="firstMetadataValue('dc.description')"></span>
Comment thread
milanmajchrak marked this conversation as resolved.
</ds-truncatable-part>
</div>
</ds-truncatable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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(), {
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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();
});
Comment thread
milanmajchrak marked this conversation as resolved.
});

describe('When the item has title', () => {
beforeEach(() => {
publicationListElementComponent.object = mockItemWithMetadata;
Expand Down
Loading