@@ -119,14 +119,16 @@ describe("Dynamic route startup bridge", () => {
119119 "loads the $label once while publishing its real location" ,
120120 async ( { routeId, location : initialLocation } ) => {
121121 let location : RouteLocation = { ...initialLocation } ;
122+ const push = vi . fn ( ( next : RouteLocation ) => {
123+ location = next ;
124+ } ) ;
125+ const replace = vi . fn ( ( next : RouteLocation ) => {
126+ location = next ;
127+ } ) ;
122128 const history : RouterHistory = {
123129 location : ( ) => location ,
124- push : vi . fn ( ( next : RouteLocation ) => {
125- location = next ;
126- } ) ,
127- replace : vi . fn ( ( next : RouteLocation ) => {
128- location = next ;
129- } ) ,
130+ push,
131+ replace,
130132 listen : ( ) => ( ) => undefined ,
131133 } ;
132134 const router = createApplicationRouter ( ) ;
@@ -146,8 +148,9 @@ describe("Dynamic route startup bridge", () => {
146148 } as unknown as ApplicationContext ) ;
147149
148150 expect ( loader ) . toHaveBeenCalledOnce ( ) ;
149- expect ( router . getState ( ) . location ) . toEqual ( initialLocation ) ;
150151 expect ( router . getState ( ) . matches [ 0 ] ?. location ) . toEqual ( initialLocation ) ;
152+ expect ( push ) . not . toHaveBeenCalled ( ) ;
153+ expect ( replace ) . not . toHaveBeenCalled ( ) ;
151154 } finally {
152155 router . stop ( ) ;
153156 route . loader = originalLoader ;
@@ -183,7 +186,7 @@ describe("Dynamic route startup bridge", () => {
183186 if ( ! route ) {
184187 throw new Error ( "Chat route missing" ) ;
185188 }
186- const loader = vi . fn ( async ( ) => ( { } ) ) ;
189+ const loader = vi . fn < NonNullable < typeof route . loader > > ( async ( ) => ( { } ) ) ;
187190 const originalLoader = route . loader ;
188191 const originalComponent = route . component ;
189192 try {
@@ -204,7 +207,7 @@ describe("Dynamic route startup bridge", () => {
204207
205208 await vi . waitFor ( ( ) => {
206209 expect ( loader ) . toHaveBeenCalledTimes ( 2 ) ;
207- expect ( router . getState ( ) . location ) . toEqual ( location ) ;
210+ expect ( loader . mock . calls [ 1 ] ?. [ 1 ] . location ) . toEqual ( location ) ;
208211 } ) ;
209212 } finally {
210213 router . stop ( ) ;
@@ -372,57 +375,6 @@ describe("Agent panel route paths", () => {
372375 expect ( agentRouteFromPath ( "/settings/agents/research/tools/extra" ) ) . toBeNull ( ) ;
373376 } ) ;
374377
375- it ( "publishes the real dynamic pathname after the exact-match startup bridge" , async ( ) => {
376- let location : RouteLocation = {
377- pathname : "/settings/agents/team%2Ewriter/tools" ,
378- search : "?probe=1" ,
379- hash : "#catalog" ,
380- } ;
381- const push = vi . fn ( ( next : RouteLocation ) => {
382- location = next ;
383- } ) ;
384- const replace = vi . fn ( ( next : RouteLocation ) => {
385- location = next ;
386- } ) ;
387- const history : RouterHistory = {
388- location : ( ) => location ,
389- push,
390- replace,
391- listen : ( ) => ( ) => undefined ,
392- } ;
393- const router = createApplicationRouter ( ) ;
394- const agentsRoute = router . getRoute ( "agents" ) ;
395- if ( ! agentsRoute ) {
396- throw new Error ( "Agents route missing" ) ;
397- }
398- agentsRoute . component = async ( ) => ( { render : ( ) => null } ) ;
399- const agentsList = {
400- defaultId : "main" ,
401- mainKey : "main" ,
402- scope : "agent" ,
403- agents : [ { id : "main" } , { id : "team.writer" } ] ,
404- } ;
405- const context = {
406- basePath : "" ,
407- gateway : { snapshot : { phase : "stopped" , client : null } } ,
408- agents : {
409- state : { agentsList, agentsError : null } ,
410- ensureList : ( ) => Promise . resolve ( agentsList ) ,
411- } ,
412- } as unknown as ApplicationContext ;
413-
414- await startApplicationRouter ( router , history , "" , context ) ;
415-
416- expect ( router . getState ( ) . location ) . toEqual ( location ) ;
417- expect ( router . getState ( ) . matches [ 0 ] ?. location ) . toEqual ( location ) ;
418- expect ( location . pathname ) . toBe ( "/settings/agents/team%2Ewriter/tools" ) ;
419- expect ( location . search ) . toBe ( "?probe=1" ) ;
420- expect ( location . hash ) . toBe ( "#catalog" ) ;
421- expect ( push ) . not . toHaveBeenCalled ( ) ;
422- expect ( replace ) . not . toHaveBeenCalled ( ) ;
423- router . stop ( ) ;
424- } ) ;
425-
426378 it ( "normalizes an invalid panel once before the startup bridge" , async ( ) => {
427379 let location : RouteLocation = {
428380 pathname : "/settings/agents/main/unknown" ,
@@ -504,48 +456,6 @@ describe("Memory tab route paths", () => {
504456 expect ( routeIdFromPath ( "/settings/memory/unknown" ) ) . toBeNull ( ) ;
505457 expect ( routeIdFromPath ( "/settings/memory/dreams/extra" ) ) . toBeNull ( ) ;
506458 } ) ;
507-
508- it ( "publishes the real dynamic pathname after the exact-match startup bridge" , async ( ) => {
509- let location : RouteLocation = {
510- pathname : "/settings/memory/settings" ,
511- search : "" ,
512- hash : "#memory-backend" ,
513- } ;
514- const push = vi . fn ( ( next : RouteLocation ) => {
515- location = next ;
516- } ) ;
517- const replace = vi . fn ( ( next : RouteLocation ) => {
518- location = next ;
519- } ) ;
520- const history : RouterHistory = {
521- location : ( ) => location ,
522- push,
523- replace,
524- listen : ( ) => ( ) => undefined ,
525- } ;
526- const router = createApplicationRouter ( ) ;
527- const memoryRoute = router . getRoute ( "memory" ) ;
528- if ( ! memoryRoute ) {
529- throw new Error ( "Memory route missing" ) ;
530- }
531- memoryRoute . component = async ( ) => ( { render : ( ) => null } ) ;
532- const context = {
533- basePath : "" ,
534- runtimeConfig : {
535- ensureLoaded : ( ) => Promise . resolve ( ) ,
536- ensureSchemaLoaded : ( ) => Promise . resolve ( ) ,
537- } ,
538- } as unknown as ApplicationContext ;
539-
540- await startApplicationRouter ( router , history , "" , context ) ;
541-
542- expect ( router . getState ( ) . location ) . toEqual ( location ) ;
543- expect ( router . getState ( ) . matches [ 0 ] ?. location ) . toEqual ( location ) ;
544- expect ( location . pathname ) . toBe ( "/settings/memory/settings" ) ;
545- expect ( push ) . not . toHaveBeenCalled ( ) ;
546- expect ( replace ) . not . toHaveBeenCalled ( ) ;
547- router . stop ( ) ;
548- } ) ;
549459} ) ;
550460
551461describe ( "Plugins hub tab route paths" , ( ) => {
@@ -574,47 +484,4 @@ describe("Plugins hub tab route paths", () => {
574484 expect ( routeIdFromPath ( "/settings/plugins/unknown" ) ) . toBeNull ( ) ;
575485 expect ( routeIdFromPath ( "/settings/plugins/discover/extra" ) ) . toBeNull ( ) ;
576486 } ) ;
577-
578- it ( "publishes the real dynamic pathname after the exact-match startup bridge" , async ( ) => {
579- let location : RouteLocation = {
580- pathname : "/settings/plugins/discover" ,
581- search : "?query=calendar" ,
582- hash : "#featured" ,
583- } ;
584- const push = vi . fn ( ( next : RouteLocation ) => {
585- location = next ;
586- } ) ;
587- const replace = vi . fn ( ( next : RouteLocation ) => {
588- location = next ;
589- } ) ;
590- const history : RouterHistory = {
591- location : ( ) => location ,
592- push,
593- replace,
594- listen : ( ) => ( ) => undefined ,
595- } ;
596- const router = createApplicationRouter ( ) ;
597- const pluginsRoute = router . getRoute ( "plugins" ) ;
598- if ( ! pluginsRoute ) {
599- throw new Error ( "Plugins route missing" ) ;
600- }
601- pluginsRoute . component = async ( ) => ( { render : ( ) => null } ) ;
602- const context = {
603- basePath : "" ,
604- gateway : {
605- snapshot : { phase : "reconnecting" , client : null } ,
606- } ,
607- } as unknown as ApplicationContext ;
608-
609- await startApplicationRouter ( router , history , "" , context ) ;
610-
611- expect ( router . getState ( ) . location ) . toEqual ( location ) ;
612- expect ( router . getState ( ) . matches [ 0 ] ?. location ) . toEqual ( location ) ;
613- expect ( location . pathname ) . toBe ( "/settings/plugins/discover" ) ;
614- expect ( location . search ) . toBe ( "?query=calendar" ) ;
615- expect ( location . hash ) . toBe ( "#featured" ) ;
616- expect ( push ) . not . toHaveBeenCalled ( ) ;
617- expect ( replace ) . not . toHaveBeenCalled ( ) ;
618- router . stop ( ) ;
619- } ) ;
620487} ) ;
0 commit comments