@@ -571,6 +571,39 @@ suite("routerResolver", () => {
571571 assert . strictEqual ( result , null )
572572 } )
573573
574+ test ( "follows imported factory function to resolve include_router calls" , async ( ) => {
575+ const result = await buildRouterGraph (
576+ fixtures . factoryFunc . factoryMainPy ,
577+ parser ,
578+ fixtures . factoryFunc . root ,
579+ nodeFileSystem ,
580+ "app" ,
581+ )
582+
583+ assert . ok ( result , "Should find app via imported factory function" )
584+ assert . strictEqual ( result . type , "FastAPI" )
585+ assert . strictEqual ( result . variableName , "app" )
586+ assert . strictEqual (
587+ result . children . length ,
588+ 1 ,
589+ "Should have one included router" ,
590+ )
591+ assert . ok (
592+ result . children [ 0 ] . router . routes . length >= 2 ,
593+ "Should have routes from routers.py" ,
594+ )
595+ } )
596+
597+ test ( "returns null without targetVariable when factory function has no local routes" , async ( ) => {
598+ const result = await buildRouterGraph (
599+ fixtures . factoryFunc . factoryMainPy ,
600+ parser ,
601+ fixtures . factoryFunc . root ,
602+ nodeFileSystem ,
603+ )
604+ assert . strictEqual ( result , null )
605+ } )
606+
574607 test ( "resolves custom APIRouter subclass as child router" , async ( ) => {
575608 const result = await buildRouterGraph (
576609 fixtures . customSubclass . mainPy ,
0 commit comments