@sap-ux/ui5-test-writer 0.7.27 → 0.7.29
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.
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.readManifest = readManifest;
|
|
4
4
|
exports.generateOPAFiles = generateOPAFiles;
|
|
5
5
|
exports.generatePageObjectFile = generatePageObjectFile;
|
|
6
|
-
const
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
7
|
const mem_fs_1 = require("mem-fs");
|
|
8
8
|
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
9
9
|
const types_1 = require("./types");
|
|
@@ -17,10 +17,10 @@ const project_access_1 = require("@sap-ux/project-access");
|
|
|
17
17
|
* @returns the manifest object. An exception is thrown if the manifest cannot be read.
|
|
18
18
|
*/
|
|
19
19
|
function readManifest(fs, basePath) {
|
|
20
|
-
const manifest = fs.readJSON((0,
|
|
20
|
+
const manifest = fs.readJSON((0, node_path_1.join)(basePath, project_access_1.DirName.Webapp, project_access_1.FileName.Manifest));
|
|
21
21
|
if (!manifest) {
|
|
22
22
|
throw new types_1.ValidationError((0, i18n_1.t)('error.cannotReadManifest', {
|
|
23
|
-
filePath: (0,
|
|
23
|
+
filePath: (0, node_path_1.join)(basePath, project_access_1.DirName.Webapp, project_access_1.FileName.Manifest)
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
26
|
return manifest;
|
|
@@ -200,7 +200,7 @@ function findLROP(pages, manifest) {
|
|
|
200
200
|
* @param fs - a reference to a mem-fs editor
|
|
201
201
|
*/
|
|
202
202
|
function writePageObject(pageConfig, rootTemplateDirPath, testOutDirPath, fs) {
|
|
203
|
-
fs.copyTpl((0,
|
|
203
|
+
fs.copyTpl((0, node_path_1.join)(rootTemplateDirPath, `integration/pages/${pageConfig.template}.js`), (0, node_path_1.join)(testOutDirPath, `integration/pages/${pageConfig.targetKey}.js`), pageConfig, undefined, {
|
|
204
204
|
globOptions: { dot: true }
|
|
205
205
|
});
|
|
206
206
|
}
|
|
@@ -221,17 +221,17 @@ function generateOPAFiles(basePath, opaConfig, fs) {
|
|
|
221
221
|
const manifest = readManifest(editor, basePath);
|
|
222
222
|
const { applicationType, hideFilterBar } = getAppTypeAndHideFilterBarFromManifest(manifest);
|
|
223
223
|
const config = createConfig(manifest, opaConfig, hideFilterBar);
|
|
224
|
-
const rootCommonTemplateDirPath = (0,
|
|
225
|
-
const rootV4TemplateDirPath = (0,
|
|
226
|
-
const testOutDirPath = (0,
|
|
224
|
+
const rootCommonTemplateDirPath = (0, node_path_1.join)(__dirname, '../templates/common');
|
|
225
|
+
const rootV4TemplateDirPath = (0, node_path_1.join)(__dirname, `../templates/${applicationType}`); // Only v4 is supported for the time being
|
|
226
|
+
const testOutDirPath = (0, node_path_1.join)(basePath, 'webapp/test');
|
|
227
227
|
// Common test files
|
|
228
|
-
editor.copyTpl((0,
|
|
228
|
+
editor.copyTpl((0, node_path_1.join)(rootCommonTemplateDirPath), testOutDirPath,
|
|
229
229
|
// unit tests are not added for Fiori elements app
|
|
230
230
|
{ appId: config.appID }, undefined, {
|
|
231
231
|
globOptions: { dot: true }
|
|
232
232
|
});
|
|
233
233
|
// Integration (OPA) test files - version-specific
|
|
234
|
-
editor.copyTpl((0,
|
|
234
|
+
editor.copyTpl((0, node_path_1.join)(rootV4TemplateDirPath, 'integration', 'opaTests.*.*'), (0, node_path_1.join)(testOutDirPath, 'integration'), config, undefined, {
|
|
235
235
|
globOptions: { dot: true }
|
|
236
236
|
});
|
|
237
237
|
// Pages files (one for each page in the app)
|
|
@@ -247,11 +247,11 @@ function generateOPAFiles(basePath, opaConfig, fs) {
|
|
|
247
247
|
navigatedOP: LROP.pageOP?.targetKey,
|
|
248
248
|
hideFilterBar: config.hideFilterBar
|
|
249
249
|
};
|
|
250
|
-
editor.copyTpl((0,
|
|
250
|
+
editor.copyTpl((0, node_path_1.join)(rootV4TemplateDirPath, 'integration/FirstJourney.js'), (0, node_path_1.join)(testOutDirPath, `integration/${config.opaJourneyFileName}.js`), journeyParams, undefined, {
|
|
251
251
|
globOptions: { dot: true }
|
|
252
252
|
});
|
|
253
253
|
// Journey Runner
|
|
254
|
-
editor.copyTpl((0,
|
|
254
|
+
editor.copyTpl((0, node_path_1.join)(rootV4TemplateDirPath, 'integration', 'pages', 'JourneyRunner.js'), (0, node_path_1.join)(testOutDirPath, 'integration', 'pages', 'JourneyRunner.js'), config, undefined, {
|
|
255
255
|
globOptions: { dot: true }
|
|
256
256
|
});
|
|
257
257
|
return editor;
|
|
@@ -273,8 +273,8 @@ function generatePageObjectFile(basePath, pageObjectParameters, fs) {
|
|
|
273
273
|
const { applicationType } = getAppTypeAndHideFilterBarFromManifest(manifest);
|
|
274
274
|
const pageConfig = createPageConfig(manifest, pageObjectParameters.targetKey, pageObjectParameters.appID);
|
|
275
275
|
if (pageConfig) {
|
|
276
|
-
const rootTemplateDirPath = (0,
|
|
277
|
-
const testOutDirPath = (0,
|
|
276
|
+
const rootTemplateDirPath = (0, node_path_1.join)(__dirname, `../templates/${applicationType}`); // Only v4 is supported for the time being
|
|
277
|
+
const testOutDirPath = (0, node_path_1.join)(basePath, 'webapp/test');
|
|
278
278
|
writePageObject(pageConfig, rootTemplateDirPath, testOutDirPath, editor);
|
|
279
279
|
}
|
|
280
280
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateFreestyleOPAFiles = generateFreestyleOPAFiles;
|
|
4
|
-
const
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
5
|
const mem_fs_1 = require("mem-fs");
|
|
6
6
|
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
7
7
|
const project_access_1 = require("@sap-ux/project-access");
|
|
@@ -16,12 +16,12 @@ const ui5_application_writer_1 = require("@sap-ux/ui5-application-writer");
|
|
|
16
16
|
*/
|
|
17
17
|
function writeOPATsconfigJsonUpdates(fs, destinationRoot, log) {
|
|
18
18
|
try {
|
|
19
|
-
const tsconfig = fs.readJSON((0,
|
|
19
|
+
const tsconfig = fs.readJSON((0, node_path_1.join)(destinationRoot, project_access_1.FileName.Tsconfig)) ?? {};
|
|
20
20
|
tsconfig.compilerOptions = tsconfig.compilerOptions || {};
|
|
21
21
|
tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || {};
|
|
22
22
|
tsconfig.compilerOptions.paths['unit/*'] = ['./webapp/test/unit/*'];
|
|
23
23
|
tsconfig.compilerOptions.paths['integration/*'] = ['./webapp/test/integration/*'];
|
|
24
|
-
fs.writeJSON((0,
|
|
24
|
+
fs.writeJSON((0, node_path_1.join)(destinationRoot, project_access_1.FileName.Tsconfig), tsconfig);
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
27
27
|
log?.error((0, i18n_1.t)('error.errorWritingTsConfig', {
|
|
@@ -55,7 +55,7 @@ function filterByUi5Version(files, templateUi5Version) {
|
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
// For all other files, include only those in the current UI5 version directory.
|
|
58
|
-
return filePath.includes(`${
|
|
58
|
+
return filePath.includes(`${node_path_1.sep}${templateUi5Version}${node_path_1.sep}`);
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -88,7 +88,7 @@ function filterByTypeScript(files, isTypeScript) {
|
|
|
88
88
|
*/
|
|
89
89
|
function getDestFilePath(filePath, freestyleTemplateDir, commonTemplateDir, templateUi5Version) {
|
|
90
90
|
if (filePath.includes(freestyleTemplateDir)) {
|
|
91
|
-
return filePath.replace(freestyleTemplateDir, '').replace(`${
|
|
91
|
+
return filePath.replace(freestyleTemplateDir, '').replace(`${node_path_1.sep}${templateUi5Version}${node_path_1.sep}`, node_path_1.sep);
|
|
92
92
|
}
|
|
93
93
|
else if (filePath.includes(commonTemplateDir)) {
|
|
94
94
|
return filePath.replace(commonTemplateDir, '');
|
|
@@ -109,9 +109,9 @@ function getDestFilePath(filePath, freestyleTemplateDir, commonTemplateDir, temp
|
|
|
109
109
|
async function generateFreestyleOPAFiles(basePath, opaConfig, fs, log) {
|
|
110
110
|
const fsEditor = fs ?? (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
111
111
|
const { enableTypeScript, ui5Version, viewName, appId } = opaConfig;
|
|
112
|
-
const freestyleTemplateDir = (0,
|
|
113
|
-
const commonTemplateDir = (0,
|
|
114
|
-
const testOutDir = (0,
|
|
112
|
+
const freestyleTemplateDir = (0, node_path_1.join)(__dirname, '../templates/freestyle/webapp/test');
|
|
113
|
+
const commonTemplateDir = (0, node_path_1.join)(__dirname, '../templates/common');
|
|
114
|
+
const testOutDir = (0, node_path_1.join)(basePath, 'webapp/test');
|
|
115
115
|
const templateUi5Version = getTemplateUi5Version(ui5Version);
|
|
116
116
|
const appIdWithSlash = appId.replace(/[.]/g, '/'); // Replace all dots with slashes
|
|
117
117
|
const navigationIntent = appId.replace(/[./\\\-\s]/g, ''); // Remove all dots, slashes, dashes, and spaces
|
|
@@ -134,10 +134,10 @@ async function generateFreestyleOPAFiles(basePath, opaConfig, fs, log) {
|
|
|
134
134
|
// - viewName.js files are renamed to include the view name in their file path
|
|
135
135
|
// - viewName.ts files are renamed with the view name appended with 'Page'
|
|
136
136
|
const renameMap = {
|
|
137
|
-
[(0,
|
|
138
|
-
[(0,
|
|
139
|
-
[(0,
|
|
140
|
-
[(0,
|
|
137
|
+
[(0, node_path_1.join)('/integration/pages/viewName.js')]: (0, node_path_1.join)(`integration/pages/${viewName}.js`),
|
|
138
|
+
[(0, node_path_1.join)('/integration/pages/viewName.ts')]: (0, node_path_1.join)(`integration/pages/${viewName}Page.ts`),
|
|
139
|
+
[(0, node_path_1.join)('/unit/controller/viewName.controller.js')]: (0, node_path_1.join)(`unit/controller/${viewName}.controller.js`),
|
|
140
|
+
[(0, node_path_1.join)('/unit/controller/viewName.controller.ts')]: (0, node_path_1.join)(`unit/controller/${viewName}Page.controller.ts`)
|
|
141
141
|
};
|
|
142
142
|
// copy templates
|
|
143
143
|
let freestyleTestTemplatesCopied = false;
|
|
@@ -145,7 +145,7 @@ async function generateFreestyleOPAFiles(basePath, opaConfig, fs, log) {
|
|
|
145
145
|
filteredFiles.forEach((filePath) => {
|
|
146
146
|
// remove template UI5 version from the path
|
|
147
147
|
const destFilePath = getDestFilePath(filePath, freestyleTemplateDir, commonTemplateDir, templateUi5Version);
|
|
148
|
-
const destinationFilePath = (0,
|
|
148
|
+
const destinationFilePath = (0, node_path_1.join)(testOutDir, renameMap?.[destFilePath] ?? destFilePath);
|
|
149
149
|
fsEditor.copyTpl(filePath, destinationFilePath, config, undefined, {
|
|
150
150
|
globOptions: { dot: true }
|
|
151
151
|
});
|
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.7.
|
|
4
|
+
"version": "0.7.29",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"i18next": "25.3.0",
|
|
25
25
|
"mem-fs": "2.1.0",
|
|
26
26
|
"mem-fs-editor": "9.4.0",
|
|
27
|
-
"@sap-ux/ui5-application-writer": "1.5.
|
|
27
|
+
"@sap-ux/ui5-application-writer": "1.5.19",
|
|
28
28
|
"@sap-ux/logger": "0.7.0",
|
|
29
|
-
"@sap-ux/project-access": "1.32.
|
|
29
|
+
"@sap-ux/project-access": "1.32.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/ejs": "3.1.2",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/mem-fs-editor": "7.0.1",
|
|
36
36
|
"rimraf": "5.0.5",
|
|
37
37
|
"fs-extra": "10.0.0",
|
|
38
|
-
"@sap-ux/jest-file-matchers": "0.2.
|
|
38
|
+
"@sap-ux/jest-file-matchers": "0.2.5"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=20.x"
|