@sap-ux/ui5-test-writer 1.10.7 → 1.12.0

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.
@@ -2,9 +2,8 @@ import { getAggregations, parseDataFieldForAnnotationName } from './modelUtils.j
2
2
  import { passthroughLabelResolver } from './i18nUtils.js';
3
3
  import { extractContactCardColumnsFromNode, extractTableColumnsFromNode } from './tableUtils.js';
4
4
  import { PageTypeV4 } from '@sap/ux-specification/dist/types/src/common/page.js';
5
- import { parse } from '@sap-ux/edmx-parser';
6
- import { convert } from '@sap-ux/annotation-converter';
7
- import { buildActionStateFromSpecModelKey, safeCheckButtonVisibility, safeCheckEditVisibility } from './actionUtils.js';
5
+ import { buildActionStateFromSpecModelKey, buildMenuActionState, isMenuActionItem, collectCriticalActionNames, safeCheckButtonVisibility, safeCheckEditVisibility } from './actionUtils.js';
6
+ import { getMergedConvertedMetadata } from './metadataXmlUtils.js';
8
7
  import { getListReportViews } from './listReportUtils.js';
9
8
  /**
10
9
  * Extracts feature data for object pages from the application model.
@@ -13,20 +12,23 @@ import { getListReportViews } from './listReportUtils.js';
13
12
  * @param listReportPageKey - the key of the List Report page in the application model, used to find navigation routes to object pages
14
13
  * @param log - optional logger instance
15
14
  * @param metadata - optional metadata for the OPA test generation
16
- * @param manifest - optional application manifest, used to resolve the parent List Report's default table tab
17
- * @param listReportEntitySet - entity set of the parent List Report, used to resolve the originating view
18
- * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
15
+ * @param options - optional context (manifest, parent List Report entity set, label resolver, annotation XMLs)
19
16
  * @returns a record of object page feature data
20
17
  */
21
- export async function getObjectPageFeatures(objectPages, listReportPageKey, log, metadata, manifest, listReportEntitySet, resolveLabel = passthroughLabelResolver) {
18
+ export async function getObjectPageFeatures(objectPages, listReportPageKey, log, metadata, options = {}) {
19
+ const { manifest, listReportEntitySet, annotationXmls } = options;
20
+ const resolveLabel = options.resolveLabel ?? passthroughLabelResolver;
22
21
  const objectPageFeatures = [];
23
22
  if (!objectPages || objectPages.length === 0) {
24
23
  log?.warn('Object Pages not found in application model. Dynamic tests will not be generated for Object Pages.');
25
24
  return objectPageFeatures;
26
25
  }
27
26
  // attempt to get individual feature data for each object page
28
- const convertedMetadata = metadata ? convert(parse(metadata)) : undefined;
27
+ // Merge local annotation files so annotation-only terms (e.g. Common.IsActionCritical) surface;
28
+ // with no annotation files this is equivalent to convert(parse(metadata)).
29
+ const convertedMetadata = getMergedConvertedMetadata(metadata, annotationXmls);
29
30
  const schemaNamespace = convertedMetadata?.namespace ?? '';
31
+ const criticalActions = collectCriticalActionNames(convertedMetadata);
30
32
  // Non-custom tabs of the parent List Report with their optional entity set. Used to pick the
31
33
  // tab a given Object Page is reached from on multi-view LRs; empty for single-table LRs.
32
34
  const listReportViews = getListReportViews(manifest, listReportPageKey);
@@ -39,10 +41,10 @@ export async function getObjectPageFeatures(objectPages, listReportPageKey, log,
39
41
  // extract header sections (facets)
40
42
  pageFeatureData.headerSections = extractObjectPageHeaderSectionsData(objectPage);
41
43
  // extract body sections (includes section-level actions and standard create/delete buttons)
42
- pageFeatureData.bodySections = extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log, resolveLabel);
44
+ pageFeatureData.bodySections = extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log, resolveLabel, criticalActions);
43
45
  // extract header-level actions
44
46
  pageFeatureData.headerActions = convertedMetadata
45
- ? extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, resolveLabel)
47
+ ? extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, resolveLabel, criticalActions)
46
48
  : [];
47
49
  // determine edit button visibility from UpdateRestrictions on the OP entity set
48
50
  if (metadata && objectPage.entitySet) {
@@ -195,9 +197,10 @@ function extractObjectPageHeaderSectionsData(objectPage) {
195
197
  * @param metadata - optional raw metadata XML for resolving standard button visibility (Create/Delete)
196
198
  * @param log - optional logger instance
197
199
  * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
200
+ * @param criticalActions - set of action method names annotated Common.IsActionCritical
198
201
  * @returns body sections data including sub-sections
199
202
  */
200
- function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log, resolveLabel = passthroughLabelResolver) {
203
+ function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log, resolveLabel = passthroughLabelResolver, criticalActions) {
201
204
  const bodySections = [];
202
205
  if (objectPage.model) {
203
206
  const sectionsAggregation = getAggregations(objectPage.model.root)['sections'];
@@ -225,7 +228,7 @@ function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schema
225
228
  contactCardColumns,
226
229
  subSections,
227
230
  actions: !section.custom && convertedMetadata && schemaNamespace
228
- ? extractSectionActions(section, convertedMetadata, schemaNamespace, resolveLabel)
231
+ ? extractSectionActions(section, convertedMetadata, schemaNamespace, resolveLabel, criticalActions)
229
232
  : []
230
233
  };
231
234
  // For table sections, resolve Create/Delete visibility from target entity set
@@ -242,71 +245,6 @@ function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schema
242
245
  }
243
246
  return bodySections;
244
247
  }
245
- /**
246
- * Determines whether an action aggregation entry is a menu (drop-down) grouping several actions.
247
- *
248
- * @param item - action aggregation entry from the spec model
249
- * @returns true if the entry represents an annotation menu or a manifest (custom) menu
250
- */
251
- function isMenuActionItem(item) {
252
- return item.menuType !== undefined || item.schema?.dataType === 'DataFieldForActionGroup';
253
- }
254
- /**
255
- * Builds the individual menu item states contained in a menu action node.
256
- *
257
- * @param menuItem - the menu container aggregation entry
258
- * @param convertedMetadata - converted OData metadata for resolving annotation actions
259
- * @param schemaNamespace - OData schema namespace used as service identifier
260
- * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
261
- * @returns array of menu item states
262
- */
263
- function buildMenuItemStates(menuItem, convertedMetadata, schemaNamespace, resolveLabel) {
264
- const innerContainer = getAggregations(menuItem)['actions'];
265
- if (!innerContainer) {
266
- return [];
267
- }
268
- const innerEntries = getAggregations(innerContainer);
269
- return Object.entries(innerEntries).map(([childKey, child]) => {
270
- const annotationState = buildActionStateFromSpecModelKey(childKey, child.description, convertedMetadata, schemaNamespace);
271
- if (annotationState) {
272
- return {
273
- label: annotationState.label,
274
- visible: annotationState.visible,
275
- service: annotationState.service,
276
- action: annotationState.action,
277
- unbound: annotationState.unbound,
278
- enabled: annotationState.enabled,
279
- dynamicPath: annotationState.dynamicPath
280
- };
281
- }
282
- const { label, unresolved } = resolveLabel(child.description);
283
- return { label, visible: true, labelUnresolved: unresolved || undefined };
284
- });
285
- }
286
- /**
287
- * Builds a menu action button state from a menu aggregation entry (annotation or custom menu).
288
- *
289
- * @param menuItem - the menu container aggregation entry
290
- * @param convertedMetadata - converted OData metadata for resolving annotation actions
291
- * @param schemaNamespace - OData schema namespace used as service identifier
292
- * @param resolveLabel - resolver for i18n placeholder labels
293
- * @returns the menu action button state
294
- */
295
- function buildMenuActionState(menuItem, convertedMetadata, schemaNamespace, resolveLabel) {
296
- const menuType = menuItem.menuType === 'Annotation' || menuItem.schema?.dataType === 'DataFieldForActionGroup'
297
- ? 'Annotation'
298
- : 'CustomMenu';
299
- const { label, unresolved } = resolveLabel(menuItem.description);
300
- return {
301
- label,
302
- action: '',
303
- visible: true,
304
- enabled: true,
305
- menuType,
306
- labelUnresolved: unresolved || undefined,
307
- menuActions: buildMenuItemStates(menuItem, convertedMetadata, schemaNamespace, resolveLabel)
308
- };
309
- }
310
248
  /**
311
249
  * Builds an action button state for a custom (manifest-declared) action that has no OData
312
250
  * `DataFieldForAction` counterpart. These are matched at runtime by their rendered label.
@@ -337,13 +275,14 @@ function buildCustomActionState(item, resolveLabel) {
337
275
  * @param convertedMetadata - converted OData metadata
338
276
  * @param schemaNamespace - OData schema namespace used as service identifier
339
277
  * @param resolveLabel - resolver for i18n placeholder labels
278
+ * @param criticalActions - set of action method names annotated Common.IsActionCritical
340
279
  * @returns the action or menu button state, or undefined if the entry is neither
341
280
  */
342
- function buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel) {
281
+ function buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel, criticalActions) {
343
282
  if (isMenuActionItem(item)) {
344
283
  return buildMenuActionState(item, convertedMetadata, schemaNamespace, resolveLabel);
345
284
  }
346
- const odataState = buildActionStateFromSpecModelKey(key, item.description, convertedMetadata, schemaNamespace);
285
+ const odataState = buildActionStateFromSpecModelKey(key, item.description, convertedMetadata, schemaNamespace, criticalActions);
347
286
  if (odataState) {
348
287
  return odataState;
349
288
  }
@@ -360,9 +299,10 @@ function buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, r
360
299
  * @param convertedMetadata - converted OData metadata for resolving action availability
361
300
  * @param schemaNamespace - OData schema namespace used as service identifier in action assertions
362
301
  * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
302
+ * @param criticalActions - set of action method names annotated Common.IsActionCritical
363
303
  * @returns array of action button states for the header toolbar
364
304
  */
365
- function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, resolveLabel) {
305
+ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, resolveLabel, criticalActions) {
366
306
  if (!objectPage.model) {
367
307
  return [];
368
308
  }
@@ -370,7 +310,7 @@ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, re
370
310
  const actionsAgg = getAggregations(headerAgg)['actions'];
371
311
  const actionEntries = getAggregations(actionsAgg);
372
312
  return Object.entries(actionEntries)
373
- .map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel))
313
+ .map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel, criticalActions))
374
314
  .filter((actionState) => actionState !== undefined);
375
315
  }
376
316
  /**
@@ -381,9 +321,10 @@ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, re
381
321
  * @param convertedMetadata - converted OData metadata for resolving action availability
382
322
  * @param schemaNamespace - OData schema namespace used as service identifier in action assertions
383
323
  * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
324
+ * @param criticalActions - set of action method names annotated Common.IsActionCritical
384
325
  * @returns array of action button states for the section toolbar
385
326
  */
386
- function extractSectionActions(section, convertedMetadata, schemaNamespace, resolveLabel) {
327
+ function extractSectionActions(section, convertedMetadata, schemaNamespace, resolveLabel, criticalActions) {
387
328
  let actionsAgg;
388
329
  if (isTableSection(section)) {
389
330
  const tableAgg = getAggregations(section)['table'];
@@ -399,7 +340,7 @@ function extractSectionActions(section, convertedMetadata, schemaNamespace, reso
399
340
  }
400
341
  const actionEntries = getAggregations(actionsAgg);
401
342
  return Object.entries(actionEntries)
402
- .map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel))
343
+ .map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel, criticalActions))
403
344
  .filter((actionState) => actionState !== undefined);
404
345
  }
405
346
  /**
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": "1.10.7",
4
+ "version": "1.12.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -87,9 +87,26 @@ sap.ui.define([
87
87
  <%_ } _%>
88
88
  <%_ toolBarActions.forEach(function(item) { _%>
89
89
  <%_ if (item.visible) { _%>
90
+ <%_ if (item.menuActions) { _%>
91
+ <%_ if (item.splitButton) { _%>
92
+ // "<%- item.label %>" is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
93
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>");
94
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
95
+ <%_ } else { _%>
96
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>");
97
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
98
+ <%_ item.menuActions.forEach(function(menuAction) { _%>
99
+ <%_ if (menuAction.visible) { _%>
100
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckMenuAction("<%- menuAction.label %>");
101
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteMenuAction("<%- menuAction.label %>");
102
+ <%_ } _%>
103
+ <%_ }); _%>
104
+ <%_ } _%>
105
+ <%_ } else { _%>
90
106
  // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
91
107
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
92
108
  <%_ } _%>
109
+ <%_ } _%>
93
110
  <%_ }); -%>
94
111
  <%_ } -%>
95
112
  <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
@@ -20,6 +20,7 @@ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
20
  <%_
21
21
  const usesFilterFieldIdentifier =
22
22
  !hideFilterBar && filterBarItems && filterBarItems.some(function(item) { return item.custom; });
23
+ const toolBarHasMenu = (toolBarActions || []).some(function(item) { return item.visible && item.menuActions && !item.splitButton; });
23
24
  -%>
24
25
  <% if (usesFilterFieldIdentifier) { -%>
25
26
  import type { FilterFieldIdentifier } from "sap/fe/test/api/FilterBarAPI";
@@ -82,7 +83,7 @@ function journey() {
82
83
  // });
83
84
 
84
85
  <%_ if ((toolBarActions && toolBarActions.length > 0 ) || (tableColumns && Object.keys(tableColumns).length > 0)) { -%>
85
- opaTest("Check table columns and actions", function (_Given: Given, _When: When, Then: Then) {
86
+ opaTest("Check table columns and actions", function (_Given: Given, <% if (toolBarHasMenu) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
86
87
  <%_ if (toolBarActions && toolBarActions.length > 0) { -%>
87
88
  <%_ if (createButton.visible && !isALP) { _%>
88
89
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckCreate({ visible: true });
@@ -94,9 +95,26 @@ function journey() {
94
95
  <%_ } _%>
95
96
  <%_ toolBarActions.forEach(function(item) { _%>
96
97
  <%_ if (item.visible) { _%>
98
+ <%_ if (item.menuActions) { _%>
99
+ <%_ if (item.splitButton) { _%>
100
+ // "<%- item.label %>" is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
101
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>");
102
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
103
+ <%_ } else { _%>
104
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>");
105
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
106
+ <%_ item.menuActions.forEach(function(menuAction) { _%>
107
+ <%_ if (menuAction.visible) { _%>
108
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckMenuAction("<%- menuAction.label %>");
109
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteMenuAction("<%- menuAction.label %>");
110
+ <%_ } _%>
111
+ <%_ }); _%>
112
+ <%_ } _%>
113
+ <%_ } else { _%>
97
114
  // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
98
115
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
99
116
  <%_ } _%>
117
+ <%_ } _%>
100
118
  <%_ }); -%>
101
119
  <%_ } -%>
102
120
  <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
@@ -55,6 +55,11 @@ sap.ui.define([
55
55
  <% headerActions.forEach(function(action) { -%>
56
56
  <% if (action.visible) { -%>
57
57
  <% if (action.menuActions) { -%>
58
+ <% if (action.splitButton) { -%>
59
+ // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
60
+ Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>);
61
+ // When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
62
+ <% } else { -%>
58
63
  Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>);
59
64
  When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
60
65
  <% action.menuActions.forEach(function(menuAction) { -%>
@@ -63,6 +68,7 @@ sap.ui.define([
63
68
  // When.onThe<%- name%>Generated.onHeader().iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
64
69
  <% } -%>
65
70
  <% }); -%>
71
+ <% } -%>
66
72
  <% } else if (action.enabled === 'dynamic') { -%>
67
73
  Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
68
74
  // When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
@@ -114,6 +120,11 @@ sap.ui.define([
114
120
  <% if (action.visible) { -%>
115
121
  <% if (section.isTable && section.navigationProperty) { -%>
116
122
  <% if (action.menuActions) { -%>
123
+ <% if (action.splitButton) { -%>
124
+ // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
125
+ Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
126
+ // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
127
+ <% } else { -%>
117
128
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
118
129
  When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
119
130
  <% action.menuActions.forEach(function(menuAction) { -%>
@@ -122,6 +133,7 @@ sap.ui.define([
122
133
  // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
123
134
  <% } -%>
124
135
  <% }); -%>
136
+ <% } -%>
125
137
  <% } else if (action.enabled === 'dynamic') { -%>
126
138
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
127
139
  // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
@@ -131,6 +143,11 @@ sap.ui.define([
131
143
  <% } -%>
132
144
  <% } else { -%>
133
145
  <% if (action.menuActions) { -%>
146
+ <% if (action.splitButton) { -%>
147
+ // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
148
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
149
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
150
+ <% } else { -%>
134
151
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
135
152
  When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
136
153
  <% action.menuActions.forEach(function(menuAction) { -%>
@@ -139,6 +156,7 @@ sap.ui.define([
139
156
  // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
140
157
  <% } -%>
141
158
  <% }); -%>
159
+ <% } -%>
142
160
  <% } else if (action.enabled === 'dynamic') { -%>
143
161
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
144
162
  // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
@@ -31,7 +31,7 @@ const usesFormIdentifier = (bodySections || []).some(function(section) {
31
31
  });
32
32
  return subSectionsHaveForm || sectionHasFormFields || hasFormAction;
33
33
  });
34
- const headerHasMenu = (headerActions || []).some(function(action) { return action.visible && action.menuActions; });
34
+ const headerHasMenu = (headerActions || []).some(function(action) { return action.visible && action.menuActions && !action.splitButton; });
35
35
  -%>
36
36
  <% if (usesFieldIdentifier) { -%>
37
37
  import type { FieldIdentifier } from "sap/fe/test/api/BaseAPI";
@@ -75,6 +75,11 @@ function journey() {
75
75
  <% headerActions.forEach(function(action) { -%>
76
76
  <% if (action.visible) { -%>
77
77
  <% if (action.menuActions) { -%>
78
+ <% if (action.splitButton) { -%>
79
+ // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
80
+ Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>);
81
+ // When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
82
+ <% } else { -%>
78
83
  Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>);
79
84
  When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
80
85
  <% action.menuActions.forEach(function(menuAction) { -%>
@@ -83,6 +88,7 @@ function journey() {
83
88
  // When.onThe<%- name%>Generated.onHeader().iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
84
89
  <% } -%>
85
90
  <% }); -%>
91
+ <% } -%>
86
92
  <% } else if (action.enabled === 'dynamic') { -%>
87
93
  Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
88
94
  // When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
@@ -124,7 +130,7 @@ function journey() {
124
130
  <% } -%>
125
131
  <% if (bodySections?.length > 0) { -%>
126
132
  <% bodySections.forEach(function(section) { -%>
127
- opaTest("Check the <%- section.id %> section of the Object Page", function (_Given: Given, <% if (bodySections.length > 1 || (section.actions && section.actions.some(function(a) { return a.visible && a.menuActions; }))) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
133
+ opaTest("Check the <%- section.id %> section of the Object Page", function (_Given: Given, <% if (bodySections.length > 1 || (section.actions && section.actions.some(function(a) { return a.visible && a.menuActions && !a.splitButton; }))) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
128
134
  <% if (bodySections.length > 1) { -%>
129
135
  When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
130
136
  <% } -%>
@@ -134,6 +140,11 @@ function journey() {
134
140
  <% if (action.visible) { -%>
135
141
  <% if (section.isTable && section.navigationProperty) { -%>
136
142
  <% if (action.menuActions) { -%>
143
+ <% if (action.splitButton) { -%>
144
+ // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
145
+ Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
146
+ // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
147
+ <% } else { -%>
137
148
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
138
149
  When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
139
150
  <% action.menuActions.forEach(function(menuAction) { -%>
@@ -142,6 +153,7 @@ function journey() {
142
153
  // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
143
154
  <% } -%>
144
155
  <% }); -%>
156
+ <% } -%>
145
157
  <% } else if (action.enabled === 'dynamic') { -%>
146
158
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
147
159
  // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
@@ -151,6 +163,11 @@ function journey() {
151
163
  <% } -%>
152
164
  <% } else { -%>
153
165
  <% if (action.menuActions) { -%>
166
+ <% if (action.splitButton) { -%>
167
+ // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
168
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>);
169
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>);
170
+ <% } else { -%>
154
171
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>);
155
172
  When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>);
156
173
  <% action.menuActions.forEach(function(menuAction) { -%>
@@ -159,6 +176,7 @@ function journey() {
159
176
  // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
160
177
  <% } -%>
161
178
  <% }); -%>
179
+ <% } -%>
162
180
  <% } else if (action.enabled === 'dynamic') { -%>
163
181
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
164
182
  // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
@@ -87,15 +87,50 @@ sap.ui.define([
87
87
  <%_ } _%>
88
88
  <%_ toolBarActions.forEach(function(item) { _%>
89
89
  <%_ if (item.visible) { _%>
90
- <%_ if (item.custom) { _%>
90
+ <%_ if (item.menuActions) { _%>
91
+ <%_ if (item.splitButton) { _%>
92
+ // "<%- item.label %>" is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
93
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>");
94
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
95
+ <%_ } else { _%>
96
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>");
97
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
98
+ <%_ item.menuActions.forEach(function(menuAction) { _%>
99
+ <%_ if (menuAction.visible) { _%>
100
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckMenuAction("<%- menuAction.label %>");
101
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteMenuAction("<%- menuAction.label %>");
102
+ <%_ } _%>
103
+ <%_ }); _%>
104
+ <%_ } _%>
105
+ <%_ } else if (item.custom) { _%>
91
106
  <%_ if (item.labelUnresolved) { _%>
92
107
  // TODO: label is an unresolved i18n key; replace with the rendered action text
93
108
  <%_ } _%>
94
- // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
109
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
95
110
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { visible: true });
96
111
  <%_ } else { _%>
97
112
  // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
98
113
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
114
+ <%_ if (item.isCritical && item.enabled === 'dynamic') { _%>
115
+ // "<%- item.label %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the selected row. Uncomment and select a row that enables it to test the confirmation dialog.
116
+ <%_ if (!hideFilterBar) { _%>
117
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
118
+ <%_ } _%>
119
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
120
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
121
+ // Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
122
+ // When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
123
+ <%_ } else if (item.isCritical) { _%>
124
+ <%_ if (!hideFilterBar) { _%>
125
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
126
+ <%_ } _%>
127
+ <%_ if (item.enabled !== true) { _%>
128
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
129
+ <%_ } _%>
130
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
131
+ Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
132
+ When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
133
+ <%_ } _%>
99
134
  <%_ } _%>
100
135
  <%_ } _%>
101
136
  <%_ }); -%>
@@ -20,6 +20,7 @@ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
20
  <%_
21
21
  const usesFilterFieldIdentifier =
22
22
  !hideFilterBar && filterBarItems && filterBarItems.some(function(item) { return item.custom; });
23
+ const toolBarHasMenu = (toolBarActions || []).some(function(item) { return item.visible && item.menuActions && !item.splitButton; });
23
24
  -%>
24
25
  <% if (usesFilterFieldIdentifier) { -%>
25
26
  import type { FilterFieldIdentifier } from "sap/fe/test/api/FilterBarAPI";
@@ -82,7 +83,7 @@ function journey() {
82
83
  // });
83
84
 
84
85
  <%_ if ((toolBarActions && toolBarActions.length > 0 ) || (tableColumns && Object.keys(tableColumns).length > 0)) { -%>
85
- opaTest("Check table columns and actions", function (_Given: Given, _When: When, Then: Then) {
86
+ opaTest("Check table columns and actions", function (_Given: Given, <% if (toolBarHasMenu || (toolBarActions && toolBarActions.some(function(item) { return item.visible && item.isCritical && item.enabled !== 'dynamic'; }))) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
86
87
  <%_ if (toolBarActions && toolBarActions.length > 0) { -%>
87
88
  <%_ if (createButton.visible && !isALP) { _%>
88
89
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckCreate({ visible: true });
@@ -94,15 +95,50 @@ function journey() {
94
95
  <%_ } _%>
95
96
  <%_ toolBarActions.forEach(function(item) { _%>
96
97
  <%_ if (item.visible) { _%>
97
- <%_ if (item.custom) { _%>
98
+ <%_ if (item.menuActions) { _%>
99
+ <%_ if (item.splitButton) { _%>
100
+ // "<%- item.label %>" is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
101
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>");
102
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
103
+ <%_ } else { _%>
104
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>");
105
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
106
+ <%_ item.menuActions.forEach(function(menuAction) { _%>
107
+ <%_ if (menuAction.visible) { _%>
108
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckMenuAction("<%- menuAction.label %>");
109
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteMenuAction("<%- menuAction.label %>");
110
+ <%_ } _%>
111
+ <%_ }); _%>
112
+ <%_ } _%>
113
+ <%_ } else if (item.custom) { _%>
98
114
  <%_ if (item.labelUnresolved) { _%>
99
115
  // TODO: label is an unresolved i18n key; replace with the rendered action text
100
116
  <%_ } _%>
101
- // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
117
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
102
118
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { visible: true });
103
119
  <%_ } else { _%>
104
120
  // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
105
121
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
122
+ <%_ if (item.isCritical && item.enabled === 'dynamic') { _%>
123
+ // "<%- item.label %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the selected row. Uncomment and select a row that enables it to test the confirmation dialog.
124
+ <%_ if (!hideFilterBar) { _%>
125
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
126
+ <%_ } _%>
127
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
128
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
129
+ // Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
130
+ // When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
131
+ <%_ } else if (item.isCritical) { _%>
132
+ <%_ if (!hideFilterBar) { _%>
133
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
134
+ <%_ } _%>
135
+ <%_ if (item.enabled !== true) { _%>
136
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
137
+ <%_ } _%>
138
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
139
+ Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
140
+ When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
141
+ <%_ } _%>
106
142
  <%_ } _%>
107
143
  <%_ } _%>
108
144
  <%_ }); -%>