@sap-ux/ui5-test-writer 1.4.0 → 1.4.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/utils/objectPageUtils.js +73 -17
- package/package.json +1 -1
- package/templates/v4/1.150/integration/ObjectPageJourney.js +9 -5
- package/templates/v4/1.150/integration/ObjectPageJourney.ts +9 -4
- package/templates/v4/1.84/integration/ObjectPageJourney.js +7 -4
- package/templates/v4/1.84/integration/ObjectPageJourney.ts +7 -4
|
@@ -263,23 +263,68 @@ function extractSectionActions(section, convertedMetadata, schemaNamespace) {
|
|
|
263
263
|
* @returns array of sub-section feature data
|
|
264
264
|
*/
|
|
265
265
|
function extractBodySubSectionsData(section, parentSectionId, convertedMetadata, entitySetName) {
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
266
|
+
const subSectionItems = getAggregations(getAggregations(section)['subsections']);
|
|
267
|
+
const childEntries = Object.entries(subSectionItems);
|
|
268
|
+
// all-FieldGroup CollectionFacet is collapsed into one sub-section with inherited id from parent
|
|
269
|
+
// Table or nested CollectionFacet sub-sections are kept as distinct sub-sections with their own ids
|
|
270
|
+
return isFormOnlyCollectionFacet(childEntries)
|
|
271
|
+
? [buildMergedFormSubSection(childEntries, parentSectionId, section.order, convertedMetadata, entitySetName)]
|
|
272
|
+
: childEntries.map(([key, child]) => buildSubSection(key, child, parentSectionId, convertedMetadata, entitySetName));
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Checks if a body section is a CollectionFacet that contains only form facets (FieldGroups) and no tables or custom facets.
|
|
276
|
+
*
|
|
277
|
+
* @param childEntries - the section's sub-section aggregation entries
|
|
278
|
+
* @returns true if every child is a plain form facet
|
|
279
|
+
*/
|
|
280
|
+
function isFormOnlyCollectionFacet(childEntries) {
|
|
281
|
+
return (childEntries.length > 0 &&
|
|
282
|
+
childEntries.every(([, child]) => !child.custom && !isTableSection(child) && isFormSection(child)));
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Merges the fields of all FieldGroups of a form-only CollectionFacet into one sub-section keyed by the
|
|
286
|
+
* section id.
|
|
287
|
+
*
|
|
288
|
+
* @param childEntries - the section's sub-section aggregation entries (all form facets)
|
|
289
|
+
* @param parentSectionId - identifier of the parent section, used as the sub-section id
|
|
290
|
+
* @param sectionOrder - order of the parent section, adopted by the collapsed sub-section
|
|
291
|
+
* @param convertedMetadata - optional converted OData metadata
|
|
292
|
+
* @param entitySetName - the entity set the section is bound to
|
|
293
|
+
* @returns the merged sub-section feature data
|
|
294
|
+
*/
|
|
295
|
+
function buildMergedFormSubSection(childEntries, parentSectionId, sectionOrder, convertedMetadata, entitySetName) {
|
|
296
|
+
const fields = dedupeFormFields(childEntries.flatMap(([, child]) => extractFormFields(child, convertedMetadata, entitySetName)));
|
|
297
|
+
return {
|
|
298
|
+
id: parentSectionId,
|
|
299
|
+
navigationProperty: undefined,
|
|
300
|
+
isTable: false,
|
|
301
|
+
custom: false,
|
|
302
|
+
order: sectionOrder ?? -1,
|
|
303
|
+
fields,
|
|
304
|
+
tableColumns: {}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Builds feature data for a single body sub-section (form or table).
|
|
309
|
+
*
|
|
310
|
+
* @param subSectionKey - the sub-section aggregation key
|
|
311
|
+
* @param subSection - the sub-section entry from the application model
|
|
312
|
+
* @param parentSectionId - identifier of the parent section (fallback key prefix)
|
|
313
|
+
* @param convertedMetadata - optional converted OData metadata
|
|
314
|
+
* @param entitySetName - the entity set the section is bound to
|
|
315
|
+
* @returns the sub-section feature data
|
|
316
|
+
*/
|
|
317
|
+
function buildSubSection(subSectionKey, subSection, parentSectionId, convertedMetadata, entitySetName) {
|
|
318
|
+
const isTable = isTableSection(subSection);
|
|
319
|
+
return {
|
|
320
|
+
id: getSectionIdentifier(subSection) ?? `${parentSectionId}_${subSectionKey}`,
|
|
321
|
+
navigationProperty: getNavigationPropertyFromKey(subSectionKey),
|
|
322
|
+
isTable,
|
|
323
|
+
custom: !!subSection.custom,
|
|
324
|
+
order: subSection?.order ?? -1, // put a negative order number to signal that order was not in spec
|
|
325
|
+
fields: subSection.custom || isTable ? [] : extractFormFields(subSection, convertedMetadata, entitySetName),
|
|
326
|
+
tableColumns: subSection.custom || !isTable ? {} : extractTableColumnsFromNode(subSection)
|
|
327
|
+
};
|
|
283
328
|
}
|
|
284
329
|
/**
|
|
285
330
|
* Extracts form field property paths from a body sub-section's form aggregation.
|
|
@@ -326,6 +371,17 @@ function extractFormFields(subSection, convertedMetadata, entitySetName) {
|
|
|
326
371
|
});
|
|
327
372
|
return fields;
|
|
328
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* Returns a new field list with duplicates removed, keeping the first occurrence of each identifier.
|
|
376
|
+
*
|
|
377
|
+
* @param fields - the fields to dedupe
|
|
378
|
+
* @returns a new deduped field list
|
|
379
|
+
*/
|
|
380
|
+
function dedupeFormFields(fields) {
|
|
381
|
+
return fields.filter((field, index) => fields.findIndex((candidate) => candidate.property === field.property &&
|
|
382
|
+
candidate.connectedFields === field.connectedFields &&
|
|
383
|
+
candidate.fieldGroup === field.fieldGroup) === index);
|
|
384
|
+
}
|
|
329
385
|
/**
|
|
330
386
|
* Resolves the inner `Value` paths of a `@UI.ConnectedFields#<qualifier>` annotation.
|
|
331
387
|
*
|
package/package.json
CHANGED
|
@@ -88,11 +88,15 @@ sap.ui.define([
|
|
|
88
88
|
});
|
|
89
89
|
<% } -%>
|
|
90
90
|
|
|
91
|
-
<% if (bodySections?.length >
|
|
92
|
-
|
|
93
|
-
opaTest("Check body sections of the Object Page", function (_Given, <% if (usesWhenInBody) { %>When<% } else { %>_When<% } %>, Then) {
|
|
91
|
+
<% if (bodySections?.length > 1) { -%>
|
|
92
|
+
opaTest("Check the number of sections of the Object Page", function (_Given, _When, Then) {
|
|
94
93
|
Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
<% } -%>
|
|
97
|
+
<% if (bodySections?.length > 0) { -%>
|
|
95
98
|
<% bodySections.forEach(function(section) { -%>
|
|
99
|
+
opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1 || (section.subSections && section.subSections.length > 0)) { %>When<% } else { %>_When<% } %>, Then) {
|
|
96
100
|
<% if (bodySections.length > 1) { -%>
|
|
97
101
|
When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>" });
|
|
98
102
|
<% } -%>
|
|
@@ -151,10 +155,10 @@ sap.ui.define([
|
|
|
151
155
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(section.tableColumns) %>);
|
|
152
156
|
<% } -%>
|
|
153
157
|
<% } -%>
|
|
158
|
+
});
|
|
159
|
+
|
|
154
160
|
<% }) -%>
|
|
155
|
-
});
|
|
156
161
|
<% } -%>
|
|
157
|
-
|
|
158
162
|
opaTest("Teardown", function (Given, When, Then) {
|
|
159
163
|
// Cleanup
|
|
160
164
|
Given.iTearDownMyApp();
|
|
@@ -110,10 +110,15 @@ function journey() {
|
|
|
110
110
|
});
|
|
111
111
|
<% } -%>
|
|
112
112
|
|
|
113
|
-
<% if (bodySections?.length >
|
|
114
|
-
opaTest("Check
|
|
113
|
+
<% if (bodySections?.length > 1) { -%>
|
|
114
|
+
opaTest("Check the number of sections of the Object Page", function (_Given: Given, _When: When, Then: Then) {
|
|
115
115
|
Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
<% } -%>
|
|
119
|
+
<% if (bodySections?.length > 0) { -%>
|
|
116
120
|
<% bodySections.forEach(function(section) { -%>
|
|
121
|
+
opaTest("Check the <%- section.id %> section of the Object Page", function (_Given: Given, <% if (usesWhenInBody) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
|
|
117
122
|
<% if (bodySections.length > 1) { -%>
|
|
118
123
|
When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>" });
|
|
119
124
|
<% } -%>
|
|
@@ -172,10 +177,10 @@ function journey() {
|
|
|
172
177
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(section.tableColumns) %>);
|
|
173
178
|
<% } -%>
|
|
174
179
|
<% } -%>
|
|
180
|
+
});
|
|
181
|
+
|
|
175
182
|
<% }) -%>
|
|
176
|
-
});
|
|
177
183
|
<% } -%>
|
|
178
|
-
|
|
179
184
|
opaTest("Teardown", function (Given: Given) {
|
|
180
185
|
// Cleanup
|
|
181
186
|
Given.iTearDownMyApp();
|
|
@@ -88,12 +88,15 @@ sap.ui.define([
|
|
|
88
88
|
});
|
|
89
89
|
<% } -%>
|
|
90
90
|
|
|
91
|
-
<% if (bodySections?.length > 0) { -%>
|
|
92
|
-
opaTest("Check body sections of the Object Page", function (Given, When, Then) {
|
|
93
91
|
<% if (bodySections?.length > 1) { -%>
|
|
92
|
+
opaTest("Check the number of sections of the Object Page", function (_Given, _When, Then) {
|
|
94
93
|
Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>);
|
|
94
|
+
});
|
|
95
|
+
|
|
95
96
|
<% } -%>
|
|
97
|
+
<% if (bodySections?.length > 0) { -%>
|
|
96
98
|
<% bodySections.forEach(function(section) { -%>
|
|
99
|
+
opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1) { %>When<% } else { %>_When<% } %>, Then) {
|
|
97
100
|
<% if (bodySections.length > 1) { -%>
|
|
98
101
|
When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
|
|
99
102
|
<% } -%>
|
|
@@ -152,10 +155,10 @@ sap.ui.define([
|
|
|
152
155
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(section.tableColumns) %>);
|
|
153
156
|
<% } -%>
|
|
154
157
|
<% } -%>
|
|
158
|
+
});
|
|
159
|
+
|
|
155
160
|
<% }) -%>
|
|
156
|
-
});
|
|
157
161
|
<% } -%>
|
|
158
|
-
|
|
159
162
|
opaTest("Teardown", function (Given, When, Then) {
|
|
160
163
|
// Cleanup
|
|
161
164
|
Given.iTearDownMyApp();
|
|
@@ -107,12 +107,15 @@ function journey() {
|
|
|
107
107
|
});
|
|
108
108
|
<% } -%>
|
|
109
109
|
|
|
110
|
-
<% if (bodySections?.length > 0) { -%>
|
|
111
|
-
opaTest("Check body sections of the Object Page", function (_Given: Given, <% if (bodySections?.length > 1) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
|
|
112
110
|
<% if (bodySections?.length > 1) { -%>
|
|
111
|
+
opaTest("Check the number of sections of the Object Page", function (_Given: Given, _When: When, Then: Then) {
|
|
113
112
|
Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>);
|
|
113
|
+
});
|
|
114
|
+
|
|
114
115
|
<% } -%>
|
|
116
|
+
<% if (bodySections?.length > 0) { -%>
|
|
115
117
|
<% bodySections.forEach(function(section) { -%>
|
|
118
|
+
opaTest("Check the <%- section.id %> section of the Object Page", function (_Given: Given, <% if (bodySections?.length > 1) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
|
|
116
119
|
<% if (bodySections.length > 1) { -%>
|
|
117
120
|
When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
|
|
118
121
|
<% } -%>
|
|
@@ -171,10 +174,10 @@ function journey() {
|
|
|
171
174
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(section.tableColumns) %>);
|
|
172
175
|
<% } -%>
|
|
173
176
|
<% } -%>
|
|
177
|
+
});
|
|
178
|
+
|
|
174
179
|
<% }) -%>
|
|
175
|
-
});
|
|
176
180
|
<% } -%>
|
|
177
|
-
|
|
178
181
|
opaTest("Teardown", function (Given: Given) {
|
|
179
182
|
// Cleanup
|
|
180
183
|
Given.iTearDownMyApp();
|