Skip to content

Commit 83b7ccc

Browse files
committed
test(project): Adjust test cases for .library changes
1 parent 20370be commit 83b7ccc

4 files changed

Lines changed: 47 additions & 19 deletions

File tree

packages/project/test/fixtures/library.d/main/src/library/d/.library

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<name>library.d</name>
55
<vendor>SAP SE</vendor>
6-
<copyright>Some fancy copyright</copyright>
6+
<copyright>${copyright}</copyright>
77
<version>${version}</version>
88

99
<documentation>Library D</documentation>

packages/project/test/fixtures/library.d/ui5.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ specVersion: "2.3"
33
type: library
44
metadata:
55
name: library.d
6+
copyright: Some fancy copyright
67
resources:
78
configuration:
89
paths:

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,47 @@ test.serial("Serve application.a, request library resource", async (t) => {
9999

100100
// Change a source file in library.a
101101
const changedFilePath = `${fixtureTester.fixturePath}/node_modules/collection/library.a/src/library/a/.library`;
102-
await fs.appendFile(changedFilePath, `\n<!-- Test -->\n`);
102+
await fs.writeFile(
103+
changedFilePath,
104+
(await fs.readFile(changedFilePath, {encoding: "utf8"})).replace(
105+
`<documentation>Library A</documentation>`,
106+
`<documentation>Library A (updated #1)</documentation>`
107+
)
108+
);
103109

104110
await setTimeout(500); // Wait for the file watcher to detect and propagate the change
105111

106112
// #3 request with cache and changes
107-
const res = await fixtureTester.requestResource("/resources/library/a/.library", {
113+
const dotLibraryResource = await fixtureTester.requestResource("/resources/library/a/.library", {
108114
projects: {
109115
"library.a": {
110116
skippedTasks: [
111-
"enhanceManifest",
112117
"escapeNonAsciiCharacters",
113118
"minify",
114-
// Note: replaceCopyright is skipped because no copyright is configured in the project
115119
"replaceBuildtime",
116-
"replaceCopyright",
117-
"replaceVersion",
118120
]
119121
}
120122
}
121123
});
122124

123-
// Check whether the changed file is in the destPath
124-
const servedFileContent = await res.getString();
125-
t.true(servedFileContent.includes(`<!-- Test -->`), "Resource contains changed file content");
125+
// Check whether the changed file is served
126+
const servedFileContent = await dotLibraryResource.getString();
127+
t.true(
128+
servedFileContent.includes(`<documentation>Library A (updated #1)</documentation>`),
129+
"Resource contains changed file content"
130+
);
131+
132+
// #4 request with cache (no changes)
133+
const manifestResource = await fixtureTester.requestResource("/resources/library/a/manifest.json", {
134+
projects: {}
135+
});
136+
137+
// Check whether the manifest is served correctly with changed .library content reflected
138+
const manifestContent = JSON.parse(await manifestResource.getString());
139+
t.is(
140+
manifestContent["sap.app"]["description"], "Library A (updated #1)",
141+
"Manifest reflects changed .library content"
142+
);
126143
});
127144

128145
function getFixturePath(fixtureName) {

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,30 +204,38 @@ test.serial("Build library.d project multiple times", async (t) => {
204204
await fs.writeFile(
205205
changedFilePath,
206206
(await fs.readFile(changedFilePath, {encoding: "utf8"})).replace(
207-
`<copyright>Some fancy copyright</copyright>`,
208-
`<copyright>Some new fancy copyright</copyright>`
207+
`<documentation>Library D</documentation>`,
208+
`<documentation>Library D (updated #1)</documentation>`
209209
)
210210
);
211211

212212
// #3 build (with cache, with changes)
213213
await fixtureTester.buildProject({
214214
config: {destPath, cleanDest: true},
215215
assertions: {
216-
projects: {"library.d": {}}
216+
projects: {"library.d": {
217+
skippedTasks: [
218+
"buildThemes",
219+
"escapeNonAsciiCharacters",
220+
"minify",
221+
"replaceBuildtime",
222+
]
223+
}}
217224
}
218225
});
219226

220-
// Check whether the changed file is in the destPath
227+
// Check whether the changes are in the destPath
221228
const builtFileContent = await fs.readFile(`${destPath}/resources/library/d/.library`, {encoding: "utf8"});
222229
t.true(
223-
builtFileContent.includes(`<copyright>Some new fancy copyright</copyright>`),
230+
builtFileContent.includes(`<documentation>Library D (updated #1)</documentation>`),
224231
"Build dest contains changed file content"
225232
);
226-
// Check whether the updated copyright replacement took place
227-
const builtSomeJsContent = await fs.readFile(`${destPath}/resources/library/d/some.js`, {encoding: "utf8"});
233+
234+
// Check whether the manifest.json was updated with the new documentation
235+
const manifestContent = await fs.readFile(`${destPath}/resources/library/d/manifest.json`, {encoding: "utf8"});
228236
t.true(
229-
builtSomeJsContent.includes(`Some new fancy copyright`),
230-
"Build dest contains updated copyright in some.js"
237+
manifestContent.includes(`"Library D (updated #1)"`),
238+
"Build dest contains updated description in manifest.json"
231239
);
232240

233241
// #4 build (with cache, no changes)
@@ -237,6 +245,8 @@ test.serial("Build library.d project multiple times", async (t) => {
237245
projects: {}
238246
}
239247
});
248+
249+
// TODO: Change copyright in ui5.yaml and expect that a full rebuild is triggered
240250
});
241251

242252
test.serial("Build theme.library.e project multiple times", async (t) => {

0 commit comments

Comments
 (0)