From c53bf094f1e74af108e8eca8a5340edb866deb75 Mon Sep 17 00:00:00 2001 From: Dominik Iwanek <141320833+dominikiwanekhyland@users.noreply.github.com> Date: Fri, 10 Jul 2026 08:07:27 +0200 Subject: [PATCH] [ACS-12047] During bulk upload preview switches to the next file (#5265) --- .../viewer/viewer.component.spec.ts | 26 +++++++++++++++++-- .../lib/components/viewer/viewer.component.ts | 4 ++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.spec.ts b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.spec.ts index cd1448ad2..3a8ce3de8 100644 --- a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.spec.ts +++ b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.spec.ts @@ -25,7 +25,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { AuthenticationService } from '@alfresco/adf-core'; -import { DiscoveryApiService, DocumentListService, NodesApiService, UploadService } from '@alfresco/adf-content-services'; +import { DiscoveryApiService, DocumentListService, FileUploadCompleteEvent, NodesApiService, UploadService } from '@alfresco/adf-content-services'; import { ClosePreviewAction, RefreshPreviewAction, ViewNodeAction } from '@alfresco/aca-shared/store'; import { AcaViewerComponent } from './viewer.component'; import { of } from 'rxjs'; @@ -161,12 +161,34 @@ describe('AcaViewerComponent', () => { it('should emit nodeUpdated event on fileUploadComplete event', fakeAsync(() => { spyOn(nodesApiService.nodeUpdated, 'next'); fixture.detectChanges(); - uploadService.fileUploadComplete.next({ data: { entry: {} } } as any); + uploadService.fileUploadComplete.next({ data: { entry: {} } } as FileUploadCompleteEvent); tick(300); expect(nodesApiService.nodeUpdated.next).toHaveBeenCalled(); })); + it('should not switch the viewer to an uploaded file that is not currently displayed', fakeAsync(() => { + spyOn(contentApi, 'getNodeInfo').and.returnValue(of({ id: 'displayed-node', isFile: true } as Node)); + fixture.detectChanges(); + component.nodeId = 'displayed-node'; + + uploadService.fileUploadComplete.next({ data: { entry: { id: 'another-node' } } } as FileUploadCompleteEvent); + tick(300); + + expect(contentApi.getNodeInfo).not.toHaveBeenCalled(); + })); + + it('should refresh the viewer when the currently displayed file finishes uploading', fakeAsync(() => { + spyOn(contentApi, 'getNodeInfo').and.returnValue(of({ id: 'displayed-node', isFile: true } as Node)); + fixture.detectChanges(); + component.nodeId = 'displayed-node'; + + uploadService.fileUploadComplete.next({ data: { entry: { id: 'displayed-node' } } } as FileUploadCompleteEvent); + tick(300); + + expect(contentApi.getNodeInfo).toHaveBeenCalledWith('displayed-node'); + })); + describe('return on event', () => { beforeEach(async () => { spyOn(component, 'navigateToFileLocation'); diff --git a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.ts b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.ts index 9a73a39cd..ac1aa760c 100644 --- a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.ts +++ b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.ts @@ -189,7 +189,9 @@ export class AcaViewerComponent implements OnInit, OnDestroy { this.uploadService.fileUploadComplete.pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef)).subscribe((file) => { this.nodesApiService.nodeUpdated.next(file.data.entry); - void this.displayNode(file.data.entry.id); + if (file.data.entry.id === this.nodeId) { + void this.displayNode(file.data.entry.id); + } }); this.previewLocation = this.router.url.substring(0, this.router.url.indexOf('/', 1)).replace(/\//g, '');