@sap-ux/preview-middleware 0.12.11 → 0.12.13
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/README.md +22 -0
- package/dist/base/flp.d.ts +10 -1
- package/dist/base/flp.js +67 -4
- package/dist/base/test.d.ts +24 -0
- package/dist/base/test.js +59 -0
- package/dist/client/flp/init.js +10 -2
- package/dist/client/flp/init.ts +17 -2
- package/dist/index.d.ts +1 -1
- package/dist/types/index.d.ts +23 -0
- package/package.json +4 -4
- package/templates/flp/sandbox.html +5 -4
- package/templates/test/qunit.html +25 -0
- package/templates/test/qunit.js +6 -0
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ When this middleware is used together with the `reload-middleware`, then the ord
|
|
|
17
17
|
| ---------------------- | --------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
18
18
|
| `flp` | | | Optional configuration object for the local Fiori launchpad |
|
|
19
19
|
| `flp.path` | `string` | `/test/flp.html` | The mount point of the local Fiori launchpad. |
|
|
20
|
+
| `flp.init` | `string` | `undefined` | Optional UI5 module/script to be executed after the standard initialization |
|
|
20
21
|
| `flp.intent` | | | Optional intent to be used for the application |
|
|
21
22
|
| `flp.intent.object` | `string` | `app` | Optional intent object |
|
|
22
23
|
| `flp.intent.action` | `string` | `preview` | Optional intent action |
|
|
@@ -28,6 +29,7 @@ When this middleware is used together with the `reload-middleware`, then the ord
|
|
|
28
29
|
| `rta` | | | Optional configuration allowing to add mount points for runtime adaptation |
|
|
29
30
|
| `rta.layer` | `string` | `(calculated)` | Optional property for defining the runtime adaptation layer for changes (default is `CUSTOMER_BASE` or read from the project for adaptation projects) |
|
|
30
31
|
| `rta.editors` | `array` | `undefined` | Optional list of mount points for editing |
|
|
32
|
+
| `test` | `array` | `undefined` | Optional list of configurations for automated testing |
|
|
31
33
|
| `debug` | `boolean` | `false` | Enables debug output |
|
|
32
34
|
|
|
33
35
|
### `flp.apps`
|
|
@@ -54,6 +56,14 @@ Array of additional application configurations:
|
|
|
54
56
|
| `path` | `string` mandatory | The mount point to be used for the editor. |
|
|
55
57
|
| `developerMode` | `boolean` optional | Enables/disables the runtime adaptation developer mode (only supported for adaptation projects) |
|
|
56
58
|
|
|
59
|
+
### `test`
|
|
60
|
+
| Option | Type | Description |
|
|
61
|
+
| --------------- | -------------------| -----------------------------------------------------------------------------------------------|
|
|
62
|
+
| `framework` | `string` mandatory | Currently `OPA5` and `QUnit` are supported |
|
|
63
|
+
| `path` | `string` optional | The mount point to be used for test suite |
|
|
64
|
+
| `init` | `string` optional | The mount point to be used for test runner script |
|
|
65
|
+
| `pattern` | `string` optional | Optional glob pattern to find the tests. By default `/test/**/*Journey.*` is used for `OPA5` and `/test/**/*Test.*` is used for `QUnit`|
|
|
66
|
+
|
|
57
67
|
|
|
58
68
|
## Usage
|
|
59
69
|
The middleware can be used without configuration. However, since the middleware intercepts a few requests that might otherwise be handled by a different middleware, it is strongly recommended to run other file serving middlewares after the `preview-middleware` e.g. `backend-proxy-middleware` and `ui5-proxy-middleware` (and the corresponding middlewares in the `@sap/ux-ui5-tooling`).
|
|
@@ -109,6 +119,18 @@ server:
|
|
|
109
119
|
- path: /test/variant-editor.html
|
|
110
120
|
```
|
|
111
121
|
|
|
122
|
+
### Test Suites
|
|
123
|
+
If you want to also generate generic test suites and test runners for QUnit or OPA5 tests then you can use the following minimum configurations
|
|
124
|
+
```Yaml
|
|
125
|
+
server:
|
|
126
|
+
customMiddleware:
|
|
127
|
+
- name: preview-middleware
|
|
128
|
+
afterMiddleware: compression
|
|
129
|
+
configuration:
|
|
130
|
+
test:
|
|
131
|
+
- framework: QUnit
|
|
132
|
+
- framework: OPA5
|
|
133
|
+
```
|
|
112
134
|
|
|
113
135
|
### Adaptation Project
|
|
114
136
|
If you want to use the middleware in an adaption project, the additional `adp` object needs to be configured. This example would preview a local adaptation project merged with its reference application from the target system at `http://sap.example` and it will ignore certification validation errors. For adaptation projects, it is also recommended to add the `rta` configuration allowing to edit the project.
|
package/dist/base/flp.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="../../../../types/ui5.d.ts" />
|
|
2
2
|
import type { ReaderCollection } from '@ui5/fs';
|
|
3
3
|
import type { Router } from 'express';
|
|
4
|
-
import type { App, FlpConfig, MiddlewareConfig, RtaConfig } from '../types';
|
|
4
|
+
import type { App, FlpConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types';
|
|
5
5
|
import type { Logger, ToolsLogger } from '@sap-ux/logger';
|
|
6
6
|
import type { MiddlewareUtils } from '@ui5/server';
|
|
7
7
|
import type { Manifest, UI5FlexLayer } from '@sap-ux/project-access';
|
|
@@ -44,6 +44,7 @@ export interface TemplateConfig {
|
|
|
44
44
|
bootstrapOptions: string;
|
|
45
45
|
resources: Record<string, string>;
|
|
46
46
|
};
|
|
47
|
+
init?: string;
|
|
47
48
|
flex?: {
|
|
48
49
|
[key: string]: unknown;
|
|
49
50
|
layer: UI5FlexLayer;
|
|
@@ -62,6 +63,7 @@ export declare class FlpSandbox {
|
|
|
62
63
|
protected templateConfig: TemplateConfig;
|
|
63
64
|
readonly config: FlpConfig;
|
|
64
65
|
readonly rta?: RtaConfig;
|
|
66
|
+
readonly test?: TestConfig[];
|
|
65
67
|
readonly router: EnhancedRouter;
|
|
66
68
|
/**
|
|
67
69
|
* Constructor setting defaults and keeping reference to workspace resources.
|
|
@@ -119,6 +121,13 @@ export declare class FlpSandbox {
|
|
|
119
121
|
* Create required routes for flex.
|
|
120
122
|
*/
|
|
121
123
|
private createFlexHandler;
|
|
124
|
+
/**
|
|
125
|
+
* Add routes for html and scripts required for a local test FLP.
|
|
126
|
+
*
|
|
127
|
+
* @param configs test configurations
|
|
128
|
+
* @param id application id from manifest
|
|
129
|
+
*/
|
|
130
|
+
private addTestRoutes;
|
|
122
131
|
/**
|
|
123
132
|
* Add an application to the local FLP preview.
|
|
124
133
|
*
|
package/dist/base/flp.js
CHANGED
|
@@ -16,6 +16,7 @@ const path_1 = require("path");
|
|
|
16
16
|
const express_1 = require("express");
|
|
17
17
|
const flex_1 = require("./flex");
|
|
18
18
|
const adp_tooling_1 = require("@sap-ux/adp-tooling");
|
|
19
|
+
const test_1 = require("./test");
|
|
19
20
|
const DEVELOPER_MODE_CONFIG = new Map([
|
|
20
21
|
// Run application in design time mode
|
|
21
22
|
// Adds bindingString to BindingInfo objects. Required to create and read PropertyBinding changes
|
|
@@ -91,7 +92,7 @@ class FlpSandbox {
|
|
|
91
92
|
* @param logger logger instance
|
|
92
93
|
*/
|
|
93
94
|
constructor(config, project, utils, logger) {
|
|
94
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
95
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
95
96
|
this.project = project;
|
|
96
97
|
this.utils = utils;
|
|
97
98
|
this.logger = logger;
|
|
@@ -100,13 +101,15 @@ class FlpSandbox {
|
|
|
100
101
|
intent: (_d = (_c = config.flp) === null || _c === void 0 ? void 0 : _c.intent) !== null && _d !== void 0 ? _d : DEFAULT_INTENT,
|
|
101
102
|
apps: (_f = (_e = config.flp) === null || _e === void 0 ? void 0 : _e.apps) !== null && _f !== void 0 ? _f : [],
|
|
102
103
|
libs: (_g = config.flp) === null || _g === void 0 ? void 0 : _g.libs,
|
|
103
|
-
theme: (_h = config.flp) === null || _h === void 0 ? void 0 : _h.theme
|
|
104
|
+
theme: (_h = config.flp) === null || _h === void 0 ? void 0 : _h.theme,
|
|
105
|
+
init: (_j = config.flp) === null || _j === void 0 ? void 0 : _j.init
|
|
104
106
|
};
|
|
105
107
|
if (!this.config.path.startsWith('/')) {
|
|
106
108
|
this.config.path = `/${this.config.path}`;
|
|
107
109
|
}
|
|
110
|
+
this.test = config.test;
|
|
108
111
|
this.rta = config.rta;
|
|
109
|
-
logger.debug(`Config: ${JSON.stringify({ flp: this.config, rta: this.rta })}`);
|
|
112
|
+
logger.debug(`Config: ${JSON.stringify({ flp: this.config, rta: this.rta, test: this.test })}`);
|
|
110
113
|
this.router = (0, express_1.Router)();
|
|
111
114
|
}
|
|
112
115
|
/**
|
|
@@ -124,9 +127,12 @@ class FlpSandbox {
|
|
|
124
127
|
const flex = this.getFlexSettings();
|
|
125
128
|
const supportedThemes = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.supportedThemes) !== null && _b !== void 0 ? _b : [DEFAULT_THEME];
|
|
126
129
|
const ui5Theme = (_c = this.config.theme) !== null && _c !== void 0 ? _c : (supportedThemes.includes(DEFAULT_THEME) ? DEFAULT_THEME : supportedThemes[0]);
|
|
130
|
+
const id = manifest['sap.app'].id;
|
|
131
|
+
const ns = id.replace(/\./g, '/');
|
|
127
132
|
this.templateConfig = {
|
|
128
133
|
basePath: (_d = path_1.posix.relative(path_1.posix.dirname(this.config.path), '/')) !== null && _d !== void 0 ? _d : '.',
|
|
129
134
|
apps: {},
|
|
135
|
+
init: this.config.init ? ns + this.config.init : undefined,
|
|
130
136
|
ui5: {
|
|
131
137
|
libs: this.getUI5Libs(manifest),
|
|
132
138
|
theme: ui5Theme,
|
|
@@ -136,7 +142,6 @@ class FlpSandbox {
|
|
|
136
142
|
},
|
|
137
143
|
locateReuseLibsScript: (_e = this.config.libs) !== null && _e !== void 0 ? _e : (yield this.hasLocateReuseLibsScript())
|
|
138
144
|
};
|
|
139
|
-
const id = manifest['sap.app'].id;
|
|
140
145
|
this.addApp(manifest, {
|
|
141
146
|
componentId,
|
|
142
147
|
target: (_f = resources[componentId !== null && componentId !== void 0 ? componentId : id]) !== null && _f !== void 0 ? _f : this.templateConfig.basePath,
|
|
@@ -150,6 +155,9 @@ class FlpSandbox {
|
|
|
150
155
|
this.rta.options.appName = id;
|
|
151
156
|
this.addEditorRoutes(this.rta);
|
|
152
157
|
}
|
|
158
|
+
if (this.test) {
|
|
159
|
+
this.addTestRoutes(this.test, id);
|
|
160
|
+
}
|
|
153
161
|
this.addRoutesForAdditionalApps();
|
|
154
162
|
this.logger.info(`Initialized for app ${id}`);
|
|
155
163
|
this.logger.debug(`Configured apps: ${JSON.stringify(this.templateConfig.apps)}`);
|
|
@@ -325,6 +333,61 @@ class FlpSandbox {
|
|
|
325
333
|
}
|
|
326
334
|
})));
|
|
327
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Add routes for html and scripts required for a local test FLP.
|
|
338
|
+
*
|
|
339
|
+
* @param configs test configurations
|
|
340
|
+
* @param id application id from manifest
|
|
341
|
+
*/
|
|
342
|
+
addTestRoutes(configs, id) {
|
|
343
|
+
const ns = id.replace(/\./g, '/');
|
|
344
|
+
const htmlTemplate = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/test/qunit.html'), 'utf-8');
|
|
345
|
+
const initTemplate = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/test/qunit.js'), 'utf-8');
|
|
346
|
+
for (const testConfig of configs) {
|
|
347
|
+
const config = (0, test_1.mergeTestConfigDefaults)(testConfig);
|
|
348
|
+
this.logger.debug(`Add route for ${config.path}`);
|
|
349
|
+
// add route for the *.qunit.html
|
|
350
|
+
this.router.get(config.path, ((_req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
351
|
+
var _a;
|
|
352
|
+
this.logger.debug(`Serving test route: ${config.path}`);
|
|
353
|
+
const file = yield this.project.byPath(config.path);
|
|
354
|
+
if (file) {
|
|
355
|
+
this.logger.warn(`HTML file returned at ${config.path} is loaded from the file system.`);
|
|
356
|
+
next();
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
const templateConfig = {
|
|
360
|
+
id,
|
|
361
|
+
framework: config.framework,
|
|
362
|
+
basePath: (_a = path_1.posix.relative(path_1.posix.dirname(config.path), '/')) !== null && _a !== void 0 ? _a : '.',
|
|
363
|
+
initPath: `${ns}${config.init.replace('.js', '')}`
|
|
364
|
+
};
|
|
365
|
+
const html = (0, ejs_1.render)(htmlTemplate, templateConfig);
|
|
366
|
+
res.status(200).contentType('html').send(html);
|
|
367
|
+
}
|
|
368
|
+
})));
|
|
369
|
+
if (testConfig.init !== undefined) {
|
|
370
|
+
this.logger.debug(`Skip serving test init script in favor of provided script: ${testConfig.init}`);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
// add route for the init file
|
|
374
|
+
this.logger.debug(`Add route for ${config.init}`);
|
|
375
|
+
this.router.get(config.init, ((_req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
376
|
+
this.logger.debug(`Serving test init script: ${config.init}`);
|
|
377
|
+
const files = yield this.project.byGlob(config.init.replace('.js', '.*'));
|
|
378
|
+
if ((files === null || files === void 0 ? void 0 : files.length) > 0) {
|
|
379
|
+
this.logger.warn(`Script returned at ${config.path} is loaded from the file system.`);
|
|
380
|
+
next();
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
const testFiles = yield this.project.byGlob(config.pattern);
|
|
384
|
+
const templateConfig = { tests: (0, test_1.generateImportList)(ns, testFiles) };
|
|
385
|
+
const html = (0, ejs_1.render)(initTemplate, templateConfig);
|
|
386
|
+
res.status(200).contentType('application/javascript').send(html);
|
|
387
|
+
}
|
|
388
|
+
})));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
328
391
|
/**
|
|
329
392
|
* Add an application to the local FLP preview.
|
|
330
393
|
*
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference path="../../../../types/ui5.d.ts" />
|
|
2
|
+
import type { Resource } from '@ui5/fs';
|
|
3
|
+
import type { TestConfig } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Merge the given test configuration with the default values.
|
|
6
|
+
*
|
|
7
|
+
* @param config test configuration
|
|
8
|
+
* @returns merged test configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function mergeTestConfigDefaults(config: TestConfig): {
|
|
11
|
+
framework: "OPA5" | "QUnit";
|
|
12
|
+
path: string;
|
|
13
|
+
init: string;
|
|
14
|
+
pattern: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Generate a list of imports from a list of resources.
|
|
18
|
+
*
|
|
19
|
+
* @param ns namespace of the test files
|
|
20
|
+
* @param resourceList list of resources representing test files
|
|
21
|
+
* @returns array of strings representing the tests
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateImportList(ns: string, resourceList: Resource[]): string[];
|
|
24
|
+
//# sourceMappingURL=test.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateImportList = exports.mergeTestConfigDefaults = void 0;
|
|
4
|
+
const DEFAULTS = {
|
|
5
|
+
qunit: {
|
|
6
|
+
path: '/test/unitTests.qunit.html',
|
|
7
|
+
init: '/test/unitTests.qunit.js',
|
|
8
|
+
pattern: '/test/**/*Test.*',
|
|
9
|
+
framework: 'QUnit'
|
|
10
|
+
},
|
|
11
|
+
opa5: {
|
|
12
|
+
path: '/test/opaTests.qunit.html',
|
|
13
|
+
init: '/test/opaTests.qunit.js',
|
|
14
|
+
pattern: '/test/**/*Journey.*',
|
|
15
|
+
framework: 'OPA5'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Merge the given test configuration with the default values.
|
|
20
|
+
*
|
|
21
|
+
* @param config test configuration
|
|
22
|
+
* @returns merged test configuration
|
|
23
|
+
*/
|
|
24
|
+
function mergeTestConfigDefaults(config) {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
26
|
+
const key = config.framework.toLowerCase();
|
|
27
|
+
const defaults = (_a = DEFAULTS[key]) !== null && _a !== void 0 ? _a : {};
|
|
28
|
+
if (config.path && !config.path.startsWith('/')) {
|
|
29
|
+
config.path = `/${config.path}`;
|
|
30
|
+
}
|
|
31
|
+
if (config.init && !config.init.startsWith('/')) {
|
|
32
|
+
config.init = `/${config.init}`;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
framework: config.framework,
|
|
36
|
+
path: (_b = config.path) !== null && _b !== void 0 ? _b : defaults.path,
|
|
37
|
+
init: (_c = config.init) !== null && _c !== void 0 ? _c : defaults.init,
|
|
38
|
+
pattern: (_d = config.pattern) !== null && _d !== void 0 ? _d : defaults.pattern
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.mergeTestConfigDefaults = mergeTestConfigDefaults;
|
|
42
|
+
/**
|
|
43
|
+
* Generate a list of imports from a list of resources.
|
|
44
|
+
*
|
|
45
|
+
* @param ns namespace of the test files
|
|
46
|
+
* @param resourceList list of resources representing test files
|
|
47
|
+
* @returns array of strings representing the tests
|
|
48
|
+
*/
|
|
49
|
+
function generateImportList(ns, resourceList) {
|
|
50
|
+
return resourceList
|
|
51
|
+
? resourceList.map((file) => {
|
|
52
|
+
const path = file.getPath().split('.');
|
|
53
|
+
path.pop();
|
|
54
|
+
return `${ns}${path.join('.')}`;
|
|
55
|
+
})
|
|
56
|
+
: [];
|
|
57
|
+
}
|
|
58
|
+
exports.generateImportList = generateImportList;
|
|
59
|
+
//# sourceMappingURL=test.js.map
|
package/dist/client/flp/init.js
CHANGED
|
@@ -145,12 +145,14 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
145
145
|
* @param params init parameters read from the script tag
|
|
146
146
|
* @param params.appUrls JSON containing a string array of application urls
|
|
147
147
|
* @param params.flex JSON containing the flex configuration
|
|
148
|
+
* @param params.customInit path to the custom init module to be called
|
|
148
149
|
* @returns promise
|
|
149
150
|
*/
|
|
150
151
|
async function init(_ref) {
|
|
151
152
|
let {
|
|
152
153
|
appUrls,
|
|
153
|
-
flex
|
|
154
|
+
flex,
|
|
155
|
+
customInit
|
|
154
156
|
} = _ref;
|
|
155
157
|
// Register RTA if configured
|
|
156
158
|
if (flex) {
|
|
@@ -189,6 +191,11 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
189
191
|
await registerComponentDependencyPaths(JSON.parse(appUrls));
|
|
190
192
|
}
|
|
191
193
|
|
|
194
|
+
// Load custom initialization module
|
|
195
|
+
if (customInit) {
|
|
196
|
+
sap.ui.require([customInit]);
|
|
197
|
+
}
|
|
198
|
+
|
|
192
199
|
// init
|
|
193
200
|
setI18nTitle();
|
|
194
201
|
registerSAPFonts();
|
|
@@ -199,7 +206,8 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
199
206
|
if (bootstrapConfig) {
|
|
200
207
|
init({
|
|
201
208
|
appUrls: bootstrapConfig.getAttribute('data-open-ux-preview-libs-manifests'),
|
|
202
|
-
flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings')
|
|
209
|
+
flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings'),
|
|
210
|
+
customInit: bootstrapConfig.getAttribute('data-open-ux-preview-customInit')
|
|
203
211
|
}).catch(() => Log.error('Sandbox initialization failed.'));
|
|
204
212
|
}
|
|
205
213
|
var __exports = {
|
package/dist/client/flp/init.ts
CHANGED
|
@@ -185,9 +185,18 @@ export function setI18nTitle(i18nKey = 'appTitle') {
|
|
|
185
185
|
* @param params init parameters read from the script tag
|
|
186
186
|
* @param params.appUrls JSON containing a string array of application urls
|
|
187
187
|
* @param params.flex JSON containing the flex configuration
|
|
188
|
+
* @param params.customInit path to the custom init module to be called
|
|
188
189
|
* @returns promise
|
|
189
190
|
*/
|
|
190
|
-
export async function init({
|
|
191
|
+
export async function init({
|
|
192
|
+
appUrls,
|
|
193
|
+
flex,
|
|
194
|
+
customInit
|
|
195
|
+
}: {
|
|
196
|
+
appUrls?: string | null;
|
|
197
|
+
flex?: string | null;
|
|
198
|
+
customInit?: string | null;
|
|
199
|
+
}): Promise<void> {
|
|
191
200
|
// Register RTA if configured
|
|
192
201
|
if (flex) {
|
|
193
202
|
sap.ushell.Container.attachRendererCreatedEvent(async function () {
|
|
@@ -232,6 +241,11 @@ export async function init({ appUrls, flex }: { appUrls?: string | null; flex?:
|
|
|
232
241
|
await registerComponentDependencyPaths(JSON.parse(appUrls));
|
|
233
242
|
}
|
|
234
243
|
|
|
244
|
+
// Load custom initialization module
|
|
245
|
+
if (customInit) {
|
|
246
|
+
sap.ui.require([customInit]);
|
|
247
|
+
}
|
|
248
|
+
|
|
235
249
|
// init
|
|
236
250
|
setI18nTitle();
|
|
237
251
|
registerSAPFonts();
|
|
@@ -243,6 +257,7 @@ const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
|
243
257
|
if (bootstrapConfig) {
|
|
244
258
|
init({
|
|
245
259
|
appUrls: bootstrapConfig.getAttribute('data-open-ux-preview-libs-manifests'),
|
|
246
|
-
flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings')
|
|
260
|
+
flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings'),
|
|
261
|
+
customInit: bootstrapConfig.getAttribute('data-open-ux-preview-customInit')
|
|
247
262
|
}).catch(() => Log.error('Sandbox initialization failed.'));
|
|
248
263
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -48,12 +48,35 @@ export interface FlpConfig {
|
|
|
48
48
|
libs?: boolean;
|
|
49
49
|
apps: App[];
|
|
50
50
|
theme?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Optional: allows to specify a custom init script executed in addition to the default one
|
|
53
|
+
*/
|
|
54
|
+
init?: string;
|
|
55
|
+
}
|
|
56
|
+
interface OptionalTestConfig {
|
|
57
|
+
/**
|
|
58
|
+
* Optional: path hosting the main test page
|
|
59
|
+
*/
|
|
60
|
+
path: string;
|
|
61
|
+
/**
|
|
62
|
+
* Optional: path to the init script
|
|
63
|
+
*/
|
|
64
|
+
init: string;
|
|
65
|
+
/**
|
|
66
|
+
* Optional: pattern to match the test files
|
|
67
|
+
*/
|
|
68
|
+
pattern: string;
|
|
69
|
+
}
|
|
70
|
+
export interface TestConfig extends Partial<OptionalTestConfig> {
|
|
71
|
+
framework: 'OPA5' | 'QUnit';
|
|
51
72
|
}
|
|
73
|
+
export type InternalTestConfig = TestConfig & OptionalTestConfig;
|
|
52
74
|
/**
|
|
53
75
|
* Middleware configuration.
|
|
54
76
|
*/
|
|
55
77
|
export interface MiddlewareConfig {
|
|
56
78
|
flp?: Partial<FlpConfig>;
|
|
79
|
+
test?: TestConfig[];
|
|
57
80
|
rta?: RtaConfig;
|
|
58
81
|
adp?: AdpPreviewConfig;
|
|
59
82
|
debug?: boolean;
|
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.12.
|
|
12
|
+
"version": "0.12.13",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"ejs": "3.1.9",
|
|
26
26
|
"@sap-ux/logger": "0.5.1",
|
|
27
|
-
"@sap-ux/adp-tooling": "0.9.
|
|
27
|
+
"@sap-ux/adp-tooling": "0.9.4",
|
|
28
28
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.15"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"supertest": "6.3.3",
|
|
40
40
|
"@sap-ux-private/playwright": "0.0.3",
|
|
41
41
|
"dotenv": "16.3.1",
|
|
42
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.
|
|
43
|
-
"@sap-ux/project-access": "1.
|
|
42
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.2",
|
|
43
|
+
"@sap-ux/project-access": "1.19.0",
|
|
44
44
|
"@sap-ux/axios-extension": "1.11.3",
|
|
45
45
|
"@sap-ux/store": "0.5.0"
|
|
46
46
|
},
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
data-sap-ui-resourceroots='<%- JSON.stringify(ui5.resources) %>'
|
|
56
56
|
data-sap-ui-frameOptions="allow"
|
|
57
57
|
data-sap-ui-xx-componentPreload="off"<%- ui5.bootstrapOptions %>
|
|
58
|
-
data-sap-ui-oninit="module:open/ux/preview/client/flp/init"<% if (locals.
|
|
58
|
+
data-sap-ui-oninit="module:open/ux/preview/client/flp/init"<% if (locals.init) { %>
|
|
59
|
+
data-open-ux-preview-customInit='<%- init %>'<% } if (locals.flex) { %>
|
|
59
60
|
data-open-ux-preview-flex-settings='<%- JSON.stringify(flex) %>'<% } if (locals.locateReuseLibsScript) { %>
|
|
60
61
|
data-open-ux-preview-libs-manifests='<%- JSON.stringify(Object.values(apps).map(app => app.url)) %>'<% } %>>
|
|
61
62
|
</script>
|
|
@@ -63,12 +64,12 @@
|
|
|
63
64
|
<script type="text/javascript">
|
|
64
65
|
(() => sap.ui.require(['open/ux/preview/client/flp/initConnectors']))()
|
|
65
66
|
</script>
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
<% if (locals.flex && flex?.scenario === 'ADAPTATION_PROJECT') { %>
|
|
68
69
|
<!-- Temporary fix until RTA provides api for enable/disable buttons in main RTA navigation menu -->
|
|
69
70
|
<style>
|
|
70
71
|
.sapUiRtaToolbarActionsSection button[aria-label="Exit"],
|
|
71
|
-
.sapUiRtaToolbarActionsSection button[id$="fragment--sapUiRta_feedback"],
|
|
72
|
+
.sapUiRtaToolbarActionsSection button[id$="fragment--sapUiRta_feedback"],
|
|
72
73
|
.sapUiRtaToolbarActionsSection button[id$="fragment--sapUiRta_actionsToolbar-overflowButton"] {
|
|
73
74
|
display:none;
|
|
74
75
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title><%- framework %> tests</title>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
|
|
7
|
+
<script
|
|
8
|
+
src="<%- basePath %>/resources/sap-ui-core.js"
|
|
9
|
+
data-sap-ui-theme='sap_fiori_3'
|
|
10
|
+
data-sap-ui-resourceroots='{
|
|
11
|
+
"<%- id %>": "<%- basePath %>"
|
|
12
|
+
}'
|
|
13
|
+
data-sap-ui-animation="false"
|
|
14
|
+
data-sap-ui-compatVersion="edge"
|
|
15
|
+
data-sap-ui-async="true"
|
|
16
|
+
data-sap-ui-oninit="module:<%- initPath %>">
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<link rel="stylesheet" type="text/css" href="<%- basePath %>/resources/sap/ui/thirdparty/qunit-2.css">
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<div id="qunit"></div>
|
|
23
|
+
<div id="qunit-fixture"></div>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|