@@ -136,19 +136,50 @@ describe('CrisItemPageTabResolver', () => {
136136 } ) ;
137137 } ) ;
138138
139- it ( 'Should handle tab shortnames with "::" correctly' , ( ) => {
140- const tabRD = createSuccessfulRemoteDataObject ( createPaginatedList ( [ {
139+ it ( 'Should handle tab shortnames with "::" correctly' , ( done ) => {
140+ const tabPageList = createPaginatedList ( [ {
141141 ...tabPublicationsTest ,
142142 shortname : 'publication::details' ,
143- } ] ) ) ;
144- tabService . findByItem . and . returnValue ( createSuccessfulRemoteDataObject$ ( tabRD ) as any ) ;
143+ } ] ) ;
144+ const tabRD = createSuccessfulRemoteDataObject ( tabPageList ) ;
145+ tabService . findByItem . and . returnValue ( createSuccessfulRemoteDataObject$ ( tabPageList ) as any ) ;
145146
146- TestBed . runInInjectionContext ( ( ) => {
147- return crisItemPageTabResolver ( { params : { id : uuid } } as any , { url : '/entities/publication/1234-65487-12354-1235/publication::details' } as any ) ;
147+ const obs = TestBed . runInInjectionContext ( ( ) => {
148+ return crisItemPageTabResolver ( { params : { id : uuid } } as any , { url : '/entities/publication/1234-65487-12354-1235/details' } as any ) ;
149+ } ) as Observable < RemoteData < PaginatedList < CrisLayoutTab > > > ;
150+
151+ obs . pipe ( take ( 1 ) ) . subscribe ( ( resolved ) => {
152+ expect ( router . navigateByUrl ) . not . toHaveBeenCalled ( ) ;
153+ expect ( hardRedirectService . redirect ) . not . toHaveBeenCalled ( ) ;
154+ expect ( resolved ) . toEqual ( tabRD ) ;
155+ done ( ) ;
148156 } ) ;
157+ } ) ;
158+
159+ it ( 'should NOT redirect to 404 when query params are present in the URL' , ( done ) => {
160+ const obs = TestBed . runInInjectionContext ( ( ) => {
161+ return crisItemPageTabResolver ( { params : { id : uuid } } as any , { url : '/entities/publication/1234-65487-12354-1235?f.subject=value&f.date=2024' } as any ) ;
162+ } ) as Observable < RemoteData < PaginatedList < CrisLayoutTab > > > ;
149163
150- expect ( router . navigateByUrl ) . not . toHaveBeenCalled ( ) ;
151- expect ( hardRedirectService . redirect ) . not . toHaveBeenCalled ( ) ;
164+ obs . pipe ( take ( 1 ) ) . subscribe ( ( resolved ) => {
165+ expect ( router . navigateByUrl ) . not . toHaveBeenCalled ( ) ;
166+ expect ( hardRedirectService . redirect ) . not . toHaveBeenCalled ( ) ;
167+ expect ( resolved ) . toEqual ( tabsRD ) ;
168+ done ( ) ;
169+ } ) ;
170+ } ) ;
171+
172+ it ( 'should NOT redirect to 404 when query params are present with a valid tab' , ( done ) => {
173+ const obs = TestBed . runInInjectionContext ( ( ) => {
174+ return crisItemPageTabResolver ( { params : { id : uuid } } as any , { url : '/entities/publication/1234-65487-12354-1235/details?f.subject=value' } as any ) ;
175+ } ) as Observable < RemoteData < PaginatedList < CrisLayoutTab > > > ;
176+
177+ obs . pipe ( take ( 1 ) ) . subscribe ( ( resolved ) => {
178+ expect ( router . navigateByUrl ) . not . toHaveBeenCalled ( ) ;
179+ expect ( hardRedirectService . redirect ) . not . toHaveBeenCalled ( ) ;
180+ expect ( resolved ) . toEqual ( tabsRD ) ;
181+ done ( ) ;
182+ } ) ;
152183 } ) ;
153184 } ) ;
154185
0 commit comments