@sap-ux/ui5-test-writer 0.4.1 → 0.5.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/fiori-elements-opa-writer.d.ts +43 -0
- package/dist/fiori-elements-opa-writer.js +283 -0
- package/dist/fiori-freestyle-opa-writer.d.ts +14 -0
- package/dist/fiori-freestyle-opa-writer.js +166 -0
- package/dist/i18n.js +2 -3
- package/dist/index.d.ts +2 -33
- package/dist/index.js +5 -275
- package/dist/translations/ui5-test-writer.i18n.json +3 -1
- package/dist/types.d.ts +12 -0
- package/package.json +5 -3
- package/templates/freestyle/webapp/test/1.120.0/integration/AllJourneys.js +13 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/NavigationJourney.js +23 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/NavigationJourney.ts +34 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/arrangements/Startup.js +25 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/opaTests.qunit.html +29 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/opaTests.qunit.js +7 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/opaTests.qunit.ts +6 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/pages/App.js +28 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/pages/AppPage.ts +22 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/pages/viewName.js +28 -0
- package/templates/freestyle/webapp/test/1.120.0/integration/pages/viewName.ts +23 -0
- package/templates/freestyle/webapp/test/1.120.0/unit/AllTests.js +5 -0
- package/templates/freestyle/webapp/test/1.120.0/unit/controller/viewName.controller.js +16 -0
- package/templates/freestyle/webapp/test/1.120.0/unit/controller/viewName.controller.ts +10 -0
- package/templates/freestyle/webapp/test/1.120.0/unit/unitTests.qunit.html +28 -0
- package/templates/freestyle/webapp/test/1.120.0/unit/unitTests.qunit.js +12 -0
- package/templates/freestyle/webapp/test/1.120.0/unit/unitTests.qunit.ts +10 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/AllJourneys.js +13 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/NavigationJourney.js +23 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/NavigationJourney.ts +34 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/arrangements/Startup.js +25 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/opaTests.qunit.html +29 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/opaTests.qunit.js +7 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/opaTests.qunit.ts +10 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/pages/App.js +28 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/pages/AppPage.ts +22 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/pages/viewName.js +28 -0
- package/templates/freestyle/webapp/test/1.71.0/integration/pages/viewName.ts +23 -0
- package/templates/freestyle/webapp/test/1.71.0/unit/AllTests.js +5 -0
- package/templates/freestyle/webapp/test/1.71.0/unit/controller/viewName.controller.js +16 -0
- package/templates/freestyle/webapp/test/1.71.0/unit/controller/viewName.controller.ts +10 -0
- package/templates/freestyle/webapp/test/1.71.0/unit/unitTests.qunit.html +27 -0
- package/templates/freestyle/webapp/test/1.71.0/unit/unitTests.qunit.js +12 -0
- package/templates/freestyle/webapp/test/1.71.0/unit/unitTests.qunit.ts +10 -0
- package/templates/freestyle/webapp/test/testsuite.qunit.js +16 -0
- package/templates/freestyle/webapp/test/testsuite.qunit.ts +14 -0
package/dist/index.js
CHANGED
|
@@ -1,278 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const i18n_1 = require("./i18n");
|
|
9
|
-
/**
|
|
10
|
-
* Reads the manifest for an app.
|
|
11
|
-
*
|
|
12
|
-
* @param fs - a reference to a mem-fs editor
|
|
13
|
-
* @param basePath - the root folder of the app
|
|
14
|
-
* @returns the manifest object. An exception is thrown if the manifest cannot be read.
|
|
15
|
-
*/
|
|
16
|
-
function readManifest(fs, basePath) {
|
|
17
|
-
const manifest = fs.readJSON((0, path_1.join)(basePath, 'webapp/manifest.json'));
|
|
18
|
-
if (!manifest) {
|
|
19
|
-
throw new types_1.ValidationError((0, i18n_1.t)('error.cannotReadManifest', {
|
|
20
|
-
filePath: (0, path_1.join)(basePath, 'webapp/manifest.json')
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
return manifest;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Retrieves the application type of the main datasource (FreeStyle, FE V2 or FE V4).
|
|
27
|
-
*
|
|
28
|
-
* @param manifest - the app descriptor of the app
|
|
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
|
-
*/
|
|
31
|
-
function getAppTypeAndHideFilterBarFromManifest(manifest) {
|
|
32
|
-
const appTargets = manifest['sap.ui5']?.routing?.targets;
|
|
33
|
-
let hideFilterBar = false;
|
|
34
|
-
let isFEV4 = false;
|
|
35
|
-
for (const targetKey in appTargets) {
|
|
36
|
-
const target = appTargets[targetKey];
|
|
37
|
-
if (target.type === 'Component' && target.name && target.name in types_1.SupportedPageTypes) {
|
|
38
|
-
isFEV4 = true;
|
|
39
|
-
if (types_1.SupportedPageTypes[target.name] === 'ListReport') {
|
|
40
|
-
hideFilterBar = target.options?.settings?.hideFilterBar ?? false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!isFEV4) {
|
|
45
|
-
throw new types_1.ValidationError((0, i18n_1.t)('error.badApplicationType'));
|
|
46
|
-
}
|
|
47
|
-
return { applicationType: 'v4', hideFilterBar }; // For the time being, only FE V4 is supported
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Retrieves appID and appPath from the manifest.
|
|
51
|
-
*
|
|
52
|
-
* @param manifest - the app descriptor of the app
|
|
53
|
-
* @param forcedAppID - the appID in case we don't want to read it from the manifest
|
|
54
|
-
* @returns appID and appPath
|
|
55
|
-
*/
|
|
56
|
-
function getAppFromManifest(manifest, forcedAppID) {
|
|
57
|
-
const appID = forcedAppID || manifest['sap.app']?.id;
|
|
58
|
-
const appPath = appID?.split('.').join('/');
|
|
59
|
-
if (!appID || !appPath) {
|
|
60
|
-
throw new types_1.ValidationError((0, i18n_1.t)('error.cannotReadAppID'));
|
|
61
|
-
}
|
|
62
|
-
return { appID, appPath };
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Create the page configuration object from the app descriptor and the target key.
|
|
66
|
-
*
|
|
67
|
-
* @param manifest - the app descriptor of the app
|
|
68
|
-
* @param targetKey - the key of the target in the manifest
|
|
69
|
-
* @param forcedAppID - the appID in case we don't want to read it from the manifest
|
|
70
|
-
* @returns Page configuration object, or undefined if the target type is not supported
|
|
71
|
-
*/
|
|
72
|
-
function createPageConfig(manifest, targetKey, forcedAppID) {
|
|
73
|
-
const appTargets = manifest['sap.ui5']?.routing?.targets;
|
|
74
|
-
const target = appTargets && appTargets[targetKey];
|
|
75
|
-
const { appID, appPath } = getAppFromManifest(manifest, forcedAppID);
|
|
76
|
-
if (target?.type === 'Component' &&
|
|
77
|
-
target?.name &&
|
|
78
|
-
target.name in types_1.SupportedPageTypes &&
|
|
79
|
-
target?.id &&
|
|
80
|
-
(target?.options?.settings?.entitySet || target?.options?.settings?.contextPath)) {
|
|
81
|
-
const pageConfig = {
|
|
82
|
-
appPath,
|
|
83
|
-
appID,
|
|
84
|
-
targetKey,
|
|
85
|
-
componentID: target.id,
|
|
86
|
-
template: types_1.SupportedPageTypes[target.name],
|
|
87
|
-
isStartup: false
|
|
88
|
-
};
|
|
89
|
-
if (target.options.settings.contextPath) {
|
|
90
|
-
pageConfig.contextPath = target.options.settings.contextPath;
|
|
91
|
-
}
|
|
92
|
-
else if (target.options.settings.entitySet) {
|
|
93
|
-
pageConfig.entitySet = target.options.settings.entitySet;
|
|
94
|
-
}
|
|
95
|
-
return pageConfig;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Create the configuration object from the app descriptor.
|
|
103
|
-
*
|
|
104
|
-
* @param manifest - the app descriptor of the target app
|
|
105
|
-
* @param opaConfig - parameters for the generation
|
|
106
|
-
* @param opaConfig.scriptName - the name of the OPA journey file. If not specified, 'FirstJourney' will be used
|
|
107
|
-
* @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
|
|
108
|
-
* @param opaConfig.appID - the appID. If not specified, will be read from the manifest in sap.app/id
|
|
109
|
-
* @param hideFilterBar - whether the filter bar should be hidden in the generated tests
|
|
110
|
-
* @returns OPA test configuration object
|
|
111
|
-
*/
|
|
112
|
-
function createConfig(manifest, opaConfig, hideFilterBar) {
|
|
113
|
-
// General application info
|
|
114
|
-
const { appID, appPath } = getAppFromManifest(manifest, opaConfig.appID);
|
|
115
|
-
const config = {
|
|
116
|
-
appID,
|
|
117
|
-
appPath,
|
|
118
|
-
pages: [],
|
|
119
|
-
opaJourneyFileName: opaConfig.scriptName ?? 'FirstJourney',
|
|
120
|
-
htmlTarget: opaConfig.htmlTarget ?? 'index.html',
|
|
121
|
-
hideFilterBar
|
|
122
|
-
};
|
|
123
|
-
// Identify startup targets from the routes
|
|
124
|
-
const appRoutes = (manifest['sap.ui5']?.routing?.routes ?? []);
|
|
125
|
-
// Find the route with an empty pattern (except for the trailing query part)
|
|
126
|
-
const startupRoute = appRoutes.find((route) => {
|
|
127
|
-
return route.pattern.replace(':?query:', '') === '';
|
|
128
|
-
});
|
|
129
|
-
let startupTargets = startupRoute?.target ?? [];
|
|
130
|
-
if (!Array.isArray(startupTargets)) {
|
|
131
|
-
startupTargets = [startupTargets];
|
|
132
|
-
}
|
|
133
|
-
// Create page configurations in supported cases
|
|
134
|
-
const appTargets = manifest['sap.ui5']?.routing?.targets;
|
|
135
|
-
for (const targetKey in appTargets) {
|
|
136
|
-
const pageConfig = createPageConfig(manifest, targetKey, opaConfig.appID);
|
|
137
|
-
if (pageConfig) {
|
|
138
|
-
pageConfig.isStartup = startupTargets.includes(targetKey);
|
|
139
|
-
config.pages.push(pageConfig);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return config;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Finds the initial ListReport page and the first Object page from the app.
|
|
146
|
-
*
|
|
147
|
-
* @param pages - the page configs of the app
|
|
148
|
-
* @param manifest - the app descriptor of the target app
|
|
149
|
-
* @returns the page fonfigs for the LR and the OP if they're found
|
|
150
|
-
*/
|
|
151
|
-
function findLROP(pages, manifest) {
|
|
152
|
-
const pageLR = pages.find((page) => {
|
|
153
|
-
return page.isStartup && page.template === 'ListReport';
|
|
154
|
-
});
|
|
155
|
-
if (!pageLR) {
|
|
156
|
-
return {};
|
|
157
|
-
}
|
|
158
|
-
const appTargets = manifest['sap.ui5']?.routing?.targets;
|
|
159
|
-
const appRoutes = (manifest['sap.ui5']?.routing?.routes ?? []);
|
|
160
|
-
const target = (appTargets && appTargets[pageLR.targetKey]);
|
|
161
|
-
if (!target?.options?.settings?.navigation) {
|
|
162
|
-
return { pageLR }; // No navigation from LR
|
|
163
|
-
}
|
|
164
|
-
// Find all targets that can be navigated from the LR page
|
|
165
|
-
const navigatedTargetKeys = [];
|
|
166
|
-
for (const navKey in target.options.settings.navigation) {
|
|
167
|
-
const navObject = target.options.settings.navigation[navKey];
|
|
168
|
-
const navigatedRoute = navObject.detail?.route &&
|
|
169
|
-
appRoutes.find((route) => {
|
|
170
|
-
return route.name === navObject.detail?.route;
|
|
171
|
-
});
|
|
172
|
-
if (Array.isArray(navigatedRoute?.target)) {
|
|
173
|
-
navigatedTargetKeys.push(...navigatedRoute.target);
|
|
174
|
-
}
|
|
175
|
-
else if (navigatedRoute?.target) {
|
|
176
|
-
navigatedTargetKeys.push(navigatedRoute.target);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
// Find the first navigated page that is valid and not the starting LR
|
|
180
|
-
let pageOP;
|
|
181
|
-
for (let i = 0; i < navigatedTargetKeys.length && !pageOP; i++) {
|
|
182
|
-
if (navigatedTargetKeys[i] === pageLR.targetKey) {
|
|
183
|
-
continue; // This can happen in the FCL case where the LR is also part of the route's targets to the OP
|
|
184
|
-
}
|
|
185
|
-
pageOP = pages.find((page) => {
|
|
186
|
-
return page.targetKey === navigatedTargetKeys[i];
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
return { pageLR, pageOP };
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Writes a page object in a mem-fs-editor.
|
|
193
|
-
*
|
|
194
|
-
* @param pageConfig - the page configuration object
|
|
195
|
-
* @param rootTemplateDirPath - template root directory
|
|
196
|
-
* @param testOutDirPath - output test directory (.../webapp/test)
|
|
197
|
-
* @param fs - a reference to a mem-fs editor
|
|
198
|
-
*/
|
|
199
|
-
function writePageObject(pageConfig, rootTemplateDirPath, testOutDirPath, fs) {
|
|
200
|
-
fs.copyTpl((0, path_1.join)(rootTemplateDirPath, `integration/pages/${pageConfig.template}.js`), (0, path_1.join)(testOutDirPath, `integration/pages/${pageConfig.targetKey}.js`), pageConfig, undefined, {
|
|
201
|
-
globOptions: { dot: true }
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Generate OPA test files for a Fiori elements for OData V4 application.
|
|
206
|
-
* Note: this can potentially overwrite existing files in the webapp/test folder.
|
|
207
|
-
*
|
|
208
|
-
* @param basePath - the absolute target path where the application will be generated
|
|
209
|
-
* @param opaConfig - parameters for the generation
|
|
210
|
-
* @param opaConfig.scriptName - the name of the OPA journey file. If not specified, 'FirstJourney' will be used
|
|
211
|
-
* @param opaConfig.htmlTarget - the name of the html that will be used in OPA journey file. If not specified, 'index.html' will be used
|
|
212
|
-
* @param opaConfig.appID - the appID. If not specified, will be read from the manifest in sap.app/id
|
|
213
|
-
* @param fs - an optional reference to a mem-fs editor
|
|
214
|
-
* @returns Reference to a mem-fs-editor
|
|
215
|
-
*/
|
|
216
|
-
function generateOPAFiles(basePath, opaConfig, fs) {
|
|
217
|
-
const editor = fs || (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
218
|
-
const manifest = readManifest(editor, basePath);
|
|
219
|
-
const { applicationType, hideFilterBar } = getAppTypeAndHideFilterBarFromManifest(manifest);
|
|
220
|
-
const config = createConfig(manifest, opaConfig, hideFilterBar);
|
|
221
|
-
const rootCommonTemplateDirPath = (0, path_1.join)(__dirname, '../templates/common');
|
|
222
|
-
const rootV4TemplateDirPath = (0, path_1.join)(__dirname, `../templates/${applicationType}`); // Only v4 is supported for the time being
|
|
223
|
-
const testOutDirPath = (0, path_1.join)(basePath, 'webapp/test');
|
|
224
|
-
// Common test files
|
|
225
|
-
editor.copy((0, path_1.join)(rootCommonTemplateDirPath), testOutDirPath);
|
|
226
|
-
// Integration (OPA) test files - version-specific
|
|
227
|
-
editor.copyTpl((0, path_1.join)(rootV4TemplateDirPath, 'integration', 'opaTests.*.*'), (0, path_1.join)(testOutDirPath, 'integration'), config, undefined, {
|
|
228
|
-
globOptions: { dot: true }
|
|
229
|
-
});
|
|
230
|
-
// Pages files (one for each page in the app)
|
|
231
|
-
config.pages.forEach((page) => {
|
|
232
|
-
writePageObject(page, rootV4TemplateDirPath, testOutDirPath, editor);
|
|
233
|
-
});
|
|
234
|
-
// OPA Journey file
|
|
235
|
-
const startPages = config.pages.filter((page) => page.isStartup).map((page) => page.targetKey);
|
|
236
|
-
const LROP = findLROP(config.pages, manifest);
|
|
237
|
-
const journeyParams = {
|
|
238
|
-
startPages,
|
|
239
|
-
startLR: LROP.pageLR?.targetKey,
|
|
240
|
-
navigatedOP: LROP.pageOP?.targetKey,
|
|
241
|
-
hideFilterBar: config.hideFilterBar
|
|
242
|
-
};
|
|
243
|
-
editor.copyTpl((0, path_1.join)(rootV4TemplateDirPath, 'integration/FirstJourney.js'), (0, path_1.join)(testOutDirPath, `integration/${config.opaJourneyFileName}.js`), journeyParams, undefined, {
|
|
244
|
-
globOptions: { dot: true }
|
|
245
|
-
});
|
|
246
|
-
return editor;
|
|
247
|
-
}
|
|
248
|
-
exports.generateOPAFiles = generateOPAFiles;
|
|
249
|
-
/**
|
|
250
|
-
* Generate a page object file for a Fiori elements for OData V4 application.
|
|
251
|
-
* Note: this doesn't modify other existing files in the webapp/test folder.
|
|
252
|
-
*
|
|
253
|
-
* @param basePath - the absolute target path where the application will be generated
|
|
254
|
-
* @param pageObjectParameters - parameters for the page
|
|
255
|
-
* @param pageObjectParameters.targetKey - the key of the target in the manifest file corresponding to the page
|
|
256
|
-
* @param pageObjectParameters.appID - the appID. If not specified, will be read from the manifest in sap.app/id
|
|
257
|
-
* @param fs - an optional reference to a mem-fs editor
|
|
258
|
-
* @returns Reference to a mem-fs-editor
|
|
259
|
-
*/
|
|
260
|
-
function generatePageObjectFile(basePath, pageObjectParameters, fs) {
|
|
261
|
-
const editor = fs || (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
262
|
-
const manifest = readManifest(editor, basePath);
|
|
263
|
-
const { applicationType } = getAppTypeAndHideFilterBarFromManifest(manifest);
|
|
264
|
-
const pageConfig = createPageConfig(manifest, pageObjectParameters.targetKey, pageObjectParameters.appID);
|
|
265
|
-
if (pageConfig) {
|
|
266
|
-
const rootTemplateDirPath = (0, path_1.join)(__dirname, `../templates/${applicationType}`); // Only v4 is supported for the time being
|
|
267
|
-
const testOutDirPath = (0, path_1.join)(basePath, 'webapp/test');
|
|
268
|
-
writePageObject(pageConfig, rootTemplateDirPath, testOutDirPath, editor);
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
throw new types_1.ValidationError((0, i18n_1.t)('error.cannotGeneratePageFile', {
|
|
272
|
-
targetKey: pageObjectParameters.targetKey
|
|
273
|
-
}));
|
|
274
|
-
}
|
|
275
|
-
return editor;
|
|
276
|
-
}
|
|
277
|
-
exports.generatePageObjectFile = generatePageObjectFile;
|
|
3
|
+
exports.generateFreestyleOPAFiles = exports.generateOPAFiles = void 0;
|
|
4
|
+
var fiori_elements_opa_writer_1 = require("./fiori-elements-opa-writer");
|
|
5
|
+
Object.defineProperty(exports, "generateOPAFiles", { enumerable: true, get: function () { return fiori_elements_opa_writer_1.generateOPAFiles; } });
|
|
6
|
+
var fiori_freestyle_opa_writer_1 = require("./fiori-freestyle-opa-writer");
|
|
7
|
+
Object.defineProperty(exports, "generateFreestyleOPAFiles", { enumerable: true, get: function () { return fiori_freestyle_opa_writer_1.generateFreestyleOPAFiles; } });
|
|
278
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
"cannotReadManifest": "Cannot read manifest file {{ filePath }}",
|
|
4
4
|
"cannotReadAppID": "Cannot read appID in the manifest file",
|
|
5
5
|
"badApplicationType": "Cannot determine application type from the manifest, or unsupported type",
|
|
6
|
-
"cannotGeneratePageFile": "Cannot generate page file for target {{ targetKey }}"
|
|
6
|
+
"cannotGeneratePageFile": "Cannot generate page file for target {{ targetKey }}",
|
|
7
|
+
"errorCopyingFreestyleTestTemplates": "Error copying freestyle test templates: {{ error }}",
|
|
8
|
+
"errorWritingTsConfig": "Error writing tsconfig.json: {{ error }}"
|
|
7
9
|
}
|
|
8
10
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -49,4 +49,16 @@ export declare class ValidationError extends Error {
|
|
|
49
49
|
*/
|
|
50
50
|
constructor(message: string);
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Configuration interface for generating freestyle OPA test files
|
|
54
|
+
*/
|
|
55
|
+
export interface FFOPAConfig {
|
|
56
|
+
appId: string;
|
|
57
|
+
applicationTitle?: string;
|
|
58
|
+
applicationDescription?: string;
|
|
59
|
+
enableTypeScript?: boolean;
|
|
60
|
+
viewName?: string;
|
|
61
|
+
ui5Version?: string;
|
|
62
|
+
ui5Theme?: string;
|
|
63
|
+
}
|
|
52
64
|
//# sourceMappingURL=types.d.ts.map
|
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.5.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"ejs": "3.1.10",
|
|
24
24
|
"i18next": "20.6.1",
|
|
25
25
|
"mem-fs": "2.1.0",
|
|
26
|
-
"mem-fs-editor": "9.4.0"
|
|
26
|
+
"mem-fs-editor": "9.4.0",
|
|
27
|
+
"@sap-ux/ui5-application-writer": "1.2.10",
|
|
28
|
+
"@sap-ux/logger": "0.6.0"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
31
|
"@types/ejs": "3.1.2",
|
|
@@ -31,7 +33,7 @@
|
|
|
31
33
|
"@types/mem-fs": "1.1.2",
|
|
32
34
|
"@types/mem-fs-editor": "7.0.1",
|
|
33
35
|
"fs-extra": "10.0.0",
|
|
34
|
-
"@sap-ux/project-access": "1.
|
|
36
|
+
"@sap-ux/project-access": "1.29.8"
|
|
35
37
|
},
|
|
36
38
|
"engines": {
|
|
37
39
|
"node": ">=18.x"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
sap.ui.define([
|
|
2
|
+
"sap/ui/test/Opa5",
|
|
3
|
+
"./arrangements/Startup",
|
|
4
|
+
"./NavigationJourney"
|
|
5
|
+
], function (Opa5, Startup) {
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
Opa5.extendConfig({
|
|
9
|
+
arrangements: new Startup(),
|
|
10
|
+
viewNamespace: "<%= appId %>.view.",
|
|
11
|
+
autoWait: true
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*global QUnit*/
|
|
2
|
+
|
|
3
|
+
sap.ui.define([
|
|
4
|
+
"sap/ui/test/opaQunit",
|
|
5
|
+
"./pages/App",
|
|
6
|
+
"./pages/<%= viewName %>"
|
|
7
|
+
], function (opaTest) {
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
QUnit.module("Navigation Journey");
|
|
11
|
+
|
|
12
|
+
opaTest("Should see the initial page of the app", function (Given, When, Then) {
|
|
13
|
+
// Arrangements
|
|
14
|
+
Given.iStartMyApp();
|
|
15
|
+
|
|
16
|
+
// Assertions
|
|
17
|
+
Then.onTheAppPage.iShouldSeeTheApp();
|
|
18
|
+
Then.onTheViewPage.iShouldSeeThePageView();
|
|
19
|
+
|
|
20
|
+
//Cleanup
|
|
21
|
+
Then.iTeardownMyApp();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*global QUnit*/
|
|
2
|
+
import opaTest from "sap/ui/test/opaQunit";
|
|
3
|
+
import AppPage from "./pages/AppPage";
|
|
4
|
+
import ViewPage from "./pages/<%= viewName %>Page";
|
|
5
|
+
|
|
6
|
+
import Opa5 from "sap/ui/test/Opa5";
|
|
7
|
+
|
|
8
|
+
QUnit.module("Navigation Journey");
|
|
9
|
+
|
|
10
|
+
const onTheAppPage = new AppPage();
|
|
11
|
+
const onTheViewPage = new ViewPage();
|
|
12
|
+
Opa5.extendConfig({
|
|
13
|
+
viewNamespace: "<%= appId %>.view.",
|
|
14
|
+
autoWait: true
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
opaTest("Should see the initial page of the app", function () {
|
|
18
|
+
// Arrangements
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
20
|
+
onTheAppPage.iStartMyUIComponent({
|
|
21
|
+
componentConfig: {
|
|
22
|
+
name: "<%= appId %>"
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Assertions
|
|
27
|
+
onTheAppPage.iShouldSeeTheApp();
|
|
28
|
+
onTheViewPage.iShouldSeeThePageView();
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// Cleanup
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
33
|
+
onTheAppPage.iTeardownMyApp();
|
|
34
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
sap.ui.define([
|
|
2
|
+
"sap/ui/test/Opa5"
|
|
3
|
+
], function (Opa5) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
return Opa5.extend("integration.arrangements.Startup", {
|
|
7
|
+
|
|
8
|
+
iStartMyApp: function (oOptionsParameter) {
|
|
9
|
+
var oOptions = oOptionsParameter || {};
|
|
10
|
+
|
|
11
|
+
// start the app with a minimal delay to make tests fast but still async to discover basic timing issues
|
|
12
|
+
oOptions.delay = oOptions.delay || 50;
|
|
13
|
+
|
|
14
|
+
// start the app UI component
|
|
15
|
+
this.iStartMyUIComponent({
|
|
16
|
+
componentConfig: {
|
|
17
|
+
name: "<%= appId %>",
|
|
18
|
+
async: true
|
|
19
|
+
},
|
|
20
|
+
hash: oOptions.hash,
|
|
21
|
+
autoWait: oOptions.autoWait
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>Integration tests for Basic Template</title>
|
|
6
|
+
|
|
7
|
+
<script
|
|
8
|
+
id="sap-ui-bootstrap"
|
|
9
|
+
src="../../resources/sap-ui-core.js"
|
|
10
|
+
data-sap-ui-theme="<%= ui5Theme %>"
|
|
11
|
+
data-sap-ui-resourceroots='{
|
|
12
|
+
"<%= appId %>": "../../",
|
|
13
|
+
"integration": "./"
|
|
14
|
+
}'
|
|
15
|
+
data-sap-ui-animation="false"
|
|
16
|
+
data-sap-ui-compatVersion="edge"
|
|
17
|
+
data-sap-ui-async="true"
|
|
18
|
+
data-sap-ui-preload="async">
|
|
19
|
+
</script>
|
|
20
|
+
<link rel="stylesheet" type="text/css" href="../../resources/sap/ui/thirdparty/qunit-2.css">
|
|
21
|
+
<script src="../../resources/sap/ui/thirdparty/qunit-2.js"></script>
|
|
22
|
+
<script src="../../resources/sap/ui/qunit/qunit-junit.js"></script>
|
|
23
|
+
<script src="opaTests.qunit.js"></script>
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
<div id="qunit"></div>
|
|
27
|
+
<div id="qunit-fixture"></div>
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
sap.ui.define([
|
|
2
|
+
"sap/ui/test/Opa5"
|
|
3
|
+
], function (Opa5) {
|
|
4
|
+
"use strict";
|
|
5
|
+
var sViewName = "App";
|
|
6
|
+
|
|
7
|
+
Opa5.createPageObjects({
|
|
8
|
+
onTheAppPage: {
|
|
9
|
+
|
|
10
|
+
actions: {},
|
|
11
|
+
|
|
12
|
+
assertions: {
|
|
13
|
+
|
|
14
|
+
iShouldSeeTheApp: function () {
|
|
15
|
+
return this.waitFor({
|
|
16
|
+
id: "app",
|
|
17
|
+
viewName: sViewName,
|
|
18
|
+
success: function () {
|
|
19
|
+
Opa5.assert.ok(true, "The " + sViewName + " view is displayed");
|
|
20
|
+
},
|
|
21
|
+
errorMessage: "Did not find the " + sViewName + " view"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Opa5 from "sap/ui/test/Opa5";
|
|
2
|
+
|
|
3
|
+
const sViewName = "App";
|
|
4
|
+
|
|
5
|
+
export default class AppPage extends Opa5 {
|
|
6
|
+
// Actions
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// Assertions
|
|
10
|
+
iShouldSeeTheApp() {
|
|
11
|
+
return this.waitFor({
|
|
12
|
+
id: "app",
|
|
13
|
+
viewName: sViewName,
|
|
14
|
+
success: function () {
|
|
15
|
+
Opa5.assert.ok(true, "The " + sViewName + " view is displayed");
|
|
16
|
+
},
|
|
17
|
+
errorMessage: "Did not find the " + sViewName + " view"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
sap.ui.define([
|
|
2
|
+
"sap/ui/test/Opa5"
|
|
3
|
+
], function (Opa5) {
|
|
4
|
+
"use strict";
|
|
5
|
+
var sViewName = "<%= viewName %>";
|
|
6
|
+
|
|
7
|
+
Opa5.createPageObjects({
|
|
8
|
+
onTheViewPage: {
|
|
9
|
+
|
|
10
|
+
actions: {},
|
|
11
|
+
|
|
12
|
+
assertions: {
|
|
13
|
+
|
|
14
|
+
iShouldSeeThePageView: function () {
|
|
15
|
+
return this.waitFor({
|
|
16
|
+
id: "page",
|
|
17
|
+
viewName: sViewName,
|
|
18
|
+
success: function () {
|
|
19
|
+
Opa5.assert.ok(true, "The " + sViewName + " view is displayed");
|
|
20
|
+
},
|
|
21
|
+
errorMessage: "Did not find the " + sViewName + " view"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Opa5 from "sap/ui/test/Opa5";
|
|
2
|
+
|
|
3
|
+
const sViewName = "<%= viewName %>";
|
|
4
|
+
|
|
5
|
+
export default class <%= viewNamePage %> extends Opa5 {
|
|
6
|
+
// Actions
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// Assertions
|
|
10
|
+
iShouldSeeThePageView() {
|
|
11
|
+
return this.waitFor({
|
|
12
|
+
id: "page",
|
|
13
|
+
viewName: sViewName,
|
|
14
|
+
success: function () {
|
|
15
|
+
Opa5.assert.ok(true, "The " + sViewName + " view is displayed");
|
|
16
|
+
},
|
|
17
|
+
errorMessage: "Did not find the " + sViewName + " view"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*global QUnit*/
|
|
2
|
+
|
|
3
|
+
sap.ui.define([
|
|
4
|
+
"<%= appIdWithSlash %>/controller/<%= viewName %>.controller"
|
|
5
|
+
], function (Controller) {
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
QUnit.module("<%= viewName %> Controller");
|
|
9
|
+
|
|
10
|
+
QUnit.test("I should test the <%= viewName %> controller", function (assert) {
|
|
11
|
+
var oAppController = new Controller();
|
|
12
|
+
oAppController.onInit();
|
|
13
|
+
assert.ok(oAppController);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*global QUnit*/
|
|
2
|
+
import Controller from "<%= appIdWithSlash %>/controller/<%= viewName %>.controller";
|
|
3
|
+
|
|
4
|
+
QUnit.module("<%= viewName %> Controller");
|
|
5
|
+
|
|
6
|
+
QUnit.test("I should test the <%= viewName %> controller", function (assert: Assert) {
|
|
7
|
+
const oAppController = new Controller("<%= viewName %>");
|
|
8
|
+
oAppController.onInit();
|
|
9
|
+
assert.ok(oAppController);
|
|
10
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Unit tests for <%= appId %></title>
|
|
6
|
+
<script
|
|
7
|
+
id="sap-ui-bootstrap"
|
|
8
|
+
src="../../resources/sap-ui-core.js"
|
|
9
|
+
data-sap-ui-resourceroots='{
|
|
10
|
+
"<%= appIdWithSlash %>": "../../",
|
|
11
|
+
"unit": "."
|
|
12
|
+
}'
|
|
13
|
+
data-sap-ui-async="true"
|
|
14
|
+
data-sap-ui-compat-version="edge">
|
|
15
|
+
</script>
|
|
16
|
+
<link rel="stylesheet" type="text/css" href="../../resources/sap/ui/thirdparty/qunit-2.css">
|
|
17
|
+
<script src="../../resources/sap/ui/thirdparty/qunit-2.js"></script>
|
|
18
|
+
<script src="../../resources/sap/ui/qunit/qunit-junit.js"></script>
|
|
19
|
+
<script src="../../resources/sap/ui/qunit/qunit-coverage.js"></script>
|
|
20
|
+
<script src="../../resources/sap/ui/thirdparty/sinon.js"></script>
|
|
21
|
+
<script src="../../resources/sap/ui/thirdparty/sinon-qunit.js"></script>
|
|
22
|
+
<script src="unitTests.qunit.js"></script>
|
|
23
|
+
</head>
|
|
24
|
+
<body>
|
|
25
|
+
<div id="qunit"></div>
|
|
26
|
+
<div id="qunit-fixture"></div>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|