mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-12047] During bulk upload preview switches to the next file (#5265)
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
import { AuthenticationService } from '@alfresco/adf-core';
|
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 { ClosePreviewAction, RefreshPreviewAction, ViewNodeAction } from '@alfresco/aca-shared/store';
|
||||||
import { AcaViewerComponent } from './viewer.component';
|
import { AcaViewerComponent } from './viewer.component';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
@@ -161,12 +161,34 @@ describe('AcaViewerComponent', () => {
|
|||||||
it('should emit nodeUpdated event on fileUploadComplete event', fakeAsync(() => {
|
it('should emit nodeUpdated event on fileUploadComplete event', fakeAsync(() => {
|
||||||
spyOn(nodesApiService.nodeUpdated, 'next');
|
spyOn(nodesApiService.nodeUpdated, 'next');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
uploadService.fileUploadComplete.next({ data: { entry: {} } } as any);
|
uploadService.fileUploadComplete.next({ data: { entry: {} } } as FileUploadCompleteEvent);
|
||||||
tick(300);
|
tick(300);
|
||||||
|
|
||||||
expect(nodesApiService.nodeUpdated.next).toHaveBeenCalled();
|
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', () => {
|
describe('return on event', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
spyOn<any>(component, 'navigateToFileLocation');
|
spyOn<any>(component, 'navigateToFileLocation');
|
||||||
|
|||||||
@@ -189,7 +189,9 @@ export class AcaViewerComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.uploadService.fileUploadComplete.pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef)).subscribe((file) => {
|
this.uploadService.fileUploadComplete.pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef)).subscribe((file) => {
|
||||||
this.nodesApiService.nodeUpdated.next(file.data.entry);
|
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, '');
|
this.previewLocation = this.router.url.substring(0, this.router.url.indexOf('/', 1)).replace(/\//g, '');
|
||||||
|
|||||||
Reference in New Issue
Block a user