mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5209] When viewing a previous version, the title is not displayed correctly. (#5926)
* set the file title if the versionId is present. * test if file title is set when changing the versionId.
This commit is contained in:
@@ -27,7 +27,7 @@ import { RenderingQueueServices } from '../services/rendering-queue.services';
|
||||
import { ViewerComponent } from './viewer.component';
|
||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||
import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { NodeEntry, VersionEntry } from '@alfresco/js-api';
|
||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
@@ -376,6 +376,35 @@ describe('ViewerComponent', () => {
|
||||
expect(component.fileTitle).toBe('file2');
|
||||
}));
|
||||
|
||||
it('should change display name every time node\`s version changes', fakeAsync(() => {
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'node1', content: {} } }))
|
||||
);
|
||||
|
||||
spyOn(alfrescoApiService.versionsApi, 'getVersion').and.returnValues(
|
||||
Promise.resolve(new VersionEntry({ entry: { name: 'file1', content: {} } })),
|
||||
Promise.resolve(new VersionEntry({ entry: { name: 'file2', content: {} } }))
|
||||
);
|
||||
|
||||
component.nodeId = 'id1';
|
||||
component.urlFile = null;
|
||||
component.displayName = null;
|
||||
component.blobFile = null;
|
||||
component.showViewer = true;
|
||||
|
||||
component.versionId = '1.0';
|
||||
component.ngOnChanges();
|
||||
tick();
|
||||
|
||||
expect(component.fileTitle).toBe('file1');
|
||||
|
||||
component.versionId = '1.1';
|
||||
component.ngOnChanges();
|
||||
tick();
|
||||
|
||||
expect(component.fileTitle).toBe('file2');
|
||||
}));
|
||||
|
||||
it('should update node only if node name changed', fakeAsync(() => {
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValues(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } }))
|
||||
|
@@ -389,7 +389,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this.mimeType = nodeData.content.mimeType;
|
||||
}
|
||||
|
||||
this.fileTitle = this.getDisplayName(nodeData.name);
|
||||
this.fileTitle = this.getDisplayName(versionData ? versionData.name : nodeData.name);
|
||||
|
||||
this.urlFileContent = versionData ? this.apiService.contentApi.getVersionContentUrl(this.nodeId, versionData.id) :
|
||||
this.apiService.contentApi.getContentUrl(this.nodeId);
|
||||
this.urlFileContent = this.cacheBusterNumber ? this.urlFileContent + '&' + this.cacheBusterNumber : this.urlFileContent;
|
||||
|
Reference in New Issue
Block a user