mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
90951: Fix issue #1381 - route titles priority over DSO titles
This commit is contained in:
@@ -157,6 +157,22 @@ describe('MetadataService', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('route titles should overwrite dso titles', fakeAsync(() => {
|
||||||
|
(translateService.get as jasmine.Spy).and.returnValues(of('DSpace :: '), of('Translated Route Title'));
|
||||||
|
(metadataService as any).processRouteChange({
|
||||||
|
data: {
|
||||||
|
value: {
|
||||||
|
dso: createSuccessfulRemoteDataObject(ItemMock),
|
||||||
|
title: 'route.title.key',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tick();
|
||||||
|
expect(title.setTitle).toHaveBeenCalledTimes(2);
|
||||||
|
expect((title.setTitle as jasmine.Spy).calls.argsFor(0)).toEqual(['Test PowerPoint Document']);
|
||||||
|
expect((title.setTitle as jasmine.Spy).calls.argsFor(1)).toEqual(['DSpace :: Translated Route Title']);
|
||||||
|
}));
|
||||||
|
|
||||||
it('other navigation should add title and description', fakeAsync(() => {
|
it('other navigation should add title and description', fakeAsync(() => {
|
||||||
(translateService.get as jasmine.Spy).and.returnValues(of('DSpace :: '), of('Dummy Title'), of('This is a dummy item component for testing!'));
|
(translateService.get as jasmine.Spy).and.returnValues(of('DSpace :: '), of('Dummy Title'), of('This is a dummy item component for testing!'));
|
||||||
(metadataService as any).processRouteChange({
|
(metadataService as any).processRouteChange({
|
||||||
|
@@ -103,6 +103,11 @@ export class MetadataService {
|
|||||||
private processRouteChange(routeInfo: any): void {
|
private processRouteChange(routeInfo: any): void {
|
||||||
this.clearMetaTags();
|
this.clearMetaTags();
|
||||||
|
|
||||||
|
if (hasValue(routeInfo.data.value.dso) && hasValue(routeInfo.data.value.dso.payload)) {
|
||||||
|
this.currentObject.next(routeInfo.data.value.dso.payload);
|
||||||
|
this.setDSOMetaTags();
|
||||||
|
}
|
||||||
|
|
||||||
if (routeInfo.data.value.title) {
|
if (routeInfo.data.value.title) {
|
||||||
const titlePrefix = this.translate.get('repository.title.prefix');
|
const titlePrefix = this.translate.get('repository.title.prefix');
|
||||||
const title = this.translate.get(routeInfo.data.value.title, routeInfo.data.value);
|
const title = this.translate.get(routeInfo.data.value.title, routeInfo.data.value);
|
||||||
@@ -116,11 +121,6 @@ export class MetadataService {
|
|||||||
this.addMetaTag('description', translatedDescription);
|
this.addMetaTag('description', translatedDescription);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasValue(routeInfo.data.value.dso) && hasValue(routeInfo.data.value.dso.payload)) {
|
|
||||||
this.currentObject.next(routeInfo.data.value.dso.payload);
|
|
||||||
this.setDSOMetaTags();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getCurrentRoute(route: ActivatedRoute): ActivatedRoute {
|
private getCurrentRoute(route: ActivatedRoute): ActivatedRoute {
|
||||||
|
Reference in New Issue
Block a user