mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
79768: Fix tag: citation_abstract_html_url
This commit is contained in:
@@ -230,7 +230,6 @@ describe('MetadataService', () => {
|
||||
tick();
|
||||
expect(tagStore.get('citation_dissertation_name')[0].content).toEqual('Test PowerPoint Document');
|
||||
expect(tagStore.get('citation_dissertation_institution')[0].content).toEqual('Mock Publisher');
|
||||
expect(tagStore.get('citation_abstract_html_url')[0].content).toEqual([environment.ui.baseUrl, router.url].join(''));
|
||||
expect(tagStore.get('citation_pdf_url')[0].content).toEqual('/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28/download');
|
||||
}));
|
||||
|
||||
@@ -273,6 +272,22 @@ describe('MetadataService', () => {
|
||||
|
||||
});
|
||||
|
||||
describe('citation_abstract_html_url', () => {
|
||||
it('should use dc.identifier.uri if available', fakeAsync(() => {
|
||||
spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(mockUri(ItemMock, 'https://ddg.gg')));
|
||||
router.navigate(['/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357']);
|
||||
tick();
|
||||
expect(tagStore.get('citation_abstract_html_url')[0].content).toEqual('https://ddg.gg');
|
||||
}));
|
||||
|
||||
it('should use current route as fallback', fakeAsync(() => {
|
||||
spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(mockUri(ItemMock)));
|
||||
router.navigate(['/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357']);
|
||||
tick();
|
||||
expect(tagStore.get('citation_abstract_html_url')[0].content).toEqual('/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357');
|
||||
}));
|
||||
});
|
||||
|
||||
describe('citation_pdf_url', () => {
|
||||
it('should link to primary Bitstream URL regardless of format', fakeAsync(() => {
|
||||
spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(ItemMock));
|
||||
@@ -328,6 +343,12 @@ describe('MetadataService', () => {
|
||||
return publishedMockItem;
|
||||
};
|
||||
|
||||
const mockUri = (mockItem: Item, uri?: string): Item => {
|
||||
const publishedMockItem = Object.assign(new Item(), mockItem) as Item;
|
||||
publishedMockItem.metadata['dc.identifier.uri'] = [{ value: uri }] as MetadataValue[];
|
||||
return publishedMockItem;
|
||||
};
|
||||
|
||||
const mockBundleRD$ = (bitstreams: Bitstream[], primary?: Bitstream): Observable<RemoteData<Bundle>> => {
|
||||
return createSuccessfulRemoteDataObject$(
|
||||
Object.assign(new Bundle(), {
|
||||
|
@@ -274,8 +274,11 @@ export class MetadataService {
|
||||
*/
|
||||
private setCitationAbstractUrlTag(): void {
|
||||
if (this.currentObject.value instanceof Item) {
|
||||
const value = [environment.ui.baseUrl, this.router.url].join('');
|
||||
this.addMetaTag('citation_abstract_html_url', value);
|
||||
let url = this.getMetaTagValue('dc.identifier.uri');
|
||||
if (hasNoValue(url)) {
|
||||
url = this.router.url; // Google should handle relative URL
|
||||
}
|
||||
this.addMetaTag('citation_abstract_html_url', url);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user