@@ -444,6 +444,123 @@ test.serial.skip("Build application.a (dependency content changes)", async (t) =
444444 t . true ( builtFileContent2 . includes ( `console.log('something new');` ) , "Build dest contains changed file content" ) ;
445445} ) ;
446446
447+ test . serial ( "Build application.a (JSDoc build)" , async ( t ) => {
448+ const fixtureTester = new FixtureTester ( t , "application.a" ) ;
449+ const destPath = fixtureTester . destPath ;
450+
451+ // This test should cover a scenario with an application depending on a library.
452+ // We're executing a JSDoc build including dependencies (as with "ui5 build jsdoc --all")
453+ // and testing if the output contains the expected JSDoc contents.
454+ // Then, we're adding some additional JSDoc annotations to the library
455+ // and testing the same again.
456+
457+ // #1 build (no cache, no changes)
458+ await fixtureTester . buildProject ( {
459+ graphConfig : { rootConfigPath : "ui5.yaml" } ,
460+ config : { destPath, cleanDest : true , jsdoc : "jsdoc" , dependencyIncludes : { includeAllDependencies : true } } ,
461+ assertions : {
462+ projects : {
463+ "library.d" : { } ,
464+ "library.a" : { } ,
465+ "library.b" : { } ,
466+ "library.c" : { } ,
467+ "application.a" : { }
468+ }
469+ }
470+ } ) ;
471+
472+ // Check that JSDoc build ran successfully:
473+ await t . throwsAsync ( fs . readFile ( `${ destPath } /resources/library/d/some-dbg.js` , { encoding : "utf8" } ) ) ;
474+ await t . throwsAsync ( fs . readFile ( `${ destPath } /resources/library/d/some.js.map` , { encoding : "utf8" } ) ) ;
475+ const builtFileContent = await fs . readFile ( `${ destPath } /resources/library/d/some.js` , { encoding : "utf8" } ) ;
476+ // Check that output contains correct file content:
477+ t . false ( builtFileContent . includes ( `//# sourceMappingURL=some.js.map` ) ,
478+ "Build dest does not contain source map reference" ) ;
479+
480+
481+ // #2 build (with cache, no changes)
482+ await fixtureTester . buildProject ( {
483+ graphConfig : { rootConfigPath : "ui5.yaml" } ,
484+ config : { destPath, cleanDest : true , jsdoc : "jsdoc" , dependencyIncludes : { includeAllDependencies : true } } ,
485+ assertions : {
486+ projects : { }
487+ }
488+ } ) ;
489+
490+
491+ // Add additional JSDoc annotations to library.d:
492+ const jsdocContent = `/*!
493+ * ` + "${copyright}" + `
494+ */
495+
496+ /**
497+ * Example JSDoc annotation
498+ *
499+ * @public
500+ * @static
501+ * @param {object} param
502+ * @returns {string} output
503+ */
504+ function functionWithJSDoc(param) {return "test"}` ;
505+
506+ await fs . writeFile ( `${ fixtureTester . fixturePath } /node_modules/library.d/main/src/library/d/some.js` ,
507+ jsdocContent ) ;
508+
509+ // #3 build (no cache, with changes)
510+ // application.a should get skipped:
511+ await fixtureTester . buildProject ( {
512+ graphConfig : { rootConfigPath : "ui5.yaml" } ,
513+ config : { destPath, cleanDest : true , jsdoc : "jsdoc" , dependencyIncludes : { includeAllDependencies : true } } ,
514+ assertions : {
515+ projects : {
516+ "library.d" : {
517+ skippedTasks : [
518+ "buildThemes" ,
519+ "enhanceManifest" ,
520+ "escapeNonAsciiCharacters" ,
521+ "executeJsdocSdkTransformation" ,
522+ ]
523+ }
524+ }
525+ }
526+ } ) ;
527+
528+ // Check that JSDoc build ran successfully:
529+ await t . throwsAsync ( fs . readFile ( `${ destPath } /resources/library/d/some-dbg.js` , { encoding : "utf8" } ) ) ;
530+ await t . throwsAsync ( fs . readFile ( `${ destPath } /resources/library/d/some.js.map` , { encoding : "utf8" } ) ) ;
531+ const builtFileContent2 = await fs . readFile ( `${ destPath } /resources/library/d/some.js` , { encoding : "utf8" } ) ;
532+ t . true ( builtFileContent2 . includes ( `Example JSDoc annotation` ) , "Build dest contains new JSDoc content" ) ;
533+ // Check that output contains new file content:
534+ t . false ( builtFileContent2 . includes ( `//# sourceMappingURL=some.js.map` ) ,
535+ "Build dest does not contain source map reference" ) ;
536+
537+
538+ // #4 build (no cache, no changes)
539+ // Normal build again (non-JSDoc build); should not execute task "generateJsdoc":
540+ await fixtureTester . buildProject ( {
541+ graphConfig : { rootConfigPath : "ui5.yaml" } ,
542+ config : { destPath, cleanDest : true , dependencyIncludes : { includeAllDependencies : true } } ,
543+ assertions : {
544+ projects : {
545+ "library.d" : { } ,
546+ "library.a" : { } ,
547+ "library.b" : { } ,
548+ "library.c" : { } ,
549+ "application.a" : { }
550+ }
551+ }
552+ } ) ;
553+
554+ // Check that normal build ran successfully:
555+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/d/some-dbg.js` , { encoding : "utf8" } ) ) ;
556+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/d/some.js.map` , { encoding : "utf8" } ) ) ;
557+ const builtFileContent3 = await fs . readFile ( `${ destPath } /resources/library/d/some.js` , { encoding : "utf8" } ) ;
558+ t . false ( builtFileContent3 . includes ( `Example JSDoc annotation` ) , "Build dest doesn't contain JSDoc content anymore" ) ;
559+ // Check that output contains content generated by the normal build:
560+ t . true ( builtFileContent3 . includes ( `//# sourceMappingURL=some.js.map` ) ,
561+ "Build dest does contain source map reference" ) ;
562+ } ) ;
563+
447564test . serial ( "Build library.d project multiple times" , async ( t ) => {
448565 const fixtureTester = new FixtureTester ( t , "library.d" ) ;
449566 const destPath = fixtureTester . destPath ;
0 commit comments