Skip to content

Commit 8a7b9d0

Browse files
committed
test(project): Check if sap-ui-version.json contains correct content
1 parent e05abd3 commit 8a7b9d0

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,75 @@ test.serial("Build race condition: file modified during active build", async (t)
23732373
);
23742374
});
23752375

2376+
test.serial("Build with dependencies: Verify sap-ui-version.json generation and regeneration", async (t) => {
2377+
const fixtureTester = new FixtureTester(t, "application.a");
2378+
const destPath = fixtureTester.destPath;
2379+
const versionInfoPath = `${destPath}/resources/sap-ui-version.json`;
2380+
2381+
// Build #1: Full build with all dependencies in JSDoc mode
2382+
// JSDoc mode enables generateVersionInfo task which creates sap-ui-version.json
2383+
await fixtureTester.buildProject({
2384+
config: {
2385+
destPath,
2386+
cleanDest: true,
2387+
jsdoc: "jsdoc",
2388+
dependencyIncludes: {includeAllDependencies: true}
2389+
},
2390+
assertions: {
2391+
projects: {
2392+
"library.d": {},
2393+
"library.a": {},
2394+
"library.b": {},
2395+
"library.c": {},
2396+
"application.a": {}
2397+
}
2398+
}
2399+
});
2400+
2401+
const versionInfo1Content = await fs.readFile(versionInfoPath, {encoding: "utf8"});
2402+
t.truthy(versionInfo1Content, "sap-ui-version.json should exist");
2403+
const versionInfo1 = JSON.parse(versionInfo1Content);
2404+
2405+
// Root project metadata
2406+
t.is(versionInfo1.name, "application.a", "Root project name");
2407+
t.is(versionInfo1.version, "1.0.0", "Root project version");
2408+
t.is(typeof versionInfo1.buildTimestamp, "string", "buildTimestamp is string");
2409+
2410+
// Libraries array
2411+
t.true(Array.isArray(versionInfo1.libraries), "libraries is array");
2412+
const libraryNames = versionInfo1.libraries.map((lib) => lib.name).sort();
2413+
t.deepEqual(libraryNames, ["library.a", "library.b", "library.c", "library.d"],
2414+
"Contains all dependency libraries");
2415+
2416+
// Each library has required fields
2417+
versionInfo1.libraries.forEach((lib) => {
2418+
t.is(typeof lib.name, "string", `Library ${lib.name} has name`);
2419+
t.is(typeof lib.version, "string", `Library ${lib.name} has version`);
2420+
t.is(typeof lib.buildTimestamp, "string", `Library ${lib.name} has buildTimestamp`);
2421+
});
2422+
2423+
const firstBuildTimestamp = versionInfo1.buildTimestamp;
2424+
2425+
// Build #2: No changes, expect full cache hit
2426+
await fixtureTester.buildProject({
2427+
config: {
2428+
destPath,
2429+
cleanDest: true,
2430+
jsdoc: "jsdoc",
2431+
dependencyIncludes: {includeAllDependencies: true}
2432+
},
2433+
assertions: {
2434+
projects: {} // All projects cached
2435+
}
2436+
});
2437+
2438+
// Verify sap-ui-version.json was reused from cache (timestamp unchanged)
2439+
const versionInfo2Content = await fs.readFile(versionInfoPath, {encoding: "utf8"});
2440+
const versionInfo2 = JSON.parse(versionInfo2Content);
2441+
t.is(versionInfo2.buildTimestamp, firstBuildTimestamp,
2442+
"buildTimestamp unchanged when cached (no source changes)");
2443+
});
2444+
23762445
function getFixturePath(fixtureName) {
23772446
return fileURLToPath(new URL(`../../fixtures/${fixtureName}`, import.meta.url));
23782447
}

0 commit comments

Comments
 (0)