[ADF-5009] close all the dialogs after false canActivate event (#5312)

* close all the dialogs after false canActivate event

* Update auth-guard-bpm.service.spec.ts

* sso fix

* fix lint
This commit is contained in:
Eugenio Romano
2020-01-02 11:21:10 +01:00
committed by Denys Vuika
parent d7e56b641e
commit 9c83c35e61
8 changed files with 86 additions and 11 deletions

View File

@@ -22,6 +22,7 @@ import { AuthenticationService } from './authentication.service';
import { RouterStateSnapshot, Router } from '@angular/router';
import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module';
import { MatDialog } from '@angular/material';
describe('AuthGuardService ECM', () => {
@@ -156,4 +157,22 @@ describe('AuthGuardService ECM', () => {
expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url');
}));
it('should to close the material dialog if is redirect to the login', () => {
const materialDialog = TestBed.get(MatDialog);
spyOn(materialDialog, 'closeAll');
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
authGuard.canActivate(null, route);
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'ECM', url: 'some-url'
});
expect(materialDialog.closeAll).toHaveBeenCalled();
});
});