Skip to content

Commit 71ddb60

Browse files
maxreichmannRandomByte
authored andcommitted
test: E2E-tests: Cover scenario for "ui5-tooling-modules"
+ Add "application.a" (Javascript project fixture)
1 parent b3841d4 commit 71ddb60

8 files changed

Lines changed: 157 additions & 9 deletions

File tree

internal/e2e-tests/fixtures/application.a.ts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"license": "Apache-2.0",
66
"devDependencies": {
77
"@openui5/types": "1.115.1",
8-
"ui5-task-zipper": "3.6.0",
98
"ui5-tooling-transpile": "3.11.0"
109
}
1110
}

internal/e2e-tests/fixtures/application.a.ts/ui5-tooling-transpile-middleware.yaml renamed to internal/e2e-tests/fixtures/application.a.ts/ui5-tooling-transpile.yaml

File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "application.a",
3+
"version": "1.0.0",
4+
"description": "UI5 Application: application.a",
5+
"license": "Apache-2.0",
6+
"dependencies": {
7+
"chart.js": "4.5.1"
8+
},
9+
"devDependencies": {
10+
"@openui5/types": "1.115.1",
11+
"ui5-task-zipper": "3.6.0",
12+
"ui5-tooling-modules": "3.35.0"
13+
}
14+
}

internal/e2e-tests/fixtures/application.a.ts/ui5-task-zipper.yaml renamed to internal/e2e-tests/fixtures/application.a/ui5-task-zipper.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
specVersion: "5.0"
22
metadata:
3-
name: application.a.ts
3+
name: application.a
44
type: application
55
builder:
66
customTasks:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
specVersion: "5.0"
2+
metadata:
3+
name: application.a
4+
type: application
5+
server:
6+
customMiddleware:
7+
- name: ui5-tooling-modules-middleware
8+
afterMiddleware: compression
9+
builder:
10+
customTasks:
11+
- name: ui5-tooling-modules-task
12+
afterTask: replaceVersion
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sap.ui.define(["chart.js"], (chartJS) => {
2+
return Controller.extend("application.a.controller.Test",{
3+
onInit() {
4+
const z = {
5+
first: {
6+
a: 1,
7+
b: 2,
8+
c: 3
9+
},
10+
second: "test"
11+
};
12+
console.log(z.first.a);
13+
14+
// For "ui5-tooling-modules" test:
15+
console.log(chartJS);
16+
}
17+
});
18+
});
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"_version": "1.12.0",
3+
"sap.app": {
4+
"id": "application.a",
5+
"type": "application",
6+
"i18n": "i18n/i18n.properties",
7+
"title": "{{appTitle}}",
8+
"description": "{{appDescription}}",
9+
"applicationVersion": {
10+
"version": "1.0.0"
11+
}
12+
},
13+
"sap.ui": {
14+
"technology": "UI5",
15+
"icons": {},
16+
"deviceTypes": {
17+
"desktop": true,
18+
"tablet": true,
19+
"phone": true
20+
}
21+
},
22+
"sap.ui5": {
23+
"rootView": {
24+
"viewName": "application.a.view.App",
25+
"type": "XML",
26+
"async": true,
27+
"id": "app"
28+
},
29+
"handleValidation": true,
30+
"contentDensities": {
31+
"compact": true,
32+
"cozy": true
33+
},
34+
"models": {
35+
"i18n": {
36+
"type": "sap.ui.model.resource.ResourceModel",
37+
"settings": {
38+
"bundleName": "application.a.i18n.i18n"
39+
}
40+
}
41+
},
42+
"routing": {
43+
"config": {
44+
"routerClass": "sap.m.routing.Router",
45+
"viewType": "XML",
46+
"viewPath": "application.a.view",
47+
"controlId": "app",
48+
"controlAggregation": "pages",
49+
"async": true
50+
},
51+
"routes": [
52+
{
53+
"pattern": "",
54+
"name": "main",
55+
"target": "main"
56+
}
57+
],
58+
"targets": {
59+
"main": {
60+
"viewId": "main",
61+
"viewName": "Main"
62+
}
63+
}
64+
}
65+
}
66+
}

internal/e2e-tests/test/build.js

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ class FixtureHelper {
7474
}
7575

7676
describe("ui5 build", () => {
77-
test("ui5-tooling-transpile-middleware", async ({assert}) => {
77+
test("ui5-tooling-transpile", async ({assert}) => {
7878
const fixtureHelper = new FixtureHelper("application.a.ts");
7979
await fixtureHelper.init();
8080
process.env.UI5_DATA_DIR = `${fixtureHelper.dotUi5Path}`;
8181
process.chdir(fixtureHelper.tmpPath);
82-
const ui5YamlName = "ui5-tooling-transpile-middleware.yaml";
82+
const ui5YamlName = "ui5-tooling-transpile.yaml";
8383

8484
// #1 Build
8585
await fixtureHelper.build(assert, ui5YamlName);
@@ -108,8 +108,8 @@ describe("ui5 build", () => {
108108
assert.ok(newComponentPreload.includes("second:\"test_2\""), "Component-preload.js should contain the updated content from the modified source file");
109109
});
110110

111-
test.only("ui5-task-zipper", async ({assert}) => {
112-
const fixtureHelper = new FixtureHelper("application.a.ts");
111+
test("ui5-task-zipper", async ({assert}) => {
112+
const fixtureHelper = new FixtureHelper("application.a");
113113
await fixtureHelper.init();
114114
process.env.UI5_DATA_DIR = `${fixtureHelper.dotUi5Path}`;
115115
process.chdir(fixtureHelper.tmpPath);
@@ -129,14 +129,14 @@ describe("ui5 build", () => {
129129
assert.ok(zipEntries.length > 0, "The zip file should contain entries");
130130

131131
// Check that the zip file contains the expected source file
132-
const testControllerEntry = zipEntries.find(entry => entry.entryName === "controller/Test.controller.ts");
132+
const testControllerEntry = zipEntries.find(entry => entry.entryName === "controller/Test.controller.js");
133133
assert.ok(testControllerEntry, "The zip file should contain the expected source file");
134134

135135
// --------------------------------------------------------------------------------------------
136136

137137
// Delete a source file
138138
await fixtureHelper.prepareForNextRun();
139-
await fs.rm(path.resolve(fixtureHelper.tmpPath, "webapp/controller/Test.controller.ts"));
139+
await fs.rm(path.resolve(fixtureHelper.tmpPath, "webapp/controller/Test.controller.js"));
140140

141141
// #2 Build
142142
await fixtureHelper.build(assert, ui5YamlName);
@@ -151,7 +151,46 @@ describe("ui5 build", () => {
151151
assert.ok(zipEntries2.length > 0, "The zip file should contain entries after the second build");
152152

153153
// Check that the zip file does NOT contain the expected source file anymore
154-
const deletedTestControllerEntry = zipEntries2.find(entry => entry.entryName === "controller/Test.controller.ts");
154+
const deletedTestControllerEntry = zipEntries2.find(entry => entry.entryName === "controller/Test.controller.js");
155155
assert.ok(!deletedTestControllerEntry, "The zip file should NOT contain the deleted source file");
156156
});
157+
158+
test("ui5-tooling-modules", async ({assert}) => {
159+
const fixtureHelper = new FixtureHelper("application.a");
160+
await fixtureHelper.init();
161+
process.env.UI5_DATA_DIR = `${fixtureHelper.dotUi5Path}`;
162+
process.chdir(fixtureHelper.tmpPath);
163+
const ui5YamlName = "ui5-tooling-modules.yaml";
164+
165+
// #1 Build
166+
await fixtureHelper.build(assert, ui5YamlName);
167+
168+
// Test: the dist contains the expected preload with the correct content
169+
const componentPreload = await fs.readFile(path.resolve(fixtureHelper.distPath, "Component-preload.js"), "utf-8");
170+
assert.ok(componentPreload.includes("sap.ui.predefine(\"application/a/controller/Test.controller\", [\"application/a/thirdparty/chart.js\"]"), "Component-preload.js should contain the 'Test' controller and its dependency");
171+
172+
173+
// --------------------------------------------------------------------------------------------
174+
175+
// Add a new source file with another third party import
176+
await fixtureHelper.prepareForNextRun();
177+
const newControllerPath = path.resolve(fixtureHelper.tmpPath, "webapp/controller/New.controller.js");
178+
const newControllerContent =
179+
`sap.ui.define(["chart.js"], (chartJS) => {
180+
return Controller.extend("application.a.controller.New",{
181+
onInit() {
182+
console.log(chartJS);
183+
}
184+
});
185+
});`;
186+
await fs.writeFile(newControllerPath, newControllerContent, "utf-8");
187+
188+
// #2 Build
189+
await fixtureHelper.build(assert, ui5YamlName);
190+
191+
// Test: the dist contains the new controller and the new import
192+
const newComponentPreload = await fs.readFile(path.resolve(fixtureHelper.distPath, "Component-preload.js"), "utf-8");
193+
assert.ok(newComponentPreload.includes("sap.ui.predefine(\"application/a/controller/Test.controller\", [\"application/a/thirdparty/chart.js\"]"), "Component-preload.js should contain the 'Test' controller and its dependency");
194+
assert.ok(newComponentPreload.includes("sap.ui.predefine(\"application/a/controller/New.controller\", [\"application/a/thirdparty/chart.js\"]"), "Component-preload.js should contain the 'New' controller and its dependency");
195+
});
157196
});

0 commit comments

Comments
 (0)