Skip to content

Commit bb3e265

Browse files
committed
test(project): Add cases for file deletion (TC4)
1 parent f26d0ed commit bb3e265

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

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

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,39 @@ test.serial("Build application.a project multiple times", async (t) => {
186186
}
187187
}
188188
});
189+
190+
191+
// Add a new file to application.a
192+
await fs.writeFile(`${fixtureTester.fixturePath}/webapp/someNew.js`,
193+
`console.log("SOME NEW CONTENT");\n`
194+
);
195+
196+
// #10 build (with cache, with changes - someNew.js added)
197+
// Tasks that don't depend on someNew.js can reuse their caches from build #9.
198+
await fixtureTester.buildProject({
199+
config: {destPath, cleanDest: true},
200+
assertions: {
201+
projects: {"application.a": {
202+
skippedTasks: [
203+
"enhanceManifest",
204+
"escapeNonAsciiCharacters",
205+
"generateFlexChangesBundle",
206+
"replaceCopyright",
207+
]
208+
}}
209+
}
210+
});
211+
212+
await fs.rm(`${fixtureTester.fixturePath}/webapp/someNew.js`);
213+
214+
// #11 build (with cache, with changes - someNew.js removed)
215+
// Source state matches build #9's cached result -> cache reused, everything skipped
216+
await fixtureTester.buildProject({
217+
config: {destPath, cleanDest: true},
218+
assertions: {
219+
projects: {},
220+
}
221+
});
189222
});
190223

191224
test.serial("Build application.a (custom task and tag handling)", async (t) => {
@@ -1028,13 +1061,60 @@ test.serial("Build library.d project multiple times", async (t) => {
10281061
)
10291062
);
10301063

1064+
await fs.writeFile(`${fixtureTester.fixturePath}/main/src/library/d/someNew.js`,
1065+
`console.log("SOME NEW CONTENT");\n`
1066+
);
1067+
10311068
// #5 build (with cache, with changes)
10321069
await fixtureTester.buildProject({
10331070
config: {destPath, cleanDest: true},
10341071
assertions: {
10351072
projects: {"library.d": {}}
10361073
}
10371074
});
1075+
1076+
await fs.rm(`${fixtureTester.fixturePath}/main/src/library/d/someNew.js`);
1077+
1078+
// #6 build (with cache, with changes - someNew.js removed)
1079+
await fixtureTester.buildProject({
1080+
config: {destPath, cleanDest: true},
1081+
assertions: {
1082+
projects: {"library.d": {
1083+
skippedTasks: [
1084+
"buildThemes",
1085+
"enhanceManifest",
1086+
"escapeNonAsciiCharacters",
1087+
"replaceBuildtime",
1088+
]
1089+
}},
1090+
}
1091+
});
1092+
1093+
// Re-add someNew.js (restores source state to match build #5)
1094+
await fs.writeFile(`${fixtureTester.fixturePath}/main/src/library/d/someNew.js`,
1095+
`console.log("SOME NEW CONTENT");\n`
1096+
);
1097+
1098+
// #7 build (with cache, with changes - someNew.js re-added)
1099+
// Source state now matches build #5's cached result -> cache reused
1100+
await fixtureTester.buildProject({
1101+
config: {destPath, cleanDest: true},
1102+
assertions: {
1103+
projects: {},
1104+
}
1105+
});
1106+
1107+
// Remove someNew.js again
1108+
await fs.rm(`${fixtureTester.fixturePath}/main/src/library/d/someNew.js`);
1109+
1110+
// #8 build (with cache, with changes - someNew.js removed again)
1111+
// Source state matches build #6's cached result -> cache reused, everything skipped
1112+
await fixtureTester.buildProject({
1113+
config: {destPath, cleanDest: true},
1114+
assertions: {
1115+
projects: {},
1116+
}
1117+
});
10381118
});
10391119

10401120
test.serial("Build library.d (Custom Library preload configuration)", async (t) => {
@@ -1305,6 +1385,39 @@ test.serial("Build component.a project multiple times", async (t) => {
13051385
projects: {}
13061386
}
13071387
});
1388+
1389+
1390+
// Add a new file to component.a
1391+
await fs.writeFile(`${fixtureTester.fixturePath}/src/someNew.js`,
1392+
`console.log("SOME NEW CONTENT");\n`
1393+
);
1394+
1395+
// #7 build (with cache, with changes - someNew.js added)
1396+
// Tasks that don't depend on someNew.js can reuse their caches from build #3.
1397+
await fixtureTester.buildProject({
1398+
config: {destPath, cleanDest: true},
1399+
assertions: {
1400+
projects: {"component.a": {
1401+
skippedTasks: [
1402+
"enhanceManifest",
1403+
"escapeNonAsciiCharacters",
1404+
"generateFlexChangesBundle",
1405+
"replaceCopyright",
1406+
]
1407+
}}
1408+
}
1409+
});
1410+
1411+
await fs.rm(`${fixtureTester.fixturePath}/src/someNew.js`);
1412+
1413+
// #8 build (with cache, with changes - someNew.js removed)
1414+
// Source state matches build #6's cached result -> cache reused, everything skipped
1415+
await fixtureTester.buildProject({
1416+
config: {destPath, cleanDest: true},
1417+
assertions: {
1418+
projects: {},
1419+
}
1420+
});
13081421
});
13091422

13101423
test.serial("Build component.a (Custom Component preload configuration)", async (t) => {

0 commit comments

Comments
 (0)