@sap-ux/ui5-test-writer 0.7.89 → 0.7.91
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 +2 -1
- package/dist/fiori-elements-opa-writer.js +38 -9
- package/dist/types.d.ts +102 -1
- package/dist/utils/listReportUtils.d.ts +94 -0
- package/dist/utils/listReportUtils.js +389 -0
- package/dist/utils/modelUtils.d.ts +60 -9
- package/dist/utils/modelUtils.js +69 -41
- package/dist/utils/objectPageUtils.d.ts +21 -0
- package/dist/utils/objectPageUtils.js +218 -0
- package/package.json +7 -4
- package/templates/v4/integration/FPMJourney.js +49 -0
- package/templates/v4/integration/FirstJourney.js +1 -11
- package/templates/v4/integration/ListReportJourney.js +84 -0
- package/templates/v4/integration/ObjectPageJourney.js +69 -0
- package/templates/v4/integration/opaTests.qunit.js +3 -2
|
@@ -1,33 +1,84 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
2
|
import type { Logger } from '@sap-ux/logger';
|
|
3
|
+
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application';
|
|
3
4
|
import type { TreeAggregation, TreeAggregations, TreeModel, ApplicationModel } from '@sap/ux-specification/dist/types/src/parser';
|
|
4
|
-
import type {
|
|
5
|
+
import type { AppFeatures, FPMFeatures } from '../types';
|
|
5
6
|
export interface AggregationItem extends TreeAggregation {
|
|
6
7
|
description: string;
|
|
8
|
+
schema: {
|
|
9
|
+
keys: {
|
|
10
|
+
name: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface FieldItem extends AggregationItem {
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SectionItem extends AggregationItem {
|
|
19
|
+
title?: string;
|
|
20
|
+
custom?: boolean;
|
|
21
|
+
name?: string;
|
|
22
|
+
schema: {
|
|
23
|
+
keys: {
|
|
24
|
+
name: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}[];
|
|
27
|
+
dataType?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface HeaderSectionItem extends SectionItem {
|
|
31
|
+
properties: {
|
|
32
|
+
stashed: {
|
|
33
|
+
freeText: string | boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface PageWithModelV4WithProperties extends PageWithModelV4 {
|
|
38
|
+
routePattern?: string;
|
|
7
39
|
}
|
|
8
40
|
/**
|
|
9
|
-
* Gets
|
|
41
|
+
* Gets app features from the application model using ux-specification.
|
|
10
42
|
*
|
|
11
43
|
* @param basePath - the absolute target path where the application will be generated
|
|
12
44
|
* @param fs - optional mem-fs editor instance
|
|
13
45
|
* @param log - optional logger instance
|
|
46
|
+
* @param metadata - optional metadata for the OPA test generation
|
|
14
47
|
* @returns feature data extracted from the application model
|
|
15
48
|
*/
|
|
16
|
-
export declare function
|
|
49
|
+
export declare function getAppFeatures(basePath: string, fs?: Editor, log?: Logger, metadata?: string): Promise<AppFeatures>;
|
|
17
50
|
/**
|
|
18
|
-
* Retrieves
|
|
51
|
+
* Retrieves table column data from the page model using ux-specification.
|
|
52
|
+
*
|
|
53
|
+
* @param pageModel - the tree model containing table column definitions
|
|
54
|
+
* @param log - optional logger instance
|
|
55
|
+
* @returns - a map of table columns
|
|
56
|
+
*/
|
|
57
|
+
export declare function getTableColumnData(pageModel: TreeModel, log?: Logger): Record<string, Record<string, string | number | boolean>>;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves List Report definition from the given application model.
|
|
60
|
+
* Only a single List Report page is expected, so the first match is returned.
|
|
19
61
|
*
|
|
20
62
|
* @param applicationModel - The application model containing page definitions.
|
|
21
|
-
* @returns An
|
|
63
|
+
* @returns An object containing the key and page definition of the List Report, or null if not found.
|
|
22
64
|
*/
|
|
23
|
-
export declare function getListReportPage
|
|
65
|
+
export declare function getListReportPage(applicationModel: ApplicationModel): PageWithModelV4 | null;
|
|
24
66
|
/**
|
|
25
|
-
* Retrieves all
|
|
67
|
+
* Retrieves all FPM Custom Page definitions from the given application model.
|
|
26
68
|
*
|
|
27
69
|
* @param applicationModel - The application model containing page definitions.
|
|
28
|
-
* @
|
|
70
|
+
* @param log - optional logger instance
|
|
71
|
+
* @returns An array of FPM Custom Page definitions.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getFPMPage(applicationModel: ApplicationModel, log?: Logger): PageWithModelV4 | null;
|
|
74
|
+
/**
|
|
75
|
+
* Gets FPM features from the page model using ux-specification.
|
|
76
|
+
*
|
|
77
|
+
* @param page - the FPM Custom Page containing model definitions
|
|
78
|
+
* @param log - optional logger instance
|
|
79
|
+
* @returns feature data extracted from the FPM Custom Page model
|
|
29
80
|
*/
|
|
30
|
-
export declare function
|
|
81
|
+
export declare function getFPMFeatures(page: PageWithModelV4, log?: Logger): FPMFeatures;
|
|
31
82
|
/**
|
|
32
83
|
* Retrieves the aggregations from the given tree aggregations node.
|
|
33
84
|
*
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -1,45 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getAppFeatures = getAppFeatures;
|
|
4
|
+
exports.getTableColumnData = getTableColumnData;
|
|
4
5
|
exports.getListReportPage = getListReportPage;
|
|
5
|
-
exports.
|
|
6
|
+
exports.getFPMPage = getFPMPage;
|
|
7
|
+
exports.getFPMFeatures = getFPMFeatures;
|
|
6
8
|
exports.getAggregations = getAggregations;
|
|
7
9
|
exports.getSelectionFieldItems = getSelectionFieldItems;
|
|
8
10
|
exports.getFilterFields = getFilterFields;
|
|
9
11
|
exports.getTableColumns = getTableColumns;
|
|
10
12
|
const project_access_1 = require("@sap-ux/project-access");
|
|
13
|
+
const page_1 = require("@sap/ux-specification/dist/types/src/common/page");
|
|
14
|
+
const objectPageUtils_1 = require("./objectPageUtils");
|
|
15
|
+
const listReportUtils_1 = require("./listReportUtils");
|
|
11
16
|
/**
|
|
12
|
-
* Gets
|
|
17
|
+
* Gets app features from the application model using ux-specification.
|
|
13
18
|
*
|
|
14
19
|
* @param basePath - the absolute target path where the application will be generated
|
|
15
20
|
* @param fs - optional mem-fs editor instance
|
|
16
21
|
* @param log - optional logger instance
|
|
22
|
+
* @param metadata - optional metadata for the OPA test generation
|
|
17
23
|
* @returns feature data extracted from the application model
|
|
18
24
|
*/
|
|
19
|
-
async function
|
|
25
|
+
async function getAppFeatures(basePath, fs, log, metadata) {
|
|
20
26
|
const featureData = {};
|
|
21
27
|
let listReportPage = null;
|
|
28
|
+
let objectPages = null;
|
|
29
|
+
let fpmPage = null;
|
|
30
|
+
let projectMetadata = metadata;
|
|
22
31
|
// Read application model to extract control information needed for test generation
|
|
23
32
|
// specification and readApp might not be available due to specification version, fail gracefully
|
|
24
33
|
try {
|
|
25
34
|
// readApp calls createApplicationAccess internally if given a path, but it uses the "live" version of project-access without fs enhancement
|
|
26
35
|
const appAccess = await (0, project_access_1.createApplicationAccess)(basePath, { fs: fs });
|
|
27
36
|
const specification = await appAccess.getSpecification();
|
|
28
|
-
const
|
|
29
|
-
|
|
37
|
+
const appModel = await specification.readApp({ app: appAccess, fs: fs });
|
|
38
|
+
if (!projectMetadata) {
|
|
39
|
+
const metadataPath = appAccess.project?.apps['']?.services?.mainService?.local;
|
|
40
|
+
if (metadataPath) {
|
|
41
|
+
projectMetadata = fs?.read(metadataPath);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
listReportPage = appModel?.applicationModel ? getListReportPage(appModel.applicationModel) : listReportPage;
|
|
45
|
+
objectPages = appModel?.applicationModel ? (0, objectPageUtils_1.getObjectPages)(appModel.applicationModel) : objectPages;
|
|
46
|
+
fpmPage = appModel?.applicationModel ? getFPMPage(appModel.applicationModel, log) : fpmPage;
|
|
30
47
|
}
|
|
31
48
|
catch (error) {
|
|
32
49
|
log?.warn('Error analyzing project model using specification. No dynamic tests will be generated. Error: ' +
|
|
33
50
|
error.message);
|
|
34
51
|
return featureData;
|
|
35
52
|
}
|
|
36
|
-
if (!listReportPage) {
|
|
37
|
-
log?.warn('
|
|
53
|
+
if (!listReportPage && !objectPages && !fpmPage) {
|
|
54
|
+
log?.warn('Pages not found in application model. Dynamic tests will not be generated.');
|
|
38
55
|
return featureData;
|
|
39
56
|
}
|
|
40
57
|
// attempt to get individual feature data
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
try {
|
|
59
|
+
if (listReportPage) {
|
|
60
|
+
featureData.listReport = (0, listReportUtils_1.getListReportFeatures)(listReportPage, log, projectMetadata);
|
|
61
|
+
}
|
|
62
|
+
if (objectPages) {
|
|
63
|
+
log?.warn('Extracting Object Page features from application model');
|
|
64
|
+
featureData.objectPages = await (0, objectPageUtils_1.getObjectPageFeatures)(objectPages, listReportPage?.name, log);
|
|
65
|
+
log?.warn('objectPages features extracted: ' + JSON.stringify(featureData.objectPages));
|
|
66
|
+
}
|
|
67
|
+
if (fpmPage) {
|
|
68
|
+
featureData.fpm = getFPMFeatures(fpmPage, log);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// do noting here, as individual feature extraction methods already log warnings
|
|
73
|
+
}
|
|
43
74
|
return featureData;
|
|
44
75
|
}
|
|
45
76
|
/**
|
|
@@ -75,27 +106,6 @@ function transformTableColumns(columnAggregations) {
|
|
|
75
106
|
});
|
|
76
107
|
return columns;
|
|
77
108
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Retrieves filter field names from the page model using ux-specification.
|
|
80
|
-
*
|
|
81
|
-
* @param pageModel - the tree model containing filter bar definitions
|
|
82
|
-
* @param log - optional logger instance
|
|
83
|
-
* @returns - an array of filter field names
|
|
84
|
-
*/
|
|
85
|
-
function getFilterFieldNames(pageModel, log) {
|
|
86
|
-
let filterBarItems = [];
|
|
87
|
-
try {
|
|
88
|
-
const filterBarAggregations = getFilterFields(pageModel);
|
|
89
|
-
filterBarItems = getSelectionFieldItems(filterBarAggregations);
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
log?.debug(error);
|
|
93
|
-
}
|
|
94
|
-
if (!filterBarItems?.length) {
|
|
95
|
-
log?.warn('Unable to extract filter fields from project model using specification. No filter field tests will be generated.');
|
|
96
|
-
}
|
|
97
|
-
return filterBarItems;
|
|
98
|
-
}
|
|
99
109
|
/**
|
|
100
110
|
* Retrieves table column data from the page model using ux-specification.
|
|
101
111
|
*
|
|
@@ -118,35 +128,53 @@ function getTableColumnData(pageModel, log) {
|
|
|
118
128
|
return tableColumns;
|
|
119
129
|
}
|
|
120
130
|
/**
|
|
121
|
-
* Retrieves
|
|
131
|
+
* Retrieves List Report definition from the given application model.
|
|
132
|
+
* Only a single List Report page is expected, so the first match is returned.
|
|
122
133
|
*
|
|
123
134
|
* @param applicationModel - The application model containing page definitions.
|
|
124
|
-
* @returns An
|
|
135
|
+
* @returns An object containing the key and page definition of the List Report, or null if not found.
|
|
125
136
|
*/
|
|
126
137
|
function getListReportPage(applicationModel) {
|
|
127
138
|
for (const pageKey in applicationModel.pages) {
|
|
128
139
|
const page = applicationModel.pages[pageKey];
|
|
129
|
-
if (page.pageType ===
|
|
140
|
+
if (page.pageType === page_1.PageTypeV4.ListReport) {
|
|
141
|
+
page.name = pageKey; // store page key as name for later identification
|
|
130
142
|
return page;
|
|
131
143
|
}
|
|
132
144
|
}
|
|
133
145
|
return null;
|
|
134
146
|
}
|
|
135
147
|
/**
|
|
136
|
-
* Retrieves all
|
|
148
|
+
* Retrieves all FPM Custom Page definitions from the given application model.
|
|
137
149
|
*
|
|
138
150
|
* @param applicationModel - The application model containing page definitions.
|
|
139
|
-
* @
|
|
151
|
+
* @param log - optional logger instance
|
|
152
|
+
* @returns An array of FPM Custom Page definitions.
|
|
140
153
|
*/
|
|
141
|
-
function
|
|
142
|
-
const objectPages = [];
|
|
154
|
+
function getFPMPage(applicationModel, log) {
|
|
143
155
|
for (const pageKey in applicationModel.pages) {
|
|
144
156
|
const page = applicationModel.pages[pageKey];
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
log?.warn('pageType:' + page.pageType);
|
|
158
|
+
if (page.pageType === page_1.PageTypeV4.FPMCustomPage) {
|
|
159
|
+
page.name = pageKey; // store page key as name for later identification
|
|
160
|
+
return page;
|
|
147
161
|
}
|
|
148
162
|
}
|
|
149
|
-
return
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Gets FPM features from the page model using ux-specification.
|
|
167
|
+
*
|
|
168
|
+
* @param page - the FPM Custom Page containing model definitions
|
|
169
|
+
* @param log - optional logger instance
|
|
170
|
+
* @returns feature data extracted from the FPM Custom Page model
|
|
171
|
+
*/
|
|
172
|
+
function getFPMFeatures(page, log) {
|
|
173
|
+
return {
|
|
174
|
+
name: page.name,
|
|
175
|
+
filterBarItems: (0, listReportUtils_1.getFilterFieldNames)(page.model, log),
|
|
176
|
+
tableColumns: getTableColumnData(page.model, log)
|
|
177
|
+
};
|
|
150
178
|
}
|
|
151
179
|
/**
|
|
152
180
|
* Retrieves the aggregations from the given tree aggregations node.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Logger } from '@sap-ux/logger';
|
|
2
|
+
import type { ApplicationModel } from '@sap/ux-specification/dist/types/src/parser';
|
|
3
|
+
import type { ObjectPageFeatures } from '../types';
|
|
4
|
+
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application';
|
|
5
|
+
/**
|
|
6
|
+
* Extracts feature data for object pages from the application model.
|
|
7
|
+
*
|
|
8
|
+
* @param objectPages - the array of object pages extracted from the application model
|
|
9
|
+
* @param listReportPageKey - the key of the List Report page in the application model, used to find navigation routes to object pages
|
|
10
|
+
* @param log - optional logger instance
|
|
11
|
+
* @returns a record of object page feature data
|
|
12
|
+
*/
|
|
13
|
+
export declare function getObjectPageFeatures(objectPages: PageWithModelV4[], listReportPageKey?: string, log?: Logger): Promise<ObjectPageFeatures[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves all Object Page definitions from the given application model, as long as the page is reachable via standard navigation routes.
|
|
16
|
+
*
|
|
17
|
+
* @param applicationModel - The application model containing page definitions.
|
|
18
|
+
* @returns An array of Object Page definitions.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getObjectPages(applicationModel: ApplicationModel): PageWithModelV4[];
|
|
21
|
+
//# sourceMappingURL=objectPageUtils.d.ts.map
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getObjectPageFeatures = getObjectPageFeatures;
|
|
4
|
+
exports.getObjectPages = getObjectPages;
|
|
5
|
+
const modelUtils_1 = require("./modelUtils");
|
|
6
|
+
const page_1 = require("@sap/ux-specification/dist/types/src/common/page");
|
|
7
|
+
/**
|
|
8
|
+
* Extracts feature data for object pages from the application model.
|
|
9
|
+
*
|
|
10
|
+
* @param objectPages - the array of object pages extracted from the application model
|
|
11
|
+
* @param listReportPageKey - the key of the List Report page in the application model, used to find navigation routes to object pages
|
|
12
|
+
* @param log - optional logger instance
|
|
13
|
+
* @returns a record of object page feature data
|
|
14
|
+
*/
|
|
15
|
+
async function getObjectPageFeatures(objectPages, listReportPageKey, log) {
|
|
16
|
+
const objectPageFeatures = [];
|
|
17
|
+
if (!objectPages || objectPages.length === 0) {
|
|
18
|
+
log?.warn('Object Pages not found in application model. Dynamic tests will not be generated for Object Pages.');
|
|
19
|
+
return objectPageFeatures;
|
|
20
|
+
}
|
|
21
|
+
// attempt to get individual feature data for each object page
|
|
22
|
+
for (const objectPage of objectPages) {
|
|
23
|
+
const pageFeatureData = {};
|
|
24
|
+
pageFeatureData.name = objectPage.name;
|
|
25
|
+
pageFeatureData.navigationParents = getObjectPageNavigationParents(objectPage.name, objectPages, listReportPageKey);
|
|
26
|
+
// extract header sections (facets)
|
|
27
|
+
pageFeatureData.headerSections = extractObjectPageHeaderSectionsData(objectPage);
|
|
28
|
+
objectPageFeatures.push(pageFeatureData);
|
|
29
|
+
}
|
|
30
|
+
return objectPageFeatures;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves all Object Page definitions from the given application model, as long as the page is reachable via standard navigation routes.
|
|
34
|
+
*
|
|
35
|
+
* @param applicationModel - The application model containing page definitions.
|
|
36
|
+
* @returns An array of Object Page definitions.
|
|
37
|
+
*/
|
|
38
|
+
function getObjectPages(applicationModel) {
|
|
39
|
+
const objectPages = [];
|
|
40
|
+
for (const pageKey in applicationModel.pages) {
|
|
41
|
+
const page = applicationModel.pages[pageKey];
|
|
42
|
+
if (page.pageType === page_1.PageTypeV4.ObjectPage) {
|
|
43
|
+
page.name = pageKey; // store page key as name for later identification
|
|
44
|
+
objectPages.push(page);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return objectPages;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Finds parent pages for the object page, and returns their identifiers.
|
|
51
|
+
*
|
|
52
|
+
* @param targetObjectPageKey - key of the target object page
|
|
53
|
+
* @param objectPages - the array of object pages extracted from the application model
|
|
54
|
+
* @param listReportPageKey - the key of the List Report page in the application model, used to find navigation routes to object pages
|
|
55
|
+
* @returns navigation data including parent page identifiers
|
|
56
|
+
*/
|
|
57
|
+
function getObjectPageNavigationParents(targetObjectPageKey, objectPages, listReportPageKey) {
|
|
58
|
+
const navigationParents = {
|
|
59
|
+
parentLRName: listReportPageKey ?? '' // app is possibly malformed if no LR found
|
|
60
|
+
};
|
|
61
|
+
objectPages.forEach((objectPage) => {
|
|
62
|
+
const navigationRoutes = getNavigationRoutes(objectPage);
|
|
63
|
+
const routeToTargetOP = navigationRoutes.find((nav) => nav.route === targetObjectPageKey);
|
|
64
|
+
if (routeToTargetOP) {
|
|
65
|
+
navigationParents.parentOPName = objectPage.name;
|
|
66
|
+
navigationParents.parentOPTableSection = routeToTargetOP.identifier;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return navigationParents;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Extracts header sections data from an object page model.
|
|
73
|
+
*
|
|
74
|
+
* @param objectPage - object page from the application model
|
|
75
|
+
* @returns header sections data
|
|
76
|
+
*/
|
|
77
|
+
function extractObjectPageHeaderSectionsData(objectPage) {
|
|
78
|
+
const headerSections = [];
|
|
79
|
+
if (objectPage.model) {
|
|
80
|
+
const headerAggregation = (0, modelUtils_1.getAggregations)(objectPage.model.root)['header'];
|
|
81
|
+
const sectionsAggregation = (0, modelUtils_1.getAggregations)(headerAggregation)['sections'];
|
|
82
|
+
const sections = (0, modelUtils_1.getAggregations)(sectionsAggregation);
|
|
83
|
+
Object.values(sections).forEach((section) => {
|
|
84
|
+
const facetId = getSectionIdentifier(section);
|
|
85
|
+
if (!facetId) {
|
|
86
|
+
// if no identifier can be found for the section, it is not possible to reliably identify it in tests, so skip it
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const sectionData = {
|
|
90
|
+
facetId: facetId,
|
|
91
|
+
stashed: getSectionStashedFlag(section),
|
|
92
|
+
custom: section.custom,
|
|
93
|
+
microChart: isSectionMicroChart(section),
|
|
94
|
+
form: isFormSection(section),
|
|
95
|
+
// collection: false // TODO: find out how to identify collection facets
|
|
96
|
+
title: section.title
|
|
97
|
+
};
|
|
98
|
+
if (sectionData.form) {
|
|
99
|
+
sectionData.fields = getHeaderSectionFormFields(section);
|
|
100
|
+
}
|
|
101
|
+
headerSections.push(sectionData);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return headerSections;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gets the identifier of a section for OPA5 tests.
|
|
108
|
+
*
|
|
109
|
+
* @param section - section entry from ux specification
|
|
110
|
+
* @returns identifier of the section for OPA5 tests
|
|
111
|
+
*/
|
|
112
|
+
function getSectionIdentifier(section) {
|
|
113
|
+
return getSectionIdentifierFromKey(section) ?? getSectionIdentifierFromTitle(section);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Gets the identifier of a section from the 'ID' entry in the schema keys for OPA5 tests.
|
|
117
|
+
* If no such entry is found, undefined is returned.
|
|
118
|
+
*
|
|
119
|
+
* @param section - section entry from ux specification
|
|
120
|
+
* @returns identifier of the section for OPA5 tests; can be undefined if no 'ID' entry is found
|
|
121
|
+
*/
|
|
122
|
+
function getSectionIdentifierFromKey(section) {
|
|
123
|
+
const keyEntry = section?.schema?.keys?.find((key) => key.name === 'ID');
|
|
124
|
+
return keyEntry ? keyEntry.value.replace('#', '::') : undefined;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Gets the identifier of a section from its title for OPA5 tests.
|
|
128
|
+
*
|
|
129
|
+
* @param section - section entry from ux specification
|
|
130
|
+
* @returns identifier of the section for OPA5 tests; can be undefined if title is not in expected format
|
|
131
|
+
*/
|
|
132
|
+
function getSectionIdentifierFromTitle(section) {
|
|
133
|
+
return section.title?.slice(section.title?.lastIndexOf('.') + 1).replace('#', '::') ?? undefined;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Gets the stashed flag of a header section for OPA5 tests.
|
|
137
|
+
*
|
|
138
|
+
* @param headerSection - header section entry from ux specification
|
|
139
|
+
* @returns stashed flag of the header section for OPA5 tests; can be a boolean or a string depending on the specification version
|
|
140
|
+
*/
|
|
141
|
+
function getSectionStashedFlag(headerSection) {
|
|
142
|
+
return headerSection?.properties?.stashed?.freeText ?? false;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Gets form fields of a header section for OPA5 tests.
|
|
146
|
+
*
|
|
147
|
+
* @param section - section entry from ux specification
|
|
148
|
+
* @returns an array of form fields with their identifiers and bound properties for OPA5 tests
|
|
149
|
+
*/
|
|
150
|
+
function getHeaderSectionFormFields(section) {
|
|
151
|
+
const formFields = [];
|
|
152
|
+
const formAggregation = (0, modelUtils_1.getAggregations)(section)?.form;
|
|
153
|
+
const fieldsAggregation = (0, modelUtils_1.getAggregations)(formAggregation)?.fields;
|
|
154
|
+
const fields = (0, modelUtils_1.getAggregations)(fieldsAggregation);
|
|
155
|
+
if (fields) {
|
|
156
|
+
Object.keys(fields).forEach((fieldKey) => {
|
|
157
|
+
const field = fields[fieldKey];
|
|
158
|
+
if (field?.name) {
|
|
159
|
+
formFields.push({
|
|
160
|
+
fieldGroupQualifier: getFieldGroupQualifier(formAggregation),
|
|
161
|
+
field: field.schema.keys.find((key) => key.name === 'Value')?.value
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return formFields;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Gets the field group qualifier of a form aggregation for OPA5 tests.
|
|
170
|
+
*
|
|
171
|
+
* @param formAggregation - form aggregation entry from ux specification
|
|
172
|
+
* @returns field group qualifier for OPA5 tests; can be undefined if not found
|
|
173
|
+
*/
|
|
174
|
+
function getFieldGroupQualifier(formAggregation) {
|
|
175
|
+
const fullTarget = formAggregation?.schema?.keys?.find((key) => key.name === 'Target')?.value;
|
|
176
|
+
return fullTarget?.split('#')[1];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Checks if the section contains a microChart based on it's name.
|
|
180
|
+
*
|
|
181
|
+
* @param section - section entry from ux specification
|
|
182
|
+
* @returns true if the section seems to contain a microChart, false otherwise
|
|
183
|
+
*/
|
|
184
|
+
function isSectionMicroChart(section) {
|
|
185
|
+
return section?.schema?.dataType === 'ChartDefinition';
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Checks if the section contains a form based on it's aggregations.
|
|
189
|
+
*
|
|
190
|
+
* @param section - section entry from ux specification
|
|
191
|
+
* @returns true if the section seems to contain a form, false otherwise
|
|
192
|
+
*/
|
|
193
|
+
function isFormSection(section) {
|
|
194
|
+
return (0, modelUtils_1.getAggregations)(section)?.form !== undefined;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Retrieves navigation targets from the given page model.
|
|
198
|
+
*
|
|
199
|
+
* @param pageModel - The page model containing navigation definitions.
|
|
200
|
+
* @returns An array of navigation target identifiers.
|
|
201
|
+
*/
|
|
202
|
+
function getNavigationRoutes(pageModel) {
|
|
203
|
+
const navigationTargets = [];
|
|
204
|
+
if (!pageModel?.navigation) {
|
|
205
|
+
return navigationTargets;
|
|
206
|
+
}
|
|
207
|
+
Object.keys(pageModel.navigation).forEach((navigationKey) => {
|
|
208
|
+
if (pageModel.navigation) {
|
|
209
|
+
const navigationEntry = pageModel.navigation[navigationKey];
|
|
210
|
+
navigationTargets.push({
|
|
211
|
+
identifier: navigationKey,
|
|
212
|
+
route: typeof navigationEntry === 'string' ? navigationEntry : navigationEntry.route
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return navigationTargets;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=objectPageUtils.js.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.7.
|
|
4
|
+
"version": "0.7.91",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -25,9 +25,11 @@
|
|
|
25
25
|
"mem-fs": "2.1.0",
|
|
26
26
|
"mem-fs-editor": "9.4.0",
|
|
27
27
|
"@sap/ux-specification": "1.144.0",
|
|
28
|
-
"@sap-ux/
|
|
29
|
-
"@sap-ux/
|
|
30
|
-
"@sap-ux/
|
|
28
|
+
"@sap-ux/edmx-parser": "0.10.0",
|
|
29
|
+
"@sap-ux/annotation-converter": "0.10.21",
|
|
30
|
+
"@sap-ux/ui5-application-writer": "1.8.1",
|
|
31
|
+
"@sap-ux/project-access": "1.35.14",
|
|
32
|
+
"@sap-ux/logger": "0.8.2"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@types/ejs": "3.1.2",
|
|
@@ -36,6 +38,7 @@
|
|
|
36
38
|
"@types/mem-fs-editor": "7.0.1",
|
|
37
39
|
"rimraf": "6.1.3",
|
|
38
40
|
"fs-extra": "11.3.4",
|
|
41
|
+
"@sap-ux/vocabularies-types": "0.15.0",
|
|
39
42
|
"@sap-ux/jest-file-matchers": "0.2.11"
|
|
40
43
|
},
|
|
41
44
|
"engines": {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* ╔═══════════════════════════════════════════════════════════════════════╗ *
|
|
3
|
+
* ║ ║ *
|
|
4
|
+
* ║ WARNING: AUTO-GENERATED FILE ║ *
|
|
5
|
+
* ║ ║ *
|
|
6
|
+
* ║ This file is automatically generated by SAP Fiori tools and is ║ *
|
|
7
|
+
* ║ overwritten when you run the OPA test generator again. ║ *
|
|
8
|
+
* ║ ║ *
|
|
9
|
+
* ║ To add your own custom tests: ║ *
|
|
10
|
+
* ║ - Create a new journey test file in this directory. ║ *
|
|
11
|
+
* ║ - Follow the same pattern as this file. ║ *
|
|
12
|
+
* ║ - Add the new file to the opaTests.qunit.js config file. ║ *
|
|
13
|
+
* ║ - Custom journey files are not overwritten. ║ *
|
|
14
|
+
* ║ ║ *
|
|
15
|
+
* ╚═══════════════════════════════════════════════════════════════════════╝ *
|
|
16
|
+
******************************************************************************/
|
|
17
|
+
|
|
18
|
+
sap.ui.define([
|
|
19
|
+
"sap/ui/test/opaQunit",
|
|
20
|
+
"./pages/JourneyRunner"
|
|
21
|
+
], function (opaTest, runner) {
|
|
22
|
+
"use strict";
|
|
23
|
+
|
|
24
|
+
function journey() {
|
|
25
|
+
QUnit.module("FPM journey");
|
|
26
|
+
|
|
27
|
+
opaTest("Start application", function (Given, When, Then) {
|
|
28
|
+
Given.iStartMyApp();
|
|
29
|
+
<%_ startPages.forEach(function(pageName) { %>
|
|
30
|
+
Then.onThe<%- pageName %>.iSeeThisPage();
|
|
31
|
+
<%_ if (filterBarItems && filterBarItems.length > 0) { -%>
|
|
32
|
+
<%_ filterBarItems.forEach(function(item) { _%>
|
|
33
|
+
Then.onThe<%- pageName%>.onFilterBar().iCheckFilterField("<%- item %>");
|
|
34
|
+
<%_ }); -%>
|
|
35
|
+
<%_ } -%>
|
|
36
|
+
<%_ if (tableColumns && Object.keys(tableColumns).length > 0) { _%>
|
|
37
|
+
Then.onThe<%- pageName %>.onTable().iCheckColumns(<%- Object.keys(tableColumns).length %>, <%- JSON.stringify(tableColumns) %>);
|
|
38
|
+
<%_ } %>
|
|
39
|
+
<%_ }); -%>
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
opaTest("Teardown", function (Given, When, Then) {
|
|
43
|
+
// Cleanup
|
|
44
|
+
Given.iTearDownMyApp();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
runner.run([journey]);
|
|
49
|
+
});
|
|
@@ -9,17 +9,7 @@ sap.ui.define([
|
|
|
9
9
|
|
|
10
10
|
opaTest("Start application", function (Given, When, Then) {
|
|
11
11
|
Given.iStartMyApp();
|
|
12
|
-
<%
|
|
13
|
-
Then.onThe<%- pageName %>.iSeeThisPage();
|
|
14
|
-
<%_ if (filterBarItems && filterBarItems.length > 0 && !hideFilterBar) { -%>
|
|
15
|
-
<%_ filterBarItems.forEach(function(item) { _%>
|
|
16
|
-
Then.onThe<%- pageName%>.onFilterBar().iCheckFilterField("<%- item %>");
|
|
17
|
-
<%_ }); -%>
|
|
18
|
-
<%_ } -%>
|
|
19
|
-
<%_ if (tableColumns && Object.keys(tableColumns).length > 0) { _%>
|
|
20
|
-
Then.onThe<%- pageName %>.onTable().iCheckColumns(<%- Object.keys(tableColumns).length %>, <%- JSON.stringify(tableColumns) %>);
|
|
21
|
-
<%_ } %>
|
|
22
|
-
<%_ }); -%>
|
|
12
|
+
<% if (startLR) { %>Then.onThe<%- startLR %>.iSeeThisPage();<%} %>
|
|
23
13
|
});
|
|
24
14
|
|
|
25
15
|
<% if (startLR) { %>
|