@sap-ux/preview-middleware 0.13.70 → 0.13.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base/flp.js +33 -24
- package/dist/base/test.d.ts +2 -7
- package/dist/base/test.js +8 -13
- package/package.json +4 -4
- package/templates/test/qunit.html +3 -2
- package/templates/test/qunit.js +27 -7
- package/templates/test/testsuite.qunit.html +2 -2
- package/templates/test/testsuite.qunit.js +2 -1
package/dist/base/flp.js
CHANGED
|
@@ -406,6 +406,7 @@ class FlpSandbox {
|
|
|
406
406
|
this.router.get(config.path, ((_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
407
407
|
this.logger.debug(`Serving test route: ${config.path}`);
|
|
408
408
|
const templateConfig = {
|
|
409
|
+
basePath: this.templateConfig.basePath,
|
|
409
410
|
initPath: config.init
|
|
410
411
|
};
|
|
411
412
|
const html = (0, ejs_1.render)(testsuite, templateConfig);
|
|
@@ -420,17 +421,24 @@ class FlpSandbox {
|
|
|
420
421
|
if (testConfig.framework === 'Testsuite') {
|
|
421
422
|
continue;
|
|
422
423
|
}
|
|
423
|
-
const
|
|
424
|
-
testPaths.push(config.path);
|
|
424
|
+
const mergedConfig = (0, test_1.mergeTestConfigDefaults)(testConfig);
|
|
425
|
+
testPaths.push(path_1.posix.relative(path_1.posix.dirname(config.path), mergedConfig.path));
|
|
425
426
|
}
|
|
426
427
|
this.logger.debug(`Add route for ${config.init}`);
|
|
427
|
-
this.router.get(config.init, ((_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
428
|
-
this.
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
428
|
+
this.router.get(config.init, ((_req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
429
|
+
const files = yield this.project.byGlob(config.init.replace('.js', '.[jt]s'));
|
|
430
|
+
if ((files === null || files === void 0 ? void 0 : files.length) > 0) {
|
|
431
|
+
this.logger.warn(`Script returned at ${config.path} is loaded from the file system.`);
|
|
432
|
+
next();
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
this.logger.debug(`Serving test route: ${config.init}`);
|
|
436
|
+
const templateConfig = {
|
|
437
|
+
testPaths: testPaths
|
|
438
|
+
};
|
|
439
|
+
const js = (0, ejs_1.render)(initTemplate, templateConfig);
|
|
440
|
+
this.sendResponse(res, 'application/javascript', 200, js);
|
|
441
|
+
}
|
|
434
442
|
})));
|
|
435
443
|
}
|
|
436
444
|
/**
|
|
@@ -477,7 +485,7 @@ class FlpSandbox {
|
|
|
477
485
|
id,
|
|
478
486
|
framework: config.framework,
|
|
479
487
|
basePath: (_a = path_1.posix.relative(path_1.posix.dirname(config.path), '/')) !== null && _a !== void 0 ? _a : '.',
|
|
480
|
-
initPath:
|
|
488
|
+
initPath: path_1.posix.relative(path_1.posix.dirname(config.path), config.init)
|
|
481
489
|
};
|
|
482
490
|
const html = (0, ejs_1.render)(htmlTemplate, templateConfig);
|
|
483
491
|
this.sendResponse(res, 'text/html', 200, html);
|
|
@@ -491,7 +499,7 @@ class FlpSandbox {
|
|
|
491
499
|
this.logger.debug(`Add route for ${config.init}`);
|
|
492
500
|
this.router.get(config.init, ((_req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
493
501
|
this.logger.debug(`Serving test init script: ${config.init}`);
|
|
494
|
-
const files = yield this.project.byGlob(config.init.replace('.js', '
|
|
502
|
+
const files = yield this.project.byGlob(config.init.replace('.js', '.[jt]s'));
|
|
495
503
|
if ((files === null || files === void 0 ? void 0 : files.length) > 0) {
|
|
496
504
|
this.logger.warn(`Script returned at ${config.path} is loaded from the file system.`);
|
|
497
505
|
next();
|
|
@@ -564,19 +572,20 @@ class FlpSandbox {
|
|
|
564
572
|
* @returns UI5 libs that should preloaded
|
|
565
573
|
*/
|
|
566
574
|
getUI5Libs(manifest) {
|
|
567
|
-
var _a, _b
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
.
|
|
575
|
+
var _a, _b;
|
|
576
|
+
if ((_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b.libs) {
|
|
577
|
+
const libNames = Object.keys(manifest['sap.ui5'].dependencies.libs);
|
|
578
|
+
return libNames
|
|
579
|
+
.filter((key) => {
|
|
580
|
+
return UI5_LIBS.some((substring) => {
|
|
581
|
+
return key === substring || key.startsWith(substring + '.');
|
|
582
|
+
});
|
|
583
|
+
})
|
|
584
|
+
.join(',');
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
return 'sap.m,sap.ui.core,sap.ushell';
|
|
588
|
+
}
|
|
580
589
|
}
|
|
581
590
|
}
|
|
582
591
|
exports.FlpSandbox = FlpSandbox;
|
package/dist/base/test.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
/// <reference path="../../../../types/ui5.d.ts" />
|
|
2
2
|
import type { Resource } from '@ui5/fs';
|
|
3
|
-
import type { TestConfig } from '../types';
|
|
3
|
+
import type { InternalTestConfig, TestConfig } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Merge the given test configuration with the default values.
|
|
6
6
|
*
|
|
7
7
|
* @param config test configuration
|
|
8
8
|
* @returns merged test configuration
|
|
9
9
|
*/
|
|
10
|
-
export declare function mergeTestConfigDefaults(config: TestConfig):
|
|
11
|
-
framework: "OPA5" | "QUnit" | "Testsuite";
|
|
12
|
-
path: string;
|
|
13
|
-
init: string;
|
|
14
|
-
pattern: string;
|
|
15
|
-
};
|
|
10
|
+
export declare function mergeTestConfigDefaults(config: TestConfig): InternalTestConfig;
|
|
16
11
|
/**
|
|
17
12
|
* Generate a list of imports from a list of resources.
|
|
18
13
|
*
|
package/dist/base/test.js
CHANGED
|
@@ -28,21 +28,16 @@ const DEFAULTS = {
|
|
|
28
28
|
* @returns merged test configuration
|
|
29
29
|
*/
|
|
30
30
|
function mergeTestConfigDefaults(config) {
|
|
31
|
-
var _a
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
31
|
+
var _a;
|
|
32
|
+
const defaults = (_a = DEFAULTS[config.framework.toLowerCase()]) !== null && _a !== void 0 ? _a : {};
|
|
33
|
+
const merged = Object.assign(Object.assign({}, defaults), config);
|
|
34
|
+
if (!merged.path.startsWith('/')) {
|
|
35
|
+
merged.path = `/${merged.path}`;
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
38
|
-
|
|
37
|
+
if (!merged.init.startsWith('/')) {
|
|
38
|
+
merged.init = `/${config.init}`;
|
|
39
39
|
}
|
|
40
|
-
return
|
|
41
|
-
framework: config.framework,
|
|
42
|
-
path: (_b = config.path) !== null && _b !== void 0 ? _b : defaults.path,
|
|
43
|
-
init: (_c = config.init) !== null && _c !== void 0 ? _c : defaults.init,
|
|
44
|
-
pattern: (_d = config.pattern) !== null && _d !== void 0 ? _d : defaults.pattern
|
|
45
|
-
};
|
|
40
|
+
return merged;
|
|
46
41
|
}
|
|
47
42
|
exports.mergeTestConfigDefaults = mergeTestConfigDefaults;
|
|
48
43
|
/**
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.13.
|
|
12
|
+
"version": "0.13.72",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
28
|
"@sap-ux/logger": "0.5.1",
|
|
29
29
|
"@sap-ux/btp-utils": "0.14.4",
|
|
30
|
-
"@sap-ux/adp-tooling": "0.11.
|
|
31
|
-
"@sap-ux/
|
|
32
|
-
"@sap-ux/
|
|
30
|
+
"@sap-ux/adp-tooling": "0.11.6",
|
|
31
|
+
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.23",
|
|
32
|
+
"@sap-ux/project-access": "1.22.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/ejs": "3.1.2",
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
}'
|
|
13
13
|
data-sap-ui-animation="false"
|
|
14
14
|
data-sap-ui-compatVersion="edge"
|
|
15
|
-
data-sap-ui-async="true"
|
|
16
|
-
data-sap-ui-oninit="module:<%- initPath %>">
|
|
15
|
+
data-sap-ui-async="true">
|
|
17
16
|
</script>
|
|
18
17
|
|
|
18
|
+
<script src="<%- initPath %>"></script>
|
|
19
|
+
|
|
19
20
|
<link rel="stylesheet" type="text/css" href="<%- basePath %>/resources/sap/ui/thirdparty/qunit-2.css">
|
|
20
21
|
</head>
|
|
21
22
|
<body>
|
package/templates/test/qunit.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
sap.ui.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
sap.ui.loader.config({
|
|
2
|
+
shim: {
|
|
3
|
+
"sap/ui/qunit/qunit-junit": {
|
|
4
|
+
deps: ["sap/ui/thirdparty/qunit-2"]
|
|
5
|
+
},
|
|
6
|
+
"sap/ui/qunit/qunit-coverage": {
|
|
7
|
+
deps: ["sap/ui/thirdparty/qunit-2"]
|
|
8
|
+
},
|
|
9
|
+
"sap/ui/thirdparty/sinon-qunit": {
|
|
10
|
+
deps: ["sap/ui/thirdparty/qunit-2", "sap/ui/thirdparty/sinon"]
|
|
11
|
+
},
|
|
12
|
+
"sap/ui/qunit/sinon-qunit-bridge": {
|
|
13
|
+
deps: ["sap/ui/thirdparty/qunit", "sap/ui/thirdparty/sinon-4"]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
sap.ui.require([
|
|
19
|
+
"sap/ui/thirdparty/qunit-2",
|
|
20
|
+
"sap/ui/qunit/qunit-junit",
|
|
21
|
+
"sap/ui/qunit/qunit-coverage"
|
|
22
|
+
], function (QUnit) {
|
|
23
|
+
'use strict';
|
|
24
|
+
QUnit.config.autostart = false;
|
|
25
|
+
sap.ui.require(<%- JSON.stringify(tests) %>, function() {
|
|
26
|
+
QUnit.start();
|
|
27
|
+
});
|
|
8
28
|
});
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<title>QUnit TestSuite</title>
|
|
5
|
-
<script src="
|
|
6
|
-
<script src="<%-
|
|
5
|
+
<script src="<%- basePath %>/resources/sap/ui/qunit/qunit-redirect.js"></script>
|
|
6
|
+
<script src="<%- initPath %>" data-sap-ui-testsuite></script>
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
</body>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
window.suite = function () {
|
|
2
2
|
const oSuite = new parent.jsUnitTestSuite();
|
|
3
|
+
var sContextPath = location.pathname.substring(0, location.pathname.lastIndexOf("/") + 1);
|
|
3
4
|
<% for (const path of locals.testPaths) { %>
|
|
4
|
-
oSuite.addTestPage("<%- path %>");
|
|
5
|
+
oSuite.addTestPage(sContextPath + "<%- path %>");
|
|
5
6
|
<% } %>
|
|
6
7
|
return oSuite;
|
|
7
8
|
}
|