mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-11472] Fix file icon is not updated for version renditions (#11807)
* [ACS-11472] Fix file icon is not updated for version renditions * [ACS-11472] cr fixes
This commit is contained in:
@@ -569,6 +569,59 @@ 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';
|
||||
const nodeId = 'node-id';
|
||||
const previousVersionId = '1.0';
|
||||
const newVersionId = '2.0';
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(component.versionsApi, 'getVersion').and.returnValue(
|
||||
Promise.resolve(
|
||||
new VersionEntry({
|
||||
entry: new Node({ id: newVersionId, name: 'file.docx', content: new ContentInfo({ mimeType: docxMimeType }) })
|
||||
})
|
||||
)
|
||||
);
|
||||
spyOn(renditionService, 'getNodeRendition').and.returnValue(Promise.resolve({ url: 'rendition-url', mimeType: 'application/pdf' }));
|
||||
|
||||
component.nodeId = nodeId;
|
||||
component.versionId = previousVersionId;
|
||||
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({ id: nodeId, name: 'file.xlsx', content: new ContentInfo({ mimeType: xlsxMimeType }) }) })
|
||||
)
|
||||
);
|
||||
|
||||
component.versionId = newVersionId;
|
||||
component.ngOnChanges(getSimpleChangesWithVersion(nodeId, newVersionId, nodeId, previousVersionId));
|
||||
tick();
|
||||
|
||||
expect(renditionService.getNodeRendition).toHaveBeenCalledWith(nodeId, newVersionId);
|
||||
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({ id: nodeId, name: 'file.docx' }) }))
|
||||
);
|
||||
|
||||
component.versionId = newVersionId;
|
||||
component.ngOnChanges(getSimpleChangesWithVersion(nodeId, newVersionId, nodeId, previousVersionId));
|
||||
tick();
|
||||
|
||||
expect(renditionService.getNodeRendition).toHaveBeenCalledWith(nodeId, newVersionId);
|
||||
expect(component.mimeType).toBe('application/pdf');
|
||||
expect(component.nodeMimeType).toBe(docxMimeType);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Toolbar', () => {
|
||||
|
||||
@@ -314,7 +314,6 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
private async setUpNodeFile(nodeData: Node, versionData?: Version): Promise<void> {
|
||||
this.canEditNode = this.contentService.hasAllowableOperations(nodeData, 'update');
|
||||
let mimeType: string;
|
||||
let nodeMimeType: string;
|
||||
let urlFileContent: string;
|
||||
|
||||
if (versionData?.content) {
|
||||
@@ -322,7 +321,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
} else if (nodeData.content) {
|
||||
mimeType = nodeData.content.mimeType;
|
||||
}
|
||||
nodeMimeType = mimeType;
|
||||
const nodeMimeType = mimeType;
|
||||
|
||||
const currentFileVersion = this.nodeEntry?.entry?.properties?.['cm:versionLabel']
|
||||
? encodeURI(this.nodeEntry?.entry?.properties['cm:versionLabel'])
|
||||
@@ -344,7 +343,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