From 5a9873f7589cf74845d48666288bb8bed8543bae Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Mon, 4 Mar 2024 12:36:49 +0100 Subject: [PATCH] OZG-4321 manuell navigation to avoid iss parameter --- .../apps/admin/src/app/app.component.spec.ts | 13 +++++++++++++ alfa-client/apps/admin/src/app/app.component.ts | 3 +++ 2 files changed, 16 insertions(+) diff --git a/alfa-client/apps/admin/src/app/app.component.spec.ts b/alfa-client/apps/admin/src/app/app.component.spec.ts index 45e077a4ec..52e41ae571 100644 --- a/alfa-client/apps/admin/src/app/app.component.spec.ts +++ b/alfa-client/apps/admin/src/app/app.component.spec.ts @@ -11,6 +11,7 @@ import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; import { MockComponent } from 'ng-mocks'; import { UserProfileButtonContainerComponent } from '../common/user-profile-button-container/user-profile.button-container.component'; import { PostfachNavigationItemComponent } from '../pages/postfach/postfach-navigation-item/postfach-navigation-item.component'; +import { Router } from '@angular/router'; describe('AppComponent', () => { let component: AppComponent; @@ -25,6 +26,8 @@ describe('AppComponent', () => { ...mock(AuthService), login: jest.fn().mockResolvedValue(Promise.resolve()), }; + + const router: Mock<Router> = mock(Router); const apiRootService: Mock<ApiRootService> = mock(ApiRootService); beforeEach(async () => { @@ -44,6 +47,10 @@ describe('AppComponent', () => { provide: ApiRootService, useValue: apiRootService, }, + { + provide: Router, + useValue: router, + }, ], }).compileComponents(); }); @@ -82,6 +89,12 @@ describe('AppComponent', () => { expect(apiRootService.getApiRoot).toHaveBeenCalled(); }); + + it('should navigate to default route', () => { + component.doAfterLoggedIn(); + + expect(router.navigate).toHaveBeenCalledWith(['/']); + }); }); }); diff --git a/alfa-client/apps/admin/src/app/app.component.ts b/alfa-client/apps/admin/src/app/app.component.ts index 20aeed47e0..a09ea6d8a5 100644 --- a/alfa-client/apps/admin/src/app/app.component.ts +++ b/alfa-client/apps/admin/src/app/app.component.ts @@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { AuthService } from '../common/auth/auth.service'; import { StateResource } from '@alfa-client/tech-shared'; +import { Router } from '@angular/router'; @Component({ selector: 'app-root', @@ -17,6 +18,7 @@ export class AppComponent implements OnInit { constructor( public authService: AuthService, private apiRootService: ApiRootService, + private router: Router, ) {} ngOnInit(): void { @@ -25,5 +27,6 @@ export class AppComponent implements OnInit { doAfterLoggedIn(): void { this.apiRootStateResource$ = this.apiRootService.getApiRoot(); + this.router.navigate(['/']); } } -- GitLab