mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4424] Pdf Viewer - password dialog does not close when pressing Escape (#4622)
* return to previous page on close * update e2e * [ADF-4424] Improve PreviousRouteService to use it in pdfViewer * change previous Url logic * remove navigation logic * remove test * Update pdfViewer.component.spec.ts * back button logic for viewer outlet * unit tests * remove fdescribe * remove unused service * e2e * return to location * remove click filter step * remove unnecessary test steps * remove un existen export * unify preview between PS and CS in demo shell * fix dispalyname property
This commit is contained in:
committed by
Eugenio Romano
parent
72b3a75a85
commit
ccdcba8778
@@ -23,16 +23,14 @@ import { AlfrescoApiService, RenditionsService } from '../../services';
|
||||
|
||||
import { CoreModule } from '../../core.module';
|
||||
|
||||
import { throwError, Observable } from 'rxjs';
|
||||
import { throwError } from 'rxjs';
|
||||
import { EventMock } from '../../mock/event.mock';
|
||||
import { RenderingQueueServices } from '../services/rendering-queue.services';
|
||||
import { ViewerComponent } from './viewer.component';
|
||||
import { setupTestBed } from '../../testing/setupTestBed';
|
||||
import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { PreviousRouteService } from 'core/services/previous-route.service';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-viewer-container-toolbar',
|
||||
@@ -123,22 +121,11 @@ class ViewerWithCustomOpenWithComponent {
|
||||
class ViewerWithCustomMoreActionsComponent {
|
||||
}
|
||||
|
||||
class MockRouter {
|
||||
navigate = jasmine.createSpy('navigate');
|
||||
firstUrl = new NavigationEnd(0, '/files', '/files');
|
||||
events = new Observable((observer) => {
|
||||
observer.next(this.firstUrl);
|
||||
observer.complete();
|
||||
});
|
||||
}
|
||||
|
||||
describe('ViewerComponent', () => {
|
||||
|
||||
let component: ViewerComponent;
|
||||
let fixture: ComponentFixture<ViewerComponent>;
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
let previousRouteService: PreviousRouteService;
|
||||
let router: Router;
|
||||
let element: HTMLElement;
|
||||
|
||||
setupTestBed({
|
||||
@@ -162,9 +149,7 @@ describe('ViewerComponent', () => {
|
||||
}
|
||||
}
|
||||
},
|
||||
{ provide: Router, useClass: MockRouter },
|
||||
RenderingQueueServices,
|
||||
PreviousRouteService,
|
||||
{ provide: Location, useClass: SpyLocation }
|
||||
]
|
||||
});
|
||||
@@ -175,8 +160,6 @@ describe('ViewerComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
|
||||
alfrescoApiService = TestBed.get(AlfrescoApiService);
|
||||
previousRouteService = TestBed.get(PreviousRouteService);
|
||||
router = TestBed.get(Router);
|
||||
});
|
||||
|
||||
describe('Extension Type Test', () => {
|
||||
@@ -661,9 +644,9 @@ describe('ViewerComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should go back when back button is clicked', async(() => {
|
||||
it('should emit `showViewerChange` event on close', async(() => {
|
||||
|
||||
spyOn(previousRouteService, 'getPreviousUrl').and.returnValue('home');
|
||||
spyOn(component.showViewerChange, 'emit');
|
||||
|
||||
const button: HTMLButtonElement = element.querySelector('[data-automation-id="adf-toolbar-back"]') as HTMLButtonElement;
|
||||
button.click();
|
||||
@@ -671,11 +654,11 @@ describe('ViewerComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(router.navigate).toHaveBeenCalled();
|
||||
expect(component.showViewerChange.emit).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render close viewer button if it is a shared link', (done) => {
|
||||
it('should not render close viewer button if it is a shared link', (done) => {
|
||||
spyOn(alfrescoApiService.getInstance().core.sharedlinksApi, 'getSharedLink')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
|
||||
|
Reference in New Issue
Block a user