@sap-ux/ui5-test-writer 0.3.3 → 0.4.1
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/i18n.js +11 -22
- package/dist/index.js +23 -30
- package/package.json +2 -2
package/dist/i18n.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -19,19 +10,17 @@ const NS = 'ui5-test-writer';
|
|
|
19
10
|
/**
|
|
20
11
|
* Initialize i18next with the translations for this module.
|
|
21
12
|
*/
|
|
22
|
-
function initI18n() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ns: [NS]
|
|
34
|
-
});
|
|
13
|
+
async function initI18n() {
|
|
14
|
+
await i18next_1.default.init({
|
|
15
|
+
resources: {
|
|
16
|
+
en: {
|
|
17
|
+
[NS]: ui5_test_writer_i18n_json_1.default
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
lng: 'en',
|
|
21
|
+
fallbackLng: 'en',
|
|
22
|
+
defaultNS: NS,
|
|
23
|
+
ns: [NS]
|
|
35
24
|
});
|
|
36
25
|
}
|
|
37
26
|
exports.initI18n = initI18n;
|
package/dist/index.js
CHANGED
|
@@ -29,8 +29,7 @@ function readManifest(fs, basePath) {
|
|
|
29
29
|
* @returns {{ applicationType: string, hideFilterBar: boolean }} An object containing the application type and hideFilterBar flag. An exception is thrown if it can't be found or if it's not supported
|
|
30
30
|
*/
|
|
31
31
|
function getAppTypeAndHideFilterBarFromManifest(manifest) {
|
|
32
|
-
|
|
33
|
-
const appTargets = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.routing) === null || _b === void 0 ? void 0 : _b.targets;
|
|
32
|
+
const appTargets = manifest['sap.ui5']?.routing?.targets;
|
|
34
33
|
let hideFilterBar = false;
|
|
35
34
|
let isFEV4 = false;
|
|
36
35
|
for (const targetKey in appTargets) {
|
|
@@ -38,7 +37,7 @@ function getAppTypeAndHideFilterBarFromManifest(manifest) {
|
|
|
38
37
|
if (target.type === 'Component' && target.name && target.name in types_1.SupportedPageTypes) {
|
|
39
38
|
isFEV4 = true;
|
|
40
39
|
if (types_1.SupportedPageTypes[target.name] === 'ListReport') {
|
|
41
|
-
hideFilterBar =
|
|
40
|
+
hideFilterBar = target.options?.settings?.hideFilterBar ?? false;
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -55,9 +54,8 @@ function getAppTypeAndHideFilterBarFromManifest(manifest) {
|
|
|
55
54
|
* @returns appID and appPath
|
|
56
55
|
*/
|
|
57
56
|
function getAppFromManifest(manifest, forcedAppID) {
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const appPath = appID === null || appID === void 0 ? void 0 : appID.split('.').join('/');
|
|
57
|
+
const appID = forcedAppID || manifest['sap.app']?.id;
|
|
58
|
+
const appPath = appID?.split('.').join('/');
|
|
61
59
|
if (!appID || !appPath) {
|
|
62
60
|
throw new types_1.ValidationError((0, i18n_1.t)('error.cannotReadAppID'));
|
|
63
61
|
}
|
|
@@ -72,15 +70,14 @@ function getAppFromManifest(manifest, forcedAppID) {
|
|
|
72
70
|
* @returns Page configuration object, or undefined if the target type is not supported
|
|
73
71
|
*/
|
|
74
72
|
function createPageConfig(manifest, targetKey, forcedAppID) {
|
|
75
|
-
|
|
76
|
-
const appTargets = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.routing) === null || _b === void 0 ? void 0 : _b.targets;
|
|
73
|
+
const appTargets = manifest['sap.ui5']?.routing?.targets;
|
|
77
74
|
const target = appTargets && appTargets[targetKey];
|
|
78
75
|
const { appID, appPath } = getAppFromManifest(manifest, forcedAppID);
|
|
79
|
-
if (
|
|
80
|
-
|
|
76
|
+
if (target?.type === 'Component' &&
|
|
77
|
+
target?.name &&
|
|
81
78
|
target.name in types_1.SupportedPageTypes &&
|
|
82
|
-
|
|
83
|
-
(
|
|
79
|
+
target?.id &&
|
|
80
|
+
(target?.options?.settings?.entitySet || target?.options?.settings?.contextPath)) {
|
|
84
81
|
const pageConfig = {
|
|
85
82
|
appPath,
|
|
86
83
|
appID,
|
|
@@ -113,29 +110,28 @@ function createPageConfig(manifest, targetKey, forcedAppID) {
|
|
|
113
110
|
* @returns OPA test configuration object
|
|
114
111
|
*/
|
|
115
112
|
function createConfig(manifest, opaConfig, hideFilterBar) {
|
|
116
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
117
113
|
// General application info
|
|
118
114
|
const { appID, appPath } = getAppFromManifest(manifest, opaConfig.appID);
|
|
119
115
|
const config = {
|
|
120
116
|
appID,
|
|
121
117
|
appPath,
|
|
122
118
|
pages: [],
|
|
123
|
-
opaJourneyFileName:
|
|
124
|
-
htmlTarget:
|
|
119
|
+
opaJourneyFileName: opaConfig.scriptName ?? 'FirstJourney',
|
|
120
|
+
htmlTarget: opaConfig.htmlTarget ?? 'index.html',
|
|
125
121
|
hideFilterBar
|
|
126
122
|
};
|
|
127
123
|
// Identify startup targets from the routes
|
|
128
|
-
const appRoutes = (
|
|
124
|
+
const appRoutes = (manifest['sap.ui5']?.routing?.routes ?? []);
|
|
129
125
|
// Find the route with an empty pattern (except for the trailing query part)
|
|
130
126
|
const startupRoute = appRoutes.find((route) => {
|
|
131
127
|
return route.pattern.replace(':?query:', '') === '';
|
|
132
128
|
});
|
|
133
|
-
let startupTargets =
|
|
129
|
+
let startupTargets = startupRoute?.target ?? [];
|
|
134
130
|
if (!Array.isArray(startupTargets)) {
|
|
135
131
|
startupTargets = [startupTargets];
|
|
136
132
|
}
|
|
137
133
|
// Create page configurations in supported cases
|
|
138
|
-
const appTargets =
|
|
134
|
+
const appTargets = manifest['sap.ui5']?.routing?.targets;
|
|
139
135
|
for (const targetKey in appTargets) {
|
|
140
136
|
const pageConfig = createPageConfig(manifest, targetKey, opaConfig.appID);
|
|
141
137
|
if (pageConfig) {
|
|
@@ -153,32 +149,30 @@ function createConfig(manifest, opaConfig, hideFilterBar) {
|
|
|
153
149
|
* @returns the page fonfigs for the LR and the OP if they're found
|
|
154
150
|
*/
|
|
155
151
|
function findLROP(pages, manifest) {
|
|
156
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
157
152
|
const pageLR = pages.find((page) => {
|
|
158
153
|
return page.isStartup && page.template === 'ListReport';
|
|
159
154
|
});
|
|
160
155
|
if (!pageLR) {
|
|
161
156
|
return {};
|
|
162
157
|
}
|
|
163
|
-
const appTargets =
|
|
164
|
-
const appRoutes = (
|
|
158
|
+
const appTargets = manifest['sap.ui5']?.routing?.targets;
|
|
159
|
+
const appRoutes = (manifest['sap.ui5']?.routing?.routes ?? []);
|
|
165
160
|
const target = (appTargets && appTargets[pageLR.targetKey]);
|
|
166
|
-
if (!
|
|
161
|
+
if (!target?.options?.settings?.navigation) {
|
|
167
162
|
return { pageLR }; // No navigation from LR
|
|
168
163
|
}
|
|
169
164
|
// Find all targets that can be navigated from the LR page
|
|
170
165
|
const navigatedTargetKeys = [];
|
|
171
166
|
for (const navKey in target.options.settings.navigation) {
|
|
172
167
|
const navObject = target.options.settings.navigation[navKey];
|
|
173
|
-
const navigatedRoute =
|
|
168
|
+
const navigatedRoute = navObject.detail?.route &&
|
|
174
169
|
appRoutes.find((route) => {
|
|
175
|
-
|
|
176
|
-
return route.name === ((_a = navObject.detail) === null || _a === void 0 ? void 0 : _a.route);
|
|
170
|
+
return route.name === navObject.detail?.route;
|
|
177
171
|
});
|
|
178
|
-
if (Array.isArray(navigatedRoute
|
|
172
|
+
if (Array.isArray(navigatedRoute?.target)) {
|
|
179
173
|
navigatedTargetKeys.push(...navigatedRoute.target);
|
|
180
174
|
}
|
|
181
|
-
else if (navigatedRoute
|
|
175
|
+
else if (navigatedRoute?.target) {
|
|
182
176
|
navigatedTargetKeys.push(navigatedRoute.target);
|
|
183
177
|
}
|
|
184
178
|
}
|
|
@@ -220,7 +214,6 @@ function writePageObject(pageConfig, rootTemplateDirPath, testOutDirPath, fs) {
|
|
|
220
214
|
* @returns Reference to a mem-fs-editor
|
|
221
215
|
*/
|
|
222
216
|
function generateOPAFiles(basePath, opaConfig, fs) {
|
|
223
|
-
var _a, _b;
|
|
224
217
|
const editor = fs || (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
225
218
|
const manifest = readManifest(editor, basePath);
|
|
226
219
|
const { applicationType, hideFilterBar } = getAppTypeAndHideFilterBarFromManifest(manifest);
|
|
@@ -243,8 +236,8 @@ function generateOPAFiles(basePath, opaConfig, fs) {
|
|
|
243
236
|
const LROP = findLROP(config.pages, manifest);
|
|
244
237
|
const journeyParams = {
|
|
245
238
|
startPages,
|
|
246
|
-
startLR:
|
|
247
|
-
navigatedOP:
|
|
239
|
+
startLR: LROP.pageLR?.targetKey,
|
|
240
|
+
navigatedOP: LROP.pageOP?.targetKey,
|
|
248
241
|
hideFilterBar: config.hideFilterBar
|
|
249
242
|
};
|
|
250
243
|
editor.copyTpl((0, path_1.join)(rootV4TemplateDirPath, 'integration/FirstJourney.js'), (0, path_1.join)(testOutDirPath, `integration/${config.opaJourneyFileName}.js`), journeyParams, undefined, {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui5-test-writer",
|
|
3
3
|
"description": "SAP UI5 tests writer",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@types/mem-fs": "1.1.2",
|
|
32
32
|
"@types/mem-fs-editor": "7.0.1",
|
|
33
33
|
"fs-extra": "10.0.0",
|
|
34
|
-
"@sap-ux/project-access": "1.
|
|
34
|
+
"@sap-ux/project-access": "1.26.3"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=18.x"
|