Skip to content

Commit e75f239

Browse files
authored
[ENG-9608] P14.1 - Links in emails not working #805
- Ticket: [ENG-9608] - Feature flag: n/a ## Summary of Changes 1. Fixed registries links.
1 parent d11310a commit e75f239

File tree

4 files changed

+82
-4
lines changed

4 files changed

+82
-4
lines changed

src/app/core/guards/registration-moderation.guard.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ export const registrationModerationGuard: CanActivateFn = (route) => {
1616
if (provider?.reviewsWorkflow) {
1717
return true;
1818
}
19+
1920
const id = route.params['providerId'];
21+
2022
return store.dispatch(new GetRegistryProvider(id)).pipe(
21-
switchMap(() => {
22-
return store.select(RegistrationProviderSelectors.getBrandedProvider).pipe(
23+
switchMap(() =>
24+
store.select(RegistrationProviderSelectors.getBrandedProvider).pipe(
2325
take(1),
2426
map((provider) => {
2527
if (!provider?.reviewsWorkflow) {
@@ -29,7 +31,7 @@ export const registrationModerationGuard: CanActivateFn = (route) => {
2931

3032
return true;
3133
})
32-
);
33-
})
34+
)
35+
)
3436
);
3537
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { Router } from '@angular/router';
3+
4+
import { MyRegistrationsRedirectComponent } from './my-registrations-redirect.component';
5+
6+
import { RouterMock } from '@testing/providers/router-provider.mock';
7+
8+
describe('MyRegistrationsRedirectComponent', () => {
9+
let component: MyRegistrationsRedirectComponent;
10+
let fixture: ComponentFixture<MyRegistrationsRedirectComponent>;
11+
let router: jest.Mocked<Router>;
12+
13+
beforeEach(async () => {
14+
const routerMock = RouterMock.create().build();
15+
16+
await TestBed.configureTestingModule({
17+
imports: [MyRegistrationsRedirectComponent],
18+
providers: [{ provide: Router, useValue: routerMock }],
19+
}).compileComponents();
20+
21+
fixture = TestBed.createComponent(MyRegistrationsRedirectComponent);
22+
component = fixture.componentInstance;
23+
router = TestBed.inject(Router) as jest.Mocked<Router>;
24+
fixture.detectChanges();
25+
});
26+
27+
it('should create', () => {
28+
expect(component).toBeTruthy();
29+
});
30+
31+
it('should be an instance of MyRegistrationsRedirectComponent', () => {
32+
expect(component).toBeInstanceOf(MyRegistrationsRedirectComponent);
33+
});
34+
35+
it('should navigate to /my-registrations on component creation', () => {
36+
expect(router.navigate).toHaveBeenCalledWith(['/my-registrations'], {
37+
queryParamsHandling: 'preserve',
38+
replaceUrl: true,
39+
});
40+
});
41+
42+
it('should preserve query parameters during navigation', () => {
43+
const navigationOptions = router.navigate.mock.calls[0][1];
44+
expect(navigationOptions?.queryParamsHandling).toBe('preserve');
45+
});
46+
47+
it('should replace the current URL in browser history', () => {
48+
const navigationOptions = router.navigate.mock.calls[0][1];
49+
expect(navigationOptions?.replaceUrl).toBe(true);
50+
});
51+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component, inject } from '@angular/core';
2+
import { Router } from '@angular/router';
3+
4+
@Component({
5+
template: '',
6+
})
7+
export class MyRegistrationsRedirectComponent {
8+
private readonly router = inject(Router);
9+
10+
constructor() {
11+
this.router.navigate(['/my-registrations'], { queryParamsHandling: 'preserve', replaceUrl: true });
12+
}
13+
}

src/app/features/registries/registries.routes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ export const registriesRoutes: Routes = [
4040
(c) => c.RegistriesLandingComponent
4141
),
4242
},
43+
{
44+
path: 'my-registrations',
45+
loadComponent: () =>
46+
import('./pages/my-registrations-redirect/my-registrations-redirect.component').then(
47+
(c) => c.MyRegistrationsRedirectComponent
48+
),
49+
},
4350
{
4451
path: ':providerId',
4552
loadComponent: () =>
@@ -65,6 +72,11 @@ export const registriesRoutes: Routes = [
6572
path: 'drafts',
6673
loadComponent: () => import('./components/drafts/drafts.component').then((mod) => mod.DraftsComponent),
6774
children: [
75+
{
76+
path: ':id',
77+
redirectTo: ':id/metadata',
78+
pathMatch: 'full',
79+
},
6880
{
6981
path: ':id/metadata',
7082
loadComponent: () =>

0 commit comments

Comments
 (0)