@@ -579,3 +579,74 @@ test("flexBundle property overrides existing value when bundle is created", asyn
579579 t . true ( manifestContent [ "sap.ui5" ] . flexBundle , "flexBundle should be overridden to true when bundle is created" ) ;
580580 t . deepEqual ( manifestContent [ "sap.ui5" ] . dependencies . libs [ "sap.ui.fl" ] , { } , "sap.ui.fl dependency should be added" ) ;
581581} ) ;
582+
583+ test ( "task does not fail when manifest.json is missing and no changes exist" , async ( t ) => {
584+ const placeholderWorkspace = {
585+ byGlob : async ( ) => [ ] , // No changes
586+ byPath : async ( path ) => {
587+ // Return null for all paths (no manifest.json, no flexibility-bundle.json)
588+ return null ;
589+ } ,
590+ write : sinon . stub ( ) . returnsArg ( 0 )
591+ } ;
592+
593+ // This should not throw an error
594+ await t . notThrowsAsync ( async ( ) => {
595+ await generateFlexChangesBundle ( {
596+ workspace : placeholderWorkspace ,
597+ taskUtil : false ,
598+ options : {
599+ projectNamespace : "sap/ui/demo/app"
600+ }
601+ } ) ;
602+ } , "Task should not fail when manifest.json is missing" ) ;
603+
604+ // No write calls should have been made since there's no manifest and no changes
605+ t . is ( placeholderWorkspace . write . callCount , 0 , "workspace.write should not be called when manifest is missing" ) ;
606+ } ) ;
607+
608+ test ( "task does not fail when manifest.json is missing but changes exist" , async ( t ) => {
609+ const changeList = [ {
610+ "fileName" : "test_change" ,
611+ "fileType" : "change" ,
612+ "changeType" : "rename" ,
613+ "reference" : "test.Component" ,
614+ "content" : { } ,
615+ "selector" : { "id" : "testId" } ,
616+ "layer" : "CUSTOMER"
617+ } ] ;
618+
619+ const placeholderWorkspace = {
620+ byGlob : async ( ) => changeList . map ( ( change ) => createPlaceholderResource ( change ) ) ,
621+ byPath : async ( path ) => {
622+ // Return null for all paths (no manifest.json, no flexibility-bundle.json)
623+ return null ;
624+ } ,
625+ write : sinon . stub ( ) . returnsArg ( 0 )
626+ } ;
627+
628+ // This should not throw an error
629+ await t . notThrowsAsync ( async ( ) => {
630+ await generateFlexChangesBundle ( {
631+ workspace : placeholderWorkspace ,
632+ taskUtil : false ,
633+ options : {
634+ projectNamespace : "sap/ui/demo/app"
635+ }
636+ } ) ;
637+ } , "Task should not fail when manifest.json is missing even with changes" ) ;
638+
639+ // Verify the task created the flexibility-bundle.json
640+ const writeCalls = [ ] ;
641+ for ( let i = 0 ; i < placeholderWorkspace . write . callCount ; i ++ ) {
642+ const call = placeholderWorkspace . write . getCall ( i ) ;
643+ const path = call . args [ 0 ] . getPath ? await call . args [ 0 ] . getPath ( ) : "unknown" ;
644+ writeCalls . push ( path ) ;
645+ }
646+
647+ // Should have written flexibility-bundle.json but NOT manifest.json
648+ t . true ( writeCalls . some ( ( path ) => path . includes ( "flexibility-bundle.json" ) ) ,
649+ "flexibility-bundle.json should be created" ) ;
650+ t . false ( writeCalls . some ( ( path ) => path . includes ( "manifest.json" ) ) ,
651+ "No manifest.json write should occur when manifest is missing" ) ;
652+ } ) ;
0 commit comments