@@ -92,7 +92,7 @@ import { EditEmaEditorComponent } from './edit-ema-editor.component';
9292import { DotBlockEditorSidebarComponent } from '../components/dot-block-editor-sidebar/dot-block-editor-sidebar.component' ;
9393import { DotEmaDialogComponent } from '../components/dot-ema-dialog/dot-ema-dialog.component' ;
9494import { DotActionUrlService } from '../services/dot-action-url/dot-action-url.service' ;
95- import { DotPageApiService } from '../services/dot-page-api/dot-page-api.service' ;
95+ import { DotPageApiParams , DotPageApiService } from '../services/dot-page-api/dot-page-api.service' ;
9696import { DotUveActionsHandlerService } from '../services/dot-uve-actions-handler/dot-uve-actions-handler.service' ;
9797import { DotUveDragDropService } from '../services/dot-uve-drag-drop/dot-uve-drag-drop.service' ;
9898import { InlineEditService } from '../services/inline-edit/inline-edit.service' ;
@@ -152,7 +152,7 @@ const mockGlobalStore = {
152152} ;
153153
154154const mockDotUveActionsHandlerService = {
155- handleAction : jest . fn ( ( ) => of ( { } ) )
155+ handleAction : jest . fn ( ( _message : unknown , _deps : unknown ) => of ( { } ) )
156156} ;
157157
158158const mockDotUveDragDropService = {
@@ -2343,6 +2343,107 @@ describe('EditEmaEditorComponent', () => {
23432343 expect ( mockEvent . preventDefault ) . toHaveBeenCalled ( ) ;
23442344 } ) ;
23452345
2346+ describe ( 'same-page navigation (same pathname)' , ( ) => {
2347+ const samePathPageParams = ( ) : DotPageApiParams => ( {
2348+ url : '/current-page' ,
2349+ language_id : '1' ,
2350+ [ PERSONA_KEY ] : DEFAULT_PERSONA . identifier
2351+ } ) ;
2352+
2353+ beforeEach ( ( ) => {
2354+ jest . spyOn ( store , 'pageParams' ) . mockReturnValue ( samePathPageParams ( ) ) ;
2355+ } ) ;
2356+
2357+ it ( 'should not trigger pageLoad for hash-only navigation on same page' , ( ) => {
2358+ const hashUrl = 'http://localhost:3000/current-page#sectionA' ;
2359+ const mockEvent = createMockEvent ( hashUrl ) ;
2360+
2361+ spectator . component . handleInternalNav ( mockEvent ) ;
2362+
2363+ expect ( pageLoadSpy ) . not . toHaveBeenCalled ( ) ;
2364+ expect ( mockEvent . preventDefault ) . not . toHaveBeenCalled ( ) ;
2365+ } ) ;
2366+
2367+ it ( 'should not trigger pageLoad for hash-only with complex id' , ( ) => {
2368+ const hashUrl = 'http://localhost:3000/current-page#section-123_complex' ;
2369+ const mockEvent = createMockEvent ( hashUrl ) ;
2370+
2371+ spectator . component . handleInternalNav ( mockEvent ) ;
2372+
2373+ expect ( pageLoadSpy ) . not . toHaveBeenCalled ( ) ;
2374+ } ) ;
2375+
2376+ it ( 'should not trigger pageLoad for query-only navigation on same page' , ( ) => {
2377+ const queryUrl = 'http://localhost:3000/current-page?tab=2' ;
2378+ const mockEvent = createMockEvent ( queryUrl ) ;
2379+
2380+ spectator . component . handleInternalNav ( mockEvent ) ;
2381+
2382+ expect ( pageLoadSpy ) . not . toHaveBeenCalled ( ) ;
2383+ expect ( mockEvent . preventDefault ) . not . toHaveBeenCalled ( ) ;
2384+ } ) ;
2385+
2386+ it ( 'should not trigger pageLoad for multiple query params on same page' , ( ) => {
2387+ const queryUrl =
2388+ 'http://localhost:3000/current-page?filter=value&sort=date' ;
2389+ const mockEvent = createMockEvent ( queryUrl ) ;
2390+
2391+ spectator . component . handleInternalNav ( mockEvent ) ;
2392+
2393+ expect ( pageLoadSpy ) . not . toHaveBeenCalled ( ) ;
2394+ } ) ;
2395+
2396+ it ( 'should not trigger pageLoad when both hash and query are present on same path' , ( ) => {
2397+ const combinedUrl = 'http://localhost:3000/current-page?tab=2#section' ;
2398+ const mockEvent = createMockEvent ( combinedUrl ) ;
2399+
2400+ spectator . component . handleInternalNav ( mockEvent ) ;
2401+
2402+ expect ( pageLoadSpy ) . not . toHaveBeenCalled ( ) ;
2403+ expect ( mockEvent . preventDefault ) . not . toHaveBeenCalled ( ) ;
2404+ } ) ;
2405+
2406+ it ( 'should trigger pageLoad when navigating to different page with hash' , ( ) => {
2407+ const differentPageUrl = 'http://localhost:3000/other-page#section' ;
2408+ const mockEvent = createMockEvent ( differentPageUrl ) ;
2409+
2410+ spectator . component . handleInternalNav ( mockEvent ) ;
2411+
2412+ expect ( pageLoadSpy ) . toHaveBeenCalledWith ( {
2413+ url : '/other-page'
2414+ } ) ;
2415+ expect ( mockEvent . preventDefault ) . toHaveBeenCalled ( ) ;
2416+ } ) ;
2417+
2418+ it ( 'should trigger pageLoad when navigating to different page with query' , ( ) => {
2419+ const differentPageUrl = 'http://localhost:3000/other-page?tab=1' ;
2420+ const mockEvent = createMockEvent ( differentPageUrl ) ;
2421+
2422+ spectator . component . handleInternalNav ( mockEvent ) ;
2423+
2424+ expect ( pageLoadSpy ) . toHaveBeenCalledWith ( {
2425+ url : '/other-page' ,
2426+ tab : '1'
2427+ } ) ;
2428+ expect ( mockEvent . preventDefault ) . toHaveBeenCalled ( ) ;
2429+ } ) ;
2430+
2431+ it ( 'should handle root path hash navigation' , ( ) => {
2432+ jest . spyOn ( store , 'pageParams' ) . mockReturnValue ( {
2433+ url : '/' ,
2434+ language_id : '1' ,
2435+ [ PERSONA_KEY ] : DEFAULT_PERSONA . identifier
2436+ } ) ;
2437+
2438+ const hashUrl = 'http://localhost:3000/#top' ;
2439+ const mockEvent = createMockEvent ( hashUrl ) ;
2440+
2441+ spectator . component . handleInternalNav ( mockEvent ) ;
2442+
2443+ expect ( pageLoadSpy ) . not . toHaveBeenCalled ( ) ;
2444+ } ) ;
2445+ } ) ;
2446+
23462447 afterEach ( ( ) => {
23472448 jest . clearAllMocks ( ) ;
23482449 } ) ;
0 commit comments