Skip to content

Commit 68eed12

Browse files
committed
test(project): Add case for self-contained builds (Standard Tasks)
1 parent 7950b5c commit 68eed12

1 file changed

Lines changed: 102 additions & 0 deletions

File tree

packages/project/test/lib/build/ProjectBuilder.integration.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,108 @@ test.serial("Build application.a (Custom Component preload configuration)", asyn
596596
});
597597
});
598598

599+
test.serial("Build application.a (self-contained build)", async (t) => {
600+
const fixtureTester = new FixtureTester(t, "application.a");
601+
const destPath = fixtureTester.destPath;
602+
603+
// We're executing a self-contained build including dependencies (as with "ui5 build self-contained --all")
604+
// and testing if the output contains the expected self-contained bundle.
605+
// Then, we're changing the content only of application.a
606+
// and testing if the self-contained build output changes accordingly.
607+
608+
// #1 build (no cache, no changes)
609+
await fixtureTester.buildProject({
610+
graphConfig: {rootConfigPath: "ui5.yaml"},
611+
config: {destPath, cleanDest: true, selfContained: "self-contained",
612+
dependencyIncludes: {includeAllDependencies: true}},
613+
assertions: {
614+
projects: {
615+
"library.d": {},
616+
"library.a": {},
617+
"library.b": {},
618+
"library.c": {},
619+
"application.a": {}
620+
}
621+
}
622+
});
623+
624+
// Check that output contains the correct content:
625+
const builtFileContent = await fs.readFile(`${destPath}/resources/sap-ui-custom.js`, {encoding: "utf8"});
626+
t.true(builtFileContent.includes(`"id1/test.js":'function test(t){var o=t;console.log(o)}test();\\n'`));
627+
628+
629+
// #2 build (with cache, no changes)
630+
await fixtureTester.buildProject({
631+
graphConfig: {rootConfigPath: "ui5.yaml"},
632+
config: {destPath, cleanDest: true, selfContained: "self-contained",
633+
dependencyIncludes: {includeAllDependencies: true}},
634+
assertions: {
635+
projects: {}
636+
}
637+
});
638+
639+
640+
// Remove the file "test.js" from application.a:
641+
await fs.rm(`${fixtureTester.fixturePath}/webapp/test.js`);
642+
643+
// #3 build (with cache, with changes)
644+
// Dependencies should get skipped, application.a should get rebuilt:
645+
await fixtureTester.buildProject({
646+
graphConfig: {rootConfigPath: "ui5.yaml"},
647+
config: {destPath, cleanDest: true, selfContained: "self-contained",
648+
dependencyIncludes: {includeAllDependencies: true}},
649+
assertions: {
650+
projects: {
651+
"application.a": {
652+
skippedTasks: [
653+
"enhanceManifest",
654+
"escapeNonAsciiCharacters",
655+
"generateFlexChangesBundle",
656+
"replaceCopyright",
657+
"transformBootstrapHtml",
658+
]
659+
}
660+
}
661+
}
662+
});
663+
664+
// Check that output contains the correct content (test.js should be missing):
665+
const builtFileContent2 = await fs.readFile(`${destPath}/resources/sap-ui-custom.js`, {encoding: "utf8"});
666+
t.false(builtFileContent2.includes(`"id1/test.js":`));
667+
668+
669+
// #4 build (with cache, no changes)
670+
// Run a self-contained build but with a different config which defines a custom preload.
671+
// The build should run and the output should still contain the expected self-contained bundle
672+
// (tasks "generateComponentPreload" and "generateLibraryPreload" should not get executed):
673+
await fixtureTester.buildProject({
674+
graphConfig: {rootConfigPath: "ui5-custom-preload-config.yaml"},
675+
config: {destPath, cleanDest: true, selfContained: "self-contained",
676+
dependencyIncludes: {includeAllDependencies: true}},
677+
assertions: {
678+
projects: {
679+
"application.a": {}
680+
}
681+
}
682+
});
683+
684+
// Check that output contains still the correct content:
685+
const builtFileContent3 = await fs.readFile(`${destPath}/resources/sap-ui-custom.js`, {encoding: "utf8"});
686+
t.false(builtFileContent3.includes(`"id1/test.js":`));
687+
688+
689+
// #5 build (with cache, no changes)
690+
// Run a self-contained build but without dependencies:
691+
// (everything should get skipped)
692+
await fixtureTester.buildProject({
693+
graphConfig: {rootConfigPath: "ui5.yaml"},
694+
config: {destPath, cleanDest: true, selfContained: "self-contained"},
695+
assertions: {
696+
projects: {}
697+
}
698+
});
699+
});
700+
599701
test.serial("Build library.d project multiple times", async (t) => {
600702
const fixtureTester = new FixtureTester(t, "library.d");
601703
const destPath = fixtureTester.destPath;

0 commit comments

Comments
 (0)