mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-04-23 22:30:37 +00:00
[ACS-11472] Fix file icon is not updated for version renditions
This commit is contained in:
@@ -569,6 +569,46 @@ describe('AlfrescoViewerComponent', () => {
|
||||
expect(component.mimeType).toEqual('application/pdf');
|
||||
expect(component.nodeMimeType).toEqual('application/msWord');
|
||||
});
|
||||
|
||||
describe('versioned file with rendition', () => {
|
||||
const docxMimeType = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
||||
const xlsxMimeType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(component.versionsApi, 'getVersion').and.returnValue(
|
||||
Promise.resolve(
|
||||
new VersionEntry({ entry: new Node({ name: 'file.docx', content: new ContentInfo({ mimeType: docxMimeType }) }) })
|
||||
)
|
||||
);
|
||||
spyOn(renditionService, 'getNodeRendition').and.returnValue(Promise.resolve({ url: 'rendition-url', mimeType: 'application/pdf' }));
|
||||
|
||||
component.nodeId = 'node-id';
|
||||
component.versionId = '2.0';
|
||||
component.showViewer = true;
|
||||
});
|
||||
|
||||
it('should set nodeMimeType from versionData.content.mimeType, not nodeData.content.mimeType', fakeAsync(() => {
|
||||
spyOn(component.nodesApi, 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({ entry: new Node({ name: 'file.xlsx', content: new ContentInfo({ mimeType: xlsxMimeType }) }) }))
|
||||
);
|
||||
|
||||
component.ngOnChanges(getSimpleChangesWithVersion('node-id', '1.0'));
|
||||
tick();
|
||||
|
||||
expect(component.mimeType).toBe('application/pdf');
|
||||
expect(component.nodeMimeType).toBe(docxMimeType);
|
||||
}));
|
||||
|
||||
it('should preserve nodeMimeType from versionData when nodeData has no content', fakeAsync(() => {
|
||||
spyOn(component.nodesApi, 'getNode').and.returnValue(Promise.resolve(new NodeEntry({ entry: new Node({ name: 'file.docx' }) })));
|
||||
|
||||
component.ngOnChanges(getSimpleChangesWithVersion('node-id', '1.0'));
|
||||
tick();
|
||||
|
||||
expect(component.mimeType).toBe('application/pdf');
|
||||
expect(component.nodeMimeType).toBe(docxMimeType);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Toolbar', () => {
|
||||
|
||||
@@ -345,7 +345,6 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
if (nodeRendition) {
|
||||
urlFileContent = nodeRendition.url;
|
||||
|
||||
nodeMimeType = nodeData?.content?.mimeType;
|
||||
const renditionMimeType = nodeRendition.mimeType;
|
||||
mimeType = renditionMimeType || nodeMimeType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user