Skip to content

Commit a263757

Browse files
committed
test(project): Add modify file case for modules
´+´ style: Apply same line padding: (within a build stage: 1 empty line; between two build stages: 2 empty lines)
1 parent f1d4bff commit a263757

1 file changed

Lines changed: 66 additions & 9 deletions

File tree

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

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ test.serial("Build application.a project multiple times", async (t) => {
4949
}
5050
});
5151

52+
5253
// #2 build (with cache, no changes)
5354
await fixtureTester.buildProject({
5455
config: {destPath, cleanDest: true},
@@ -57,6 +58,7 @@ test.serial("Build application.a project multiple times", async (t) => {
5758
}
5859
});
5960

61+
6062
// Change a source file in application.a
6163
const changedFilePath = `${fixtureTester.fixturePath}/webapp/test.js`;
6264
await fs.appendFile(changedFilePath, `\ntest("line added");\n`);
@@ -83,6 +85,7 @@ test.serial("Build application.a project multiple times", async (t) => {
8385
const builtFileContent = await fs.readFile(`${destPath}/test.js`, {encoding: "utf8"});
8486
t.true(builtFileContent.includes(`test("line added");`), "Build dest contains changed file content");
8587

88+
8689
// #4 build (with cache, no changes, with dependencies)
8790
await fixtureTester.buildProject({
8891
config: {destPath, cleanDest: true, dependencyIncludes: {includeAllDependencies: true}},
@@ -96,6 +99,7 @@ test.serial("Build application.a project multiple times", async (t) => {
9699
}
97100
});
98101

102+
99103
// #5 build (with cache, no changes)
100104
await fixtureTester.buildProject({
101105
config: {destPath, cleanDest: true},
@@ -104,6 +108,7 @@ test.serial("Build application.a project multiple times", async (t) => {
104108
}
105109
});
106110

111+
107112
// #6 build (with cache, no changes, with dependencies)
108113
await fixtureTester.buildProject({
109114
config: {destPath, cleanDest: true, dependencyIncludes: {includeAllDependencies: true}},
@@ -112,6 +117,7 @@ test.serial("Build application.a project multiple times", async (t) => {
112117
}
113118
});
114119

120+
115121
// #6 build (with cache, no changes, with custom tasks)
116122
await fixtureTester.buildProject({
117123
graphConfig: {rootConfigPath: "ui5-customTask.yaml"},
@@ -123,6 +129,7 @@ test.serial("Build application.a project multiple times", async (t) => {
123129
}
124130
});
125131

132+
126133
// #7 build (with cache, no changes, with custom tasks)
127134
await fixtureTester.buildProject({
128135
graphConfig: {rootConfigPath: "ui5-customTask.yaml"},
@@ -132,6 +139,7 @@ test.serial("Build application.a project multiple times", async (t) => {
132139
}
133140
});
134141

142+
135143
// #8 build (with cache, no changes, with dependencies)
136144
await fixtureTester.buildProject({
137145
config: {destPath, cleanDest: true, dependencyIncludes: {includeAllDependencies: true}},
@@ -140,6 +148,7 @@ test.serial("Build application.a project multiple times", async (t) => {
140148
}
141149
});
142150

151+
143152
// Change a source file with existing source map in application.a
144153
const fileWithSourceMapPath =
145154
`${fixtureTester.fixturePath}/webapp/thirdparty/scriptWithSourceMap.js`;
@@ -195,6 +204,7 @@ test.serial.skip("Build application.a (custom task and tag handling)", async (t)
195204
}
196205
});
197206

207+
198208
// Create new file which should get tagged as "OmitFromBuildResult" by a custom task
199209
await fs.writeFile(`${fixtureTester.fixturePath}/webapp/fileToBeOmitted.js`,
200210
`console.log("this file should be ommited in the build result")`);
@@ -221,6 +231,7 @@ test.serial.skip("Build application.a (custom task and tag handling)", async (t)
221231
// Check that fileToBeOmitted.js is not in dist
222232
await t.throwsAsync(fs.readFile(`${destPath}/fileToBeOmitted.js`, {encoding: "utf8"}));
223233

234+
224235
// #3 build (with cache, no changes, with custom tasks)
225236
await fixtureTester.buildProject({
226237
graphConfig: {rootConfigPath: "ui5-customTask.yaml"},
@@ -233,6 +244,7 @@ test.serial.skip("Build application.a (custom task and tag handling)", async (t)
233244
// Check that fileToBeOmitted.js is not in dist again --> FIXME: Currently failing here
234245
await t.throwsAsync(fs.readFile(`${destPath}/fileToBeOmitted.js`, {encoding: "utf8"}));
235246

247+
236248
// Delete the file again
237249
await fs.rm(`${fixtureTester.fixturePath}/webapp/fileToBeOmitted.js`);
238250

@@ -258,6 +270,7 @@ test.serial("Build library.d project multiple times", async (t) => {
258270
}
259271
});
260272

273+
261274
// #2 build (with cache, no changes)
262275
await fixtureTester.buildProject({
263276
config: {destPath, cleanDest: true},
@@ -266,6 +279,7 @@ test.serial("Build library.d project multiple times", async (t) => {
266279
}
267280
});
268281

282+
269283
// Change a source file in library.d
270284
const changedFilePath = `${fixtureTester.fixturePath}/main/src/library/d/.library`;
271285
await fs.writeFile(
@@ -305,6 +319,7 @@ test.serial("Build library.d project multiple times", async (t) => {
305319
"Build dest contains updated description in manifest.json"
306320
);
307321

322+
308323
// #4 build (with cache, no changes)
309324
await fixtureTester.buildProject({
310325
config: {destPath, cleanDest: true},
@@ -313,6 +328,7 @@ test.serial("Build library.d project multiple times", async (t) => {
313328
}
314329
});
315330

331+
316332
// Update copyright in ui5.yaml (should trigger a full rebuild of the project)
317333
const ui5YamlPath = `${fixtureTester.fixturePath}/ui5.yaml`;
318334
await fs.writeFile(
@@ -344,6 +360,7 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
344360
}
345361
});
346362

363+
347364
// #2 build (with cache, no changes)
348365
await fixtureTester.buildProject({
349366
config: {destPath, cleanDest: true},
@@ -352,17 +369,20 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
352369
}
353370
});
354371

372+
355373
// Change a source file in theme.library.e
356374
const librarySourceFilePath =
357375
`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/library.source.less`;
358376
await fs.appendFile(librarySourceFilePath, `\n.someNewClass {\n\tcolor: red;\n}\n`);
377+
359378
// #3 build (with cache, with changes)
360379
await fixtureTester.buildProject({
361380
config: {destPath, cleanDest: true},
362381
assertions: {
363382
projects: {"theme.library.e": {}}
364383
}
365384
});
385+
366386
// Check whether the changed file is in the destPath
367387
const builtFileContent = await fs.readFile(
368388
`${destPath}/resources/theme/library/e/themes/my_theme/library.source.less`, {encoding: "utf8"}
@@ -371,6 +391,7 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
371391
builtFileContent.includes(`.someNewClass`),
372392
"Build dest contains changed file content"
373393
);
394+
374395
// Check whether the build output contains the new CSS rule
375396
const builtCssContent = await fs.readFile(
376397
`${destPath}/resources/theme/library/e/themes/my_theme/library.css`, {encoding: "utf8"}
@@ -380,18 +401,21 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
380401
"Build dest contains new rule in library.css"
381402
);
382403

404+
383405
// Add a new less file and import it in library.source.less
384406
await fs.writeFile(`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/newImportFile.less`,
385407
`.someOtherNewClass {\n\tcolor: blue;\n}\n`
386408
);
387409
await fs.appendFile(librarySourceFilePath, `\n@import "newImportFile.less";\n`);
410+
388411
// #4 build (with cache, with changes)
389412
await fixtureTester.buildProject({
390413
config: {destPath, cleanDest: true},
391414
assertions: {
392415
projects: {"theme.library.e": {}},
393416
}
394417
});
418+
395419
// Check whether the build output contains the import to the new file
396420
const builtCssContent2 = await fs.readFile(
397421
`${destPath}/resources/theme/library/e/themes/my_theme/library.css`, {encoding: "utf8"}
@@ -401,6 +425,7 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
401425
"Build dest contains new rule in library.css"
402426
);
403427

428+
404429
// #5 build (with cache, no changes)
405430
await fixtureTester.buildProject({
406431
config: {destPath, cleanDest: true},
@@ -409,17 +434,20 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
409434
}
410435
});
411436

437+
412438
// Change content of new less file
413439
await fs.writeFile(`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/newImportFile.less`,
414440
`.someOtherNewClass {\n\tcolor: green;\n}\n`
415441
);
442+
416443
// #6 build (with cache, with changes)
417444
await fixtureTester.buildProject({
418445
config: {destPath, cleanDest: true},
419446
assertions: {
420447
projects: {"theme.library.e": {}},
421448
}
422449
});
450+
423451
// Check whether the build output contains the changed content of the imported file
424452
const builtCssContent3 = await fs.readFile(
425453
`${destPath}/resources/theme/library/e/themes/my_theme/library.css`, {encoding: "utf8"}
@@ -429,15 +457,18 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
429457
"Build dest contains new rule in library.css"
430458
);
431459

460+
432461
// Delete import of library.source.less
433462
const librarySourceFileContent = (await fs.readFile(librarySourceFilePath)).toString();
434463
await fs.writeFile(librarySourceFilePath,
435464
librarySourceFileContent.replace(`\n@import "newImportFile.less";\n`, "")
436465
);
466+
437467
// Change content of new less file again
438468
await fs.writeFile(`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/newImportFile.less`,
439469
`.someOtherNewClass {\n\tcolor: yellow;\n}\n`
440470
);
471+
441472
// #7 build (with cache, with changes)
442473
await fixtureTester.buildProject({
443474
config: {destPath, cleanDest: true},
@@ -456,6 +487,7 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
456487
"Build dest should NOT contain the rule in library.css anymore"
457488
);
458489

490+
459491
// Delete the imported less file
460492
await fs.rm(`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/newImportFile.less`);
461493

@@ -472,7 +504,6 @@ test.serial("Build component.a project multiple times", async (t) => {
472504
const fixtureTester = new FixtureTester(t, "component.a");
473505
const destPath = fixtureTester.destPath;
474506

475-
476507
// #1 build (no cache, no changes)
477508
await fixtureTester.buildProject({
478509
config: {destPath, cleanDest: true},
@@ -483,6 +514,7 @@ test.serial("Build component.a project multiple times", async (t) => {
483514
}
484515
});
485516

517+
486518
// #2 build (with cache, no changes)
487519
await fixtureTester.buildProject({
488520
config: {destPath, cleanDest: true},
@@ -491,6 +523,7 @@ test.serial("Build component.a project multiple times", async (t) => {
491523
}
492524
});
493525

526+
494527
// Change a source file in component.a
495528
const changedFilePath = `${fixtureTester.fixturePath}/src/test.js`;
496529
await fs.appendFile(changedFilePath, `\ntest("line added");\n`);
@@ -517,6 +550,7 @@ test.serial("Build component.a project multiple times", async (t) => {
517550
const builtFileContent = await fs.readFile(`${destPath}/resources/id1/test.js`, {encoding: "utf8"});
518551
t.true(builtFileContent.includes(`test("line added");`), "Build dest contains changed file content");
519552

553+
520554
// #4 build (with cache, no changes, with dependencies)
521555
await fixtureTester.buildProject({
522556
config: {destPath, cleanDest: true, dependencyIncludes: {includeAllDependencies: true}},
@@ -530,6 +564,7 @@ test.serial("Build component.a project multiple times", async (t) => {
530564
}
531565
});
532566

567+
533568
// #5 build (with cache, no changes)
534569
await fixtureTester.buildProject({
535570
config: {destPath, cleanDest: true},
@@ -538,6 +573,7 @@ test.serial("Build component.a project multiple times", async (t) => {
538573
}
539574
});
540575

576+
541577
// #6 build (with cache, no changes, with dependencies)
542578
await fixtureTester.buildProject({
543579
config: {destPath, cleanDest: true, dependencyIncludes: {includeAllDependencies: true}},
@@ -559,6 +595,7 @@ test.serial("Build module.b project multiple times", async (t) => {
559595
},
560596
});
561597

598+
562599
// #2 build (with cache, no changes)
563600
await fixtureTester.buildProject({
564601
config: {destPath, cleanDest: true},
@@ -568,10 +605,27 @@ test.serial("Build module.b project multiple times", async (t) => {
568605
});
569606

570607

608+
// Change a source file in module.b
609+
const changedFilePath = `${fixtureTester.fixturePath}/dev/devTools.js`;
610+
await fs.appendFile(changedFilePath, `\ntest("line added");\n`);
611+
612+
// #3 build (no cache, with changes)
613+
await fixtureTester.buildProject({
614+
config: {destPath, cleanDest: true},
615+
assertions: {
616+
projects: {"module.b": {}}
617+
}
618+
});
619+
620+
// Check whether the changed file is in the destPath
621+
const builtFileContent = await fs.readFile(`${destPath}/resources/b/module/dev/devTools.js`, {encoding: "utf8"});
622+
t.true(builtFileContent.includes(`test("line added");`), "Build dest contains changed file content");
623+
624+
571625
// Remove a source file in module.b
572626
await fs.rm(`${fixtureTester.fixturePath}/dev/devTools.js`);
573627

574-
// #3 build (no cache, with changes)
628+
// #4 build (no cache, with changes)
575629
await fixtureTester.buildProject({
576630
config: {destPath, cleanDest: true},
577631
assertions: {
@@ -583,7 +637,8 @@ test.serial("Build module.b project multiple times", async (t) => {
583637
// (dist output should be totally empty: no source files -> no build result)
584638
await t.throwsAsync(fs.readFile(`${destPath}/resources/b/module/dev/devTools.js`, {encoding: "utf8"}));
585639

586-
// #4 build (with cache, no changes)
640+
641+
// #5 build (with cache, no changes)
587642
await fixtureTester.buildProject({
588643
config: {destPath, cleanDest: true},
589644
assertions: {
@@ -597,7 +652,7 @@ test.serial("Build module.b project multiple times", async (t) => {
597652
await fs.writeFile(`${fixtureTester.fixturePath}/dev/newFolder/newFile.js`,
598653
`console.log("this is a new file which should be included in the build result")`);
599654

600-
// #5 build (no cache, with changes)
655+
// #6 build (no cache, with changes)
601656
await fixtureTester.buildProject({
602657
config: {destPath, cleanDest: true},
603658
assertions: {
@@ -633,9 +688,9 @@ resources:
633688
// Create a resource for this new path mapping:
634689
await fs.mkdir(`${fixtureTester.fixturePath}/${newFolderName}`, {recursive: true});
635690
await fs.writeFile(`${fixtureTester.fixturePath}/${newFolderName}/${newFileName}`,
636-
`console.log("this is a new file which should be included in the build result via the new path mapping")`);
691+
`console.log("this should be included in the build result if the path mapping has been set")`);
637692

638-
// #6 build (no cache, with changes)
693+
// #7 build (no cache, with changes)
639694
await fixtureTester.buildProject({
640695
config: {destPath, cleanDest: true},
641696
assertions: {
@@ -646,12 +701,13 @@ resources:
646701
// Check whether the added file is in the destPath
647702
const someOtherNewFile = await fs.readFile(`${destPath}${virtualPath}${newFileName}`,
648703
{encoding: "utf8"});
649-
t.true(someOtherNewFile.includes(`via the new path mapping`), "Build dest contains correct file content");
704+
t.true(someOtherNewFile.includes(`path mapping has been set`), "Build dest contains correct file content");
705+
650706

651707
// Remove the path mapping again (revert original ui5.yaml):
652708
await fs.writeFile(`${fixtureTester.fixturePath}/ui5.yaml`, originalUi5Yaml);
653709

654-
// #7 build (with cache, with changes)
710+
// #8 build (with cache, with changes)
655711
await fixtureTester.buildProject({
656712
config: {destPath, cleanDest: true},
657713
assertions: {
@@ -663,7 +719,8 @@ resources:
663719
await t.throwsAsync(fs.readFile(`${destPath}${virtualPath}${newFileName}`,
664720
{encoding: "utf8"}));
665721

666-
// #8 build (with cache, no changes, with dependencies)
722+
723+
// #9 build (with cache, no changes, with dependencies)
667724
await fixtureTester.buildProject({
668725
config: {destPath, cleanDest: true, dependencyIncludes: {includeAllDependencies: true}},
669726
assertions: {

0 commit comments

Comments
 (0)