@sap-ux/ui5-test-writer 0.3.0 → 0.3.2
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/index.js +17 -10
- package/dist/types.d.ts +2 -0
- package/package.json +2 -3
- package/templates/v4/integration/FirstJourney.js +2 -0
package/dist/index.js
CHANGED
|
@@ -26,22 +26,26 @@ function readManifest(fs, basePath) {
|
|
|
26
26
|
* Retrieves the application type of the main datasource (FreeStyle, FE V2 or FE V4).
|
|
27
27
|
*
|
|
28
28
|
* @param manifest - the app descriptor of the app
|
|
29
|
-
* @returns the application type. An exception is thrown if it can't be found or if it's not supported
|
|
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
|
-
function
|
|
32
|
-
var _a, _b;
|
|
31
|
+
function getAppTypeAndHideFilterBarFromManifest(manifest) {
|
|
32
|
+
var _a, _b, _c, _d, _e;
|
|
33
33
|
const appTargets = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.routing) === null || _b === void 0 ? void 0 : _b.targets;
|
|
34
|
+
let hideFilterBar = false;
|
|
34
35
|
let isFEV4 = false;
|
|
35
36
|
for (const targetKey in appTargets) {
|
|
36
37
|
const target = appTargets[targetKey];
|
|
37
38
|
if (target.type === 'Component' && target.name && target.name in types_1.SupportedPageTypes) {
|
|
38
39
|
isFEV4 = true;
|
|
40
|
+
if (types_1.SupportedPageTypes[target.name] === 'ListReport') {
|
|
41
|
+
hideFilterBar = (_e = (_d = (_c = target.options) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.hideFilterBar) !== null && _e !== void 0 ? _e : false;
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
if (!isFEV4) {
|
|
42
46
|
throw new types_1.ValidationError((0, i18n_1.t)('error.badApplicationType'));
|
|
43
47
|
}
|
|
44
|
-
return 'v4'; // For the time being, only FE V4 is supported
|
|
48
|
+
return { applicationType: 'v4', hideFilterBar }; // For the time being, only FE V4 is supported
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* Retrieves appID and appPath from the manifest.
|
|
@@ -105,9 +109,10 @@ function createPageConfig(manifest, targetKey, forcedAppID) {
|
|
|
105
109
|
* @param opaConfig.scriptName - the name of the OPA journey file. If not specified, 'FirstJourney' will be used
|
|
106
110
|
* @param opaConfig.htmlTarget - the name of the html file that will be used in the OPA journey file. If not specified, 'index.html' will be used
|
|
107
111
|
* @param opaConfig.appID - the appID. If not specified, will be read from the manifest in sap.app/id
|
|
112
|
+
* @param hideFilterBar - whether the filter bar should be hidden in the generated tests
|
|
108
113
|
* @returns OPA test configuration object
|
|
109
114
|
*/
|
|
110
|
-
function createConfig(manifest, opaConfig) {
|
|
115
|
+
function createConfig(manifest, opaConfig, hideFilterBar) {
|
|
111
116
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
112
117
|
// General application info
|
|
113
118
|
const { appID, appPath } = getAppFromManifest(manifest, opaConfig.appID);
|
|
@@ -116,7 +121,8 @@ function createConfig(manifest, opaConfig) {
|
|
|
116
121
|
appPath,
|
|
117
122
|
pages: [],
|
|
118
123
|
opaJourneyFileName: (_a = opaConfig.scriptName) !== null && _a !== void 0 ? _a : 'FirstJourney',
|
|
119
|
-
htmlTarget: (_b = opaConfig.htmlTarget) !== null && _b !== void 0 ? _b : 'index.html'
|
|
124
|
+
htmlTarget: (_b = opaConfig.htmlTarget) !== null && _b !== void 0 ? _b : 'index.html',
|
|
125
|
+
hideFilterBar
|
|
120
126
|
};
|
|
121
127
|
// Identify startup targets from the routes
|
|
122
128
|
const appRoutes = ((_e = (_d = (_c = manifest['sap.ui5']) === null || _c === void 0 ? void 0 : _c.routing) === null || _d === void 0 ? void 0 : _d.routes) !== null && _e !== void 0 ? _e : []);
|
|
@@ -217,8 +223,8 @@ function generateOPAFiles(basePath, opaConfig, fs) {
|
|
|
217
223
|
var _a, _b;
|
|
218
224
|
const editor = fs || (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
219
225
|
const manifest = readManifest(editor, basePath);
|
|
220
|
-
const applicationType =
|
|
221
|
-
const config = createConfig(manifest, opaConfig);
|
|
226
|
+
const { applicationType, hideFilterBar } = getAppTypeAndHideFilterBarFromManifest(manifest);
|
|
227
|
+
const config = createConfig(manifest, opaConfig, hideFilterBar);
|
|
222
228
|
const rootCommonTemplateDirPath = (0, path_1.join)(__dirname, '../templates/common');
|
|
223
229
|
const rootV4TemplateDirPath = (0, path_1.join)(__dirname, `../templates/${applicationType}`); // Only v4 is supported for the time being
|
|
224
230
|
const testOutDirPath = (0, path_1.join)(basePath, 'webapp/test');
|
|
@@ -238,7 +244,8 @@ function generateOPAFiles(basePath, opaConfig, fs) {
|
|
|
238
244
|
const journeyParams = {
|
|
239
245
|
startPages,
|
|
240
246
|
startLR: (_a = LROP.pageLR) === null || _a === void 0 ? void 0 : _a.targetKey,
|
|
241
|
-
navigatedOP: (_b = LROP.pageOP) === null || _b === void 0 ? void 0 : _b.targetKey
|
|
247
|
+
navigatedOP: (_b = LROP.pageOP) === null || _b === void 0 ? void 0 : _b.targetKey,
|
|
248
|
+
hideFilterBar: config.hideFilterBar
|
|
242
249
|
};
|
|
243
250
|
editor.copyTpl((0, path_1.join)(rootV4TemplateDirPath, 'integration/FirstJourney.js'), (0, path_1.join)(testOutDirPath, `integration/${config.opaJourneyFileName}.js`), journeyParams, undefined, {
|
|
244
251
|
globOptions: { dot: true }
|
|
@@ -260,7 +267,7 @@ exports.generateOPAFiles = generateOPAFiles;
|
|
|
260
267
|
function generatePageObjectFile(basePath, pageObjectParameters, fs) {
|
|
261
268
|
const editor = fs || (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
262
269
|
const manifest = readManifest(editor, basePath);
|
|
263
|
-
const applicationType =
|
|
270
|
+
const { applicationType } = getAppTypeAndHideFilterBarFromManifest(manifest);
|
|
264
271
|
const pageConfig = createPageConfig(manifest, pageObjectParameters.targetKey, pageObjectParameters.appID);
|
|
265
272
|
if (pageConfig) {
|
|
266
273
|
const rootTemplateDirPath = (0, path_1.join)(__dirname, `../templates/${applicationType}`); // Only v4 is supported for the time being
|
package/dist/types.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type FEV4OPAConfig = {
|
|
|
17
17
|
pages: FEV4OPAPageConfig[];
|
|
18
18
|
opaJourneyFileName: string;
|
|
19
19
|
htmlTarget: string;
|
|
20
|
+
hideFilterBar: boolean;
|
|
20
21
|
};
|
|
21
22
|
export type FEV4ManifestTarget = {
|
|
22
23
|
type?: string;
|
|
@@ -26,6 +27,7 @@ export type FEV4ManifestTarget = {
|
|
|
26
27
|
settings?: {
|
|
27
28
|
entitySet?: string;
|
|
28
29
|
contextPath?: string;
|
|
30
|
+
hideFilterBar?: boolean;
|
|
29
31
|
navigation?: {
|
|
30
32
|
[id: string]: {
|
|
31
33
|
detail?: {
|
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.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -31,10 +31,9 @@
|
|
|
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.17.4"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
|
-
"pnpm": ">=6.26.1 < 7.0.0 || >=7.1.0",
|
|
38
37
|
"node": ">=18.x"
|
|
39
38
|
},
|
|
40
39
|
"scripts": {
|
|
@@ -17,7 +17,9 @@ sap.ui.define([
|
|
|
17
17
|
<% if (startLR) { %>
|
|
18
18
|
opaTest("Navigate to ObjectPage", function (Given, When, Then) {
|
|
19
19
|
// Note: this test will fail if the ListReport page doesn't show any data
|
|
20
|
+
<% if (!hideFilterBar) { %>
|
|
20
21
|
When.onThe<%- startLR%>.onFilterBar().iExecuteSearch();
|
|
22
|
+
<%} %>
|
|
21
23
|
Then.onThe<%- startLR%>.onTable().iCheckRows();
|
|
22
24
|
<% if (navigatedOP) { %>
|
|
23
25
|
When.onThe<%- startLR%>.onTable().iPressRow(0);
|