@@ -361,6 +361,90 @@ test.serial.skip("Build application.a (multiple custom tasks 2)", async (t) => {
361361 await t . throwsAsync ( fs . readFile ( `${ destPath } /test.js` , { encoding : "utf8" } ) ) ;
362362} ) ;
363363
364+ test . only ( "Build application.a (dependency content changes)" , async ( t ) => {
365+ const fixtureTester = new FixtureTester ( t , "application.a" ) ;
366+ const destPath = fixtureTester . destPath ;
367+
368+ // This test should cover a scenario with an application depending on a library.
369+ // Specifically, we're directly modifying the contents of the library
370+ // which should have effects on the application because a custom task will detect it
371+ // and modify the application's resources. The application is expected to get rebuilt.
372+
373+ // #1 build (no cache, no changes, no dependencies)
374+ await fixtureTester . buildProject ( {
375+ graphConfig : { rootConfigPath : "ui5-customTask-dependency-change.yaml" } ,
376+ config : { destPath, cleanDest : true } ,
377+ assertions : {
378+ projects : {
379+ "application.a" : { }
380+ }
381+ }
382+ } ) ;
383+
384+
385+ // #2 build (with cache, no changes, no dependencies)
386+ await fixtureTester . buildProject ( {
387+ graphConfig : { rootConfigPath : "ui5-customTask-dependency-change.yaml" } ,
388+ config : { destPath, cleanDest : true } ,
389+ assertions : {
390+ projects : { }
391+ }
392+ } ) ;
393+
394+
395+ // Change content of library.d (this will not affect application.a):
396+ const someJsOfLibrary = `${ fixtureTester . fixturePath } /node_modules/library.d/main/src/library/d/some.js` ;
397+ await fs . appendFile ( someJsOfLibrary , `\ntest("line added");\n` ) ;
398+
399+ // #3 build (with cache, with changes, with dependencies)
400+ await fixtureTester . buildProject ( {
401+ graphConfig : { rootConfigPath : "ui5-customTask-dependency-change.yaml" } ,
402+ config : { destPath, cleanDest : true , dependencyIncludes : { includeAllDependencies : true } } ,
403+ assertions : {
404+ projects : {
405+ "library.d" : { } ,
406+ "library.a" : { } ,
407+ "library.b" : { } ,
408+ "library.c" : { } ,
409+ }
410+ }
411+ } ) ;
412+
413+ // Check if library contains correct changed content:
414+ const builtFileContent = await fs . readFile ( `${ destPath } /resources/library/d/some.js` , { encoding : "utf8" } ) ;
415+ t . true ( builtFileContent . includes ( `test("line added");` ) , "Build dest contains changed file content" ) ;
416+
417+
418+ // Change content of library.d again (this time it affects application.a):
419+ await fs . writeFile ( `${ fixtureTester . fixturePath } /node_modules/library.d/main/src/library/d/newLibraryFile.js` ,
420+ `console.log("SOME NEW CONTENT");` ) ;
421+
422+ // #4 build (no cache, with changes, with dependencies)
423+ // This build should execute the custom task "task.dependency-change.js" again which now detects "newLibraryFile.js"
424+ // and modifies a resource of application.a (namely "test.js").
425+ await fixtureTester . buildProject ( {
426+ graphConfig : { rootConfigPath : "ui5-customTask-dependency-change.yaml" } ,
427+ config : { destPath, cleanDest : true , dependencyIncludes : { includeAllDependencies : true } } ,
428+ assertions : {
429+ projects : {
430+ "library.d" : { } ,
431+ "application.a" : { // FIXME: currently failing (getting skipped entirely)
432+ skippedTasks : [
433+ "enhanceManifest" ,
434+ "escapeNonAsciiCharacters" ,
435+ "generateFlexChangesBundle" ,
436+ "replaceCopyright" ,
437+ ]
438+ } ,
439+ }
440+ }
441+ } ) ;
442+
443+ // Check that application.a contains correct changed content (test.js):
444+ const builtFileContent2 = await fs . readFile ( `${ destPath } /test.js` , { encoding : "utf8" } ) ;
445+ t . true ( builtFileContent2 . includes ( `console.log('something new');` ) , "Build dest contains changed file content" ) ;
446+ } ) ;
447+
364448test . serial ( "Build library.d project multiple times" , async ( t ) => {
365449 const fixtureTester = new FixtureTester ( t , "library.d" ) ;
366450 const destPath = fixtureTester . destPath ;
0 commit comments