From 8c8a6d997d4c4bea44fef1cb80876d65b0d957bc Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk Date: Mon, 13 Apr 2026 12:43:51 +0200 Subject: [PATCH] [ACS-11472] Fix file icon is not updated for version renditions --- .../alfresco-viewer.component.spec.ts | 40 +++++++++++++++++++ .../components/alfresco-viewer.component.ts | 1 - 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts index 332ad747d9..f67de0bdb6 100644 --- a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts +++ b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts @@ -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', () => { diff --git a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.ts b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.ts index 534715dbc3..813fa5b127 100644 --- a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.ts +++ b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.ts @@ -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; }