[ACS-11472] Fix file icon is not updated for version renditions

This commit is contained in:
Mykyta Maliarchuk
2026-04-13 12:43:51 +02:00
parent 1ee94fcb2c
commit 8c8a6d997d
2 changed files with 40 additions and 1 deletions

View File

@@ -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', () => {

View File

@@ -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;
}