Skip to content

Commit 9fc2509

Browse files
committed
test(project): Add cases for custom preload configs (for application, component & library)
1 parent eff1e5f commit 9fc2509

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
specVersion: "5.0"
3+
type: application
4+
metadata:
5+
name: application.a
6+
builder:
7+
componentPreload:
8+
namespaces:
9+
- "id1"
10+
excludes:
11+
- "id1/thirdparty/scriptWithSourceMap.js"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
specVersion: "5.0"
3+
type: component
4+
metadata:
5+
name: component.a
6+
builder:
7+
componentPreload:
8+
namespaces:
9+
- "id1"
10+
excludes:
11+
- "id1/test.js"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
specVersion: "5.0"
3+
type: library
4+
metadata:
5+
name: library.d
6+
copyright: Some fancy copyright
7+
resources:
8+
configuration:
9+
paths:
10+
src: main/src
11+
test: main/test
12+
builder:
13+
libraryPreload:
14+
excludes:
15+
- "library/d/some.js"

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

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,41 @@ function functionWithJSDoc(param) {return "test"}`;
561561
"Build dest does contain source map reference");
562562
});
563563

564+
test.serial("Build application.a (Custom Component preload configuration)", async (t) => {
565+
const fixtureTester = new FixtureTester(t, "application.a");
566+
const destPath = fixtureTester.destPath;
567+
568+
// In this test, we're testing the behavior of a custom preload configuration
569+
// which is defined in "ui5-custom-preload-config.yaml".
570+
// This custom preload configuration generates a Component-preload.js similar to a default one.
571+
// However, it will omit a resource ("scriptWithSourceMap.js") from the bundle.
572+
573+
// #1 build (no cache, no changes)
574+
await fixtureTester.buildProject({
575+
graphConfig: {rootConfigPath: "ui5-custom-preload-config.yaml"},
576+
config: {destPath, cleanDest: true},
577+
assertions: {
578+
projects: {
579+
"application.a": {}
580+
}
581+
}
582+
});
583+
584+
// Check that generated preload bundle doesn't contain the omitted file:
585+
t.false((await fs.readFile(`${destPath}/Component-preload.js`, {encoding: "utf8"}))
586+
.includes("id1/thirdparty/scriptWithSourceMap.js"));
587+
588+
589+
// #2 build (with cache, no changes)
590+
await fixtureTester.buildProject({
591+
graphConfig: {rootConfigPath: "ui5-custom-preload-config.yaml"},
592+
config: {destPath, cleanDest: true},
593+
assertions: {
594+
projects: {}
595+
}
596+
});
597+
});
598+
564599
test.serial("Build library.d project multiple times", async (t) => {
565600
const fixtureTester = new FixtureTester(t, "library.d");
566601
const destPath = fixtureTester.destPath;
@@ -651,6 +686,41 @@ test.serial("Build library.d project multiple times", async (t) => {
651686
});
652687
});
653688

689+
test.serial("Build library.d (Custom Library preload configuration)", async (t) => {
690+
const fixtureTester = new FixtureTester(t, "library.d");
691+
const destPath = fixtureTester.destPath;
692+
693+
// In this test, we're testing the behavior of a custom preload configuration
694+
// which is defined in "ui5-custom-preload-config.yaml".
695+
// This custom preload configuration generates a library-preload.js similar to a default one.
696+
// However, it will omit a resource ("some.js") from the bundle.
697+
698+
// #1 build (no cache, no changes)
699+
await fixtureTester.buildProject({
700+
graphConfig: {rootConfigPath: "ui5-custom-preload-config.yaml"},
701+
config: {destPath, cleanDest: true},
702+
assertions: {
703+
projects: {
704+
"library.d": {}
705+
}
706+
}
707+
});
708+
709+
// Check that generated preload bundle doesn't contain the omitted file:
710+
t.false((await fs.readFile(`${destPath}/resources/library/d/library-preload.js`, {encoding: "utf8"}))
711+
.includes("library/d/some.js"));
712+
713+
714+
// #2 build (with cache, no changes)
715+
await fixtureTester.buildProject({
716+
graphConfig: {rootConfigPath: "ui5-custom-preload-config.yaml"},
717+
config: {destPath, cleanDest: true},
718+
assertions: {
719+
projects: {}
720+
}
721+
});
722+
});
723+
654724
test.serial("Build theme.library.e project multiple times", async (t) => {
655725
const fixtureTester = new FixtureTester(t, "theme.library.e");
656726
const destPath = fixtureTester.destPath;
@@ -886,6 +956,41 @@ test.serial("Build component.a project multiple times", async (t) => {
886956
});
887957
});
888958

959+
test.serial("Build component.a (Custom Component preload configuration)", async (t) => {
960+
const fixtureTester = new FixtureTester(t, "component.a");
961+
const destPath = fixtureTester.destPath;
962+
963+
// In this test, we're testing the behavior of a custom preload configuration
964+
// which is defined in "ui5-custom-preload-config.yaml".
965+
// This custom preload configuration generates a Component-preload.js similar to a default one.
966+
// However, it will omit a resource ("test.js") from the bundle.
967+
968+
// #1 build (no cache, no changes)
969+
await fixtureTester.buildProject({
970+
graphConfig: {rootConfigPath: "ui5-custom-preload-config.yaml"},
971+
config: {destPath, cleanDest: true},
972+
assertions: {
973+
projects: {
974+
"component.a": {}
975+
}
976+
}
977+
});
978+
979+
// Check that generated preload bundle doesn't contain the omitted file:
980+
t.false((await fs.readFile(`${destPath}/resources/id1/Component-preload.js`, {encoding: "utf8"}))
981+
.includes("id1/test.js"));
982+
983+
984+
// #2 build (with cache, no changes)
985+
await fixtureTester.buildProject({
986+
graphConfig: {rootConfigPath: "ui5-custom-preload-config.yaml"},
987+
config: {destPath, cleanDest: true},
988+
assertions: {
989+
projects: {}
990+
}
991+
});
992+
});
993+
889994
test.serial("Build module.b project multiple times", async (t) => {
890995
const fixtureTester = new FixtureTester(t, "module.b");
891996
const destPath = fixtureTester.destPath;

0 commit comments

Comments
 (0)