@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.
package/dist/types.d.ts CHANGED
@@ -248,6 +248,11 @@ export interface ActionButtonState {
248
248
  * Populated for both List Report and Object Page actions extracted via metadata.
249
249
  */
250
250
  unbound?: boolean;
251
+ /**
252
+ * Whether the action is annotated with `Common.IsActionCritical`. Critical actions trigger a
253
+ * confirmation dialog at runtime, which the generated test asserts and then cancels.
254
+ */
255
+ isCritical?: boolean;
251
256
  /**
252
257
  * Set when this entry is a menu (drop-down) button rather than a single action.
253
258
  * `menuActions` then holds the individual actions inside the menu.
@@ -259,6 +264,12 @@ export interface ActionButtonState {
259
264
  * `iExecuteMenuAction` match menu entries by their rendered text, not by a stable id).
260
265
  */
261
266
  menuActions?: MenuActionState[];
267
+ /**
268
+ * Set when a menu (drop-down) button declares a `defaultAction`, so Fiori Elements renders it as a
269
+ * split button. Its dropdown can only be opened via the arrow, which the `sap.fe.test` API cannot
270
+ * press — so the generated test asserts the button but omits the (unreachable) menu drill-down.
271
+ */
272
+ splitButton?: boolean;
262
273
  /**
263
274
  * Set for custom (manifest-declared) actions that have no OData `DataFieldForAction` counterpart.
264
275
  * These are matched at runtime by their rendered label, so the writer emits the label-string form
@@ -1,9 +1,19 @@
1
1
  import type { ConvertedMetadata } from '@sap-ux/vocabularies-types';
2
- import type { ActionButtonState, ButtonState, ButtonVisibilityResult } from '../types.js';
2
+ import type { ActionButtonState, ButtonState, ButtonVisibilityResult, MenuActionState } from '../types.js';
3
+ import { type AggregationItem } from './modelUtils.js';
4
+ import type { I18nLabelResolver } from './i18nUtils.js';
3
5
  import type { DataFieldForAction } from '@sap-ux/vocabularies-types/vocabularies/UI.js';
4
6
  import type { OperationAvailable } from '@sap-ux/vocabularies-types/vocabularies/Core.js';
5
7
  import type { DeleteRestrictionsType, InsertRestrictionsType, UpdateRestrictionsType } from '@sap-ux/vocabularies-types/vocabularies/Capabilities.js';
6
8
  import type { Logger } from '@sap-ux/logger';
9
+ /**
10
+ * Collects the names of actions annotated with `Common.IsActionCritical` from converted metadata.
11
+ * The metadata must already include the annotation files (merged) for annotation-only terms to surface.
12
+ *
13
+ * @param metadata The converted (ideally annotation-merged) OData metadata
14
+ * @returns The set of critical action method names (empty if none)
15
+ */
16
+ export declare function collectCriticalActionNames(metadata?: ConvertedMetadata): Set<string>;
7
17
  type OperationAvailableWithPaths = OperationAvailable & {
8
18
  $Path?: string;
9
19
  path?: string;
@@ -52,9 +62,10 @@ export declare function extractEnumMemberValue(enumValue: unknown): string | und
52
62
  *
53
63
  * @param item The DataFieldForAction annotation item
54
64
  * @param metadata The converted metadata
65
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
55
66
  * @returns ActionButtonState for the action
56
67
  */
57
- export declare function buildActionButtonState(item: DataFieldForAction, metadata: ConvertedMetadata): ActionButtonState;
68
+ export declare function buildActionButtonState(item: DataFieldForAction, metadata: ConvertedMetadata, criticalActions?: Set<string>): ActionButtonState;
58
69
  /**
59
70
  * Builds an ActionButtonState from a spec model aggregation key.
60
71
  *
@@ -65,9 +76,10 @@ export declare function buildActionButtonState(item: DataFieldForAction, metadat
65
76
  * @param label Display label from the spec model item description
66
77
  * @param convertedMetadata The converted OData metadata
67
78
  * @param schemaNamespace The OData schema namespace (used as service identifier)
79
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
68
80
  * @returns ActionButtonState or undefined if the key is not a DataFieldForAction key
69
81
  */
70
- export declare function buildActionStateFromSpecModelKey(aggregationKey: string, label: string | undefined, convertedMetadata: ConvertedMetadata, schemaNamespace: string): ActionButtonState | undefined;
82
+ export declare function buildActionStateFromSpecModelKey(aggregationKey: string, label: string | undefined, convertedMetadata: ConvertedMetadata, schemaNamespace: string, criticalActions?: Set<string>): ActionButtonState | undefined;
71
83
  /**
72
84
  * Analyzes a restriction value (Insertable, Deletable, or Updatable) to determine button state.
73
85
  *
@@ -153,5 +165,33 @@ export declare function safeCheckButtonVisibility(metadata: string, entitySetNam
153
165
  * @returns ButtonState for the edit button, or undefined if error occurs
154
166
  */
155
167
  export declare function safeCheckEditVisibility(metadata: string, entitySetName: string, log?: Logger): ButtonState | undefined;
168
+ /**
169
+ * Determines whether an action aggregation entry is a menu (drop-down) grouping several actions.
170
+ *
171
+ * @param item - action aggregation entry from the spec model
172
+ * @returns true if the entry represents an annotation menu or a manifest (custom) menu
173
+ */
174
+ export declare function isMenuActionItem(item: AggregationItem): boolean;
175
+ /**
176
+ * Builds the individual menu item states contained in a menu action node. Child actions are read
177
+ * from the nested `actions` aggregation of the menu node (`menuItem.aggregations.actions`).
178
+ *
179
+ * @param menuItem - the menu container aggregation entry
180
+ * @param convertedMetadata - converted OData metadata for resolving annotation-backed children; when omitted children are matched by label only
181
+ * @param schemaNamespace - OData schema namespace used as service identifier
182
+ * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
183
+ * @returns array of menu item states
184
+ */
185
+ export declare function buildMenuItemStates(menuItem: AggregationItem, convertedMetadata: ConvertedMetadata | undefined, schemaNamespace: string, resolveLabel: I18nLabelResolver): MenuActionState[];
186
+ /**
187
+ * Builds a menu action button state from a menu aggregation entry (annotation or custom menu).
188
+ *
189
+ * @param menuItem - the menu container aggregation entry
190
+ * @param convertedMetadata - converted OData metadata for resolving annotation-backed children; when omitted children are matched by label only
191
+ * @param schemaNamespace - OData schema namespace used as service identifier
192
+ * @param resolveLabel - resolver for i18n placeholder labels
193
+ * @returns the menu action button state
194
+ */
195
+ export declare function buildMenuActionState(menuItem: AggregationItem, convertedMetadata: ConvertedMetadata | undefined, schemaNamespace: string, resolveLabel: I18nLabelResolver): ActionButtonState;
156
196
  export {};
157
197
  //# sourceMappingURL=actionUtils.d.ts.map
@@ -1,6 +1,27 @@
1
+ import { getAggregations } from './modelUtils.js';
1
2
  import { parse } from '@sap-ux/edmx-parser';
2
3
  import { convert } from '@sap-ux/annotation-converter';
3
4
  const DATA_FIELD_FOR_ACTION = 'DataFieldForAction';
5
+ /**
6
+ * Collects the names of actions annotated with `Common.IsActionCritical` from converted metadata.
7
+ * The metadata must already include the annotation files (merged) for annotation-only terms to surface.
8
+ *
9
+ * @param metadata The converted (ideally annotation-merged) OData metadata
10
+ * @returns The set of critical action method names (empty if none)
11
+ */
12
+ export function collectCriticalActionNames(metadata) {
13
+ const names = new Set();
14
+ for (const action of metadata?.actions ?? []) {
15
+ if (action.name) {
16
+ // ponytail: IsActionCritical is present at runtime but missing from the vocabularies-types typings.
17
+ const common = action.annotations?.Common;
18
+ if (common?.IsActionCritical?.valueOf() === true) {
19
+ names.add(action.name);
20
+ }
21
+ }
22
+ }
23
+ return names;
24
+ }
4
25
  /**
5
26
  * Extracts the action method name from a fully qualified action string.
6
27
  *
@@ -93,9 +114,10 @@ export function extractEnumMemberValue(enumValue) {
93
114
  *
94
115
  * @param item The DataFieldForAction annotation item
95
116
  * @param metadata The converted metadata
117
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
96
118
  * @returns ActionButtonState for the action
97
119
  */
98
- export function buildActionButtonState(item, metadata) {
120
+ export function buildActionButtonState(item, metadata, criticalActions) {
99
121
  const actionString = item.Action || '';
100
122
  const actionMethod = extractActionMethodName(actionString);
101
123
  const operationAvailable = findOperationAvailableAnnotation(metadata, actionMethod);
@@ -115,7 +137,8 @@ export function buildActionButtonState(item, metadata) {
115
137
  visible: true,
116
138
  enabled,
117
139
  dynamicPath,
118
- invocationGrouping: item.InvocationGrouping ? extractEnumMemberValue(item.InvocationGrouping) : undefined
140
+ invocationGrouping: item.InvocationGrouping ? extractEnumMemberValue(item.InvocationGrouping) : undefined,
141
+ isCritical: criticalActions?.has(actionMethod) ?? false
119
142
  };
120
143
  }
121
144
  /**
@@ -128,9 +151,10 @@ export function buildActionButtonState(item, metadata) {
128
151
  * @param label Display label from the spec model item description
129
152
  * @param convertedMetadata The converted OData metadata
130
153
  * @param schemaNamespace The OData schema namespace (used as service identifier)
154
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
131
155
  * @returns ActionButtonState or undefined if the key is not a DataFieldForAction key
132
156
  */
133
- export function buildActionStateFromSpecModelKey(aggregationKey, label, convertedMetadata, schemaNamespace) {
157
+ export function buildActionStateFromSpecModelKey(aggregationKey, label, convertedMetadata, schemaNamespace, criticalActions) {
134
158
  const keyParts = aggregationKey.split('::');
135
159
  if (keyParts[0] !== DATA_FIELD_FOR_ACTION || !keyParts[1]) {
136
160
  return undefined;
@@ -151,7 +175,8 @@ export function buildActionStateFromSpecModelKey(aggregationKey, label, converte
151
175
  unbound: !isBound,
152
176
  visible: true,
153
177
  enabled,
154
- dynamicPath
178
+ dynamicPath,
179
+ isCritical: criticalActions?.has(actionMethod) ?? false
155
180
  };
156
181
  }
157
182
  /**
@@ -320,4 +345,76 @@ export function safeCheckEditVisibility(metadata, entitySetName, log) {
320
345
  return undefined;
321
346
  }
322
347
  }
348
+ /**
349
+ * Determines whether an action aggregation entry is a menu (drop-down) grouping several actions.
350
+ *
351
+ * @param item - action aggregation entry from the spec model
352
+ * @returns true if the entry represents an annotation menu or a manifest (custom) menu
353
+ */
354
+ export function isMenuActionItem(item) {
355
+ return item.menuType !== undefined || item.schema?.dataType === 'DataFieldForActionGroup';
356
+ }
357
+ /**
358
+ * Builds the individual menu item states contained in a menu action node. Child actions are read
359
+ * from the nested `actions` aggregation of the menu node (`menuItem.aggregations.actions`).
360
+ *
361
+ * @param menuItem - the menu container aggregation entry
362
+ * @param convertedMetadata - converted OData metadata for resolving annotation-backed children; when omitted children are matched by label only
363
+ * @param schemaNamespace - OData schema namespace used as service identifier
364
+ * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
365
+ * @returns array of menu item states
366
+ */
367
+ export function buildMenuItemStates(menuItem, convertedMetadata, schemaNamespace, resolveLabel) {
368
+ const innerContainer = getAggregations(menuItem)['actions'];
369
+ if (!innerContainer) {
370
+ return [];
371
+ }
372
+ const innerEntries = getAggregations(innerContainer);
373
+ return Object.entries(innerEntries).map(([childKey, child]) => {
374
+ const annotationState = convertedMetadata
375
+ ? buildActionStateFromSpecModelKey(childKey, child.description, convertedMetadata, schemaNamespace)
376
+ : undefined;
377
+ if (annotationState) {
378
+ return {
379
+ label: annotationState.label,
380
+ visible: annotationState.visible,
381
+ service: annotationState.service,
382
+ action: annotationState.action,
383
+ unbound: annotationState.unbound,
384
+ enabled: annotationState.enabled,
385
+ dynamicPath: annotationState.dynamicPath
386
+ };
387
+ }
388
+ const { label, unresolved } = resolveLabel(child.description);
389
+ return { label, visible: true, labelUnresolved: unresolved || undefined };
390
+ });
391
+ }
392
+ /**
393
+ * Builds a menu action button state from a menu aggregation entry (annotation or custom menu).
394
+ *
395
+ * @param menuItem - the menu container aggregation entry
396
+ * @param convertedMetadata - converted OData metadata for resolving annotation-backed children; when omitted children are matched by label only
397
+ * @param schemaNamespace - OData schema namespace used as service identifier
398
+ * @param resolveLabel - resolver for i18n placeholder labels
399
+ * @returns the menu action button state
400
+ */
401
+ export function buildMenuActionState(menuItem, convertedMetadata, schemaNamespace, resolveLabel) {
402
+ const menuType = menuItem.menuType === 'Annotation' || menuItem.schema?.dataType === 'DataFieldForActionGroup'
403
+ ? 'Annotation'
404
+ : 'CustomMenu';
405
+ // A `defaultAction` makes FE render a split button whose menu cannot be opened via the OPA API.
406
+ const defaultAction = menuItem
407
+ .properties?.defaultAction?.value;
408
+ const { label, unresolved } = resolveLabel(menuItem.description);
409
+ return {
410
+ label,
411
+ action: '',
412
+ visible: true,
413
+ enabled: true,
414
+ menuType,
415
+ splitButton: defaultAction ? true : undefined,
416
+ labelUnresolved: unresolved || undefined,
417
+ menuActions: buildMenuItemStates(menuItem, convertedMetadata, schemaNamespace, resolveLabel)
418
+ };
419
+ }
323
420
  //# sourceMappingURL=actionUtils.js.map
@@ -26,9 +26,10 @@ export declare function buildButtonState(buttonState?: ButtonState): {
26
26
  * @param entitySetName - The name of the entity set
27
27
  * @param actionNames - List of action names to check
28
28
  * @param log - Optional logger instance
29
+ * @param criticalActions - Optional set of action method names annotated Common.IsActionCritical
29
30
  * @returns Array of action button states or empty array if error occurs
30
31
  */
31
- export declare function safeCheckActionButtonStates(convertedMetadata: ConvertedMetadata, entitySetName: string, actionNames: string[], log?: Logger): ActionButtonState[];
32
+ export declare function safeCheckActionButtonStates(convertedMetadata: ConvertedMetadata, entitySetName: string, actionNames: string[], log?: Logger, criticalActions?: Set<string>): ActionButtonState[];
32
33
  /**
33
34
  * Safely gets semantic key properties with error handling.
34
35
  *
@@ -63,10 +64,10 @@ export declare function isALPFromManifest(manifest: Manifest, targetKey?: string
63
64
  * @param metadata - optional metadata for the OPA test generation
64
65
  * @param manifest - optional application manifest, used to detect ALP configuration
65
66
  * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
66
- * @param annotationFiles - optional local annotation XML files merged with the metadata
67
+ * @param annotationXmls - optional annotation XML documents to merge with the metadata (for annotation-only terms)
67
68
  * @returns feature data extracted from the List Report page model
68
69
  */
69
- export declare function getListReportFeatures(listReportPage: PageWithModelV4, log?: Logger, metadata?: string, manifest?: Manifest, resolveLabel?: I18nLabelResolver, annotationFiles?: string[]): ListReportFeatures;
70
+ export declare function getListReportFeatures(listReportPage: PageWithModelV4, log?: Logger, metadata?: string, manifest?: Manifest, resolveLabel?: I18nLabelResolver, annotationXmls?: string[]): ListReportFeatures;
70
71
  /**
71
72
  * Retrieves toolbar action definitions from the given tree model.
72
73
  *
@@ -75,13 +76,16 @@ export declare function getListReportFeatures(listReportPage: PageWithModelV4, l
75
76
  */
76
77
  export declare function getToolBarActions(pageModel: TreeModel): TreeAggregations;
77
78
  /**
78
- * Extracts custom (manifest-declared) toolbar actions from the List Report table toolbar.
79
+ * Extracts custom (manifest-declared) and menu (drop-down) toolbar actions from the List Report
80
+ * table toolbar. Annotation-backed single actions are handled separately via the OData metadata
81
+ * path, so they are not emitted here.
79
82
  *
80
83
  * @param pageModel - the tree model containing the table toolbar definitions
81
84
  * @param resolveLabel - resolver for i18n placeholder labels
82
- * @returns array of custom toolbar action button states
85
+ * @param convertedMetadata - converted OData metadata, required to resolve annotation-backed menu children
86
+ * @returns array of custom and menu toolbar action button states
83
87
  */
84
- export declare function extractCustomToolBarActions(pageModel: TreeModel, resolveLabel: I18nLabelResolver): ActionButtonState[];
88
+ export declare function extractCustomToolBarActions(pageModel: TreeModel, resolveLabel: I18nLabelResolver, convertedMetadata?: ConvertedMetadata): ActionButtonState[];
85
89
  /**
86
90
  * Retrieves filter field names from the page model using ux-specification.
87
91
  *
@@ -194,10 +198,11 @@ export declare function isHiddenProperty(convertedMetadata: ConvertedMetadata, e
194
198
  * @param convertedMetadata The already-converted OData metadata
195
199
  * @param entitySetName The name of the entity set to check
196
200
  * @param actionNames Optional list of action names to filter (e.g., ['Check', 'deductDiscount']). If not provided, returns all actions.
201
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
197
202
  * @returns ActionButtonsResult containing the list of action buttons and their states
198
203
  * @throws {Error} If entity set is not found
199
204
  */
200
- export declare function checkActionButtonStatesFromMetadata(convertedMetadata: ConvertedMetadata, entitySetName: string, actionNames?: string[]): ActionButtonsResult;
205
+ export declare function checkActionButtonStatesFromMetadata(convertedMetadata: ConvertedMetadata, entitySetName: string, actionNames?: string[], criticalActions?: Set<string>): ActionButtonsResult;
201
206
  /**
202
207
  * Checks the state of action buttons defined in UI.LineItem annotations for a given entity set.
203
208
  *
@@ -3,7 +3,7 @@ import { passthroughLabelResolver } from './i18nUtils.js';
3
3
  import { extractContactCardColumnsFromNode, extractTextAnnotationColumnsFromNode, resolvePrimaryTableNode } from './tableUtils.js';
4
4
  import { parse, merge } from '@sap-ux/edmx-parser';
5
5
  import { convert } from '@sap-ux/annotation-converter';
6
- import { extractActionMethodName, buildActionButtonState, safeCheckButtonVisibility, safeCheckButtonVisibilityFromMetadata } from './actionUtils.js';
6
+ import { extractActionMethodName, buildActionButtonState, buildMenuActionState, isMenuActionItem, collectCriticalActionNames, safeCheckButtonVisibility, safeCheckButtonVisibilityFromMetadata } from './actionUtils.js';
7
7
  import { t } from '../i18n.js';
8
8
  export { checkButtonVisibility, safeCheckEditVisibility } from './actionUtils.js';
9
9
  export { safeCheckButtonVisibility };
@@ -27,11 +27,13 @@ export function buildButtonState(buttonState) {
27
27
  * @param entitySetName - The name of the entity set
28
28
  * @param actionNames - List of action names to check
29
29
  * @param log - Optional logger instance
30
+ * @param criticalActions - Optional set of action method names annotated Common.IsActionCritical
30
31
  * @returns Array of action button states or empty array if error occurs
31
32
  */
32
- export function safeCheckActionButtonStates(convertedMetadata, entitySetName, actionNames, log) {
33
+ export function safeCheckActionButtonStates(convertedMetadata, entitySetName, actionNames, log, criticalActions) {
33
34
  try {
34
- return checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames).actions;
35
+ return checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames, criticalActions)
36
+ .actions;
35
37
  }
36
38
  catch (error) {
37
39
  log?.debug(`Failed to check action button states: ${error instanceof Error ? error.message : String(error)}`);
@@ -92,10 +94,10 @@ export function isALPFromManifest(manifest, targetKey) {
92
94
  * @param metadata - optional metadata for the OPA test generation
93
95
  * @param manifest - optional application manifest, used to detect ALP configuration
94
96
  * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
95
- * @param annotationFiles - optional local annotation XML files merged with the metadata
97
+ * @param annotationXmls - optional annotation XML documents to merge with the metadata (for annotation-only terms)
96
98
  * @returns feature data extracted from the List Report page model
97
99
  */
98
- export function getListReportFeatures(listReportPage, log, metadata, manifest, resolveLabel = passthroughLabelResolver, annotationFiles = []) {
100
+ export function getListReportFeatures(listReportPage, log, metadata, manifest, resolveLabel = passthroughLabelResolver, annotationXmls = []) {
99
101
  const toolbarActions = getToolBarActionNames(listReportPage.model, log);
100
102
  const filterFieldEntries = getFilterFieldItems(listReportPage.model, log);
101
103
  const customFilterFieldProperties = getCustomFilterFieldProperties(manifest, listReportPage.name);
@@ -110,23 +112,27 @@ export function getListReportFeatures(listReportPage, log, metadata, manifest, r
110
112
  // with the service metadata before converting. Each source must be parsed with a distinct
111
113
  // fileId; otherwise merge treats them as the same file and later `Annotations` blocks
112
114
  // overwrite (rather than complement) the metadata's property-level annotations.
113
- const parsedAnnotations = annotationFiles.map((xml, index) => parse(xml, `annotationFile${index}`));
115
+ const parsedAnnotations = annotationXmls.map((xml, index) => parse(xml, `annotationFile${index}`));
114
116
  const rawMetadata = parsedAnnotations.length
115
117
  ? merge(parse(metadata, 'metadata'), ...parsedAnnotations)
116
118
  : parse(metadata);
117
119
  convertedMetadata = convert(rawMetadata);
120
+ // IsActionCritical is an annotation-only term surfaced by the merge above; read it off the
121
+ // already-converted metadata rather than re-parsing.
122
+ const criticalActions = collectCriticalActionNames(convertedMetadata);
118
123
  buttonVisibility = safeCheckButtonVisibilityFromMetadata(convertedMetadata, entitySetName, log);
119
124
  semanticKeyProperties = safeGetSemanticKeyProperties(convertedMetadata, entitySetName, log);
120
- toolBarActions = safeCheckActionButtonStates(convertedMetadata, entitySetName, toolbarActions, log);
125
+ toolBarActions = safeCheckActionButtonStates(convertedMetadata, entitySetName, toolbarActions, log, criticalActions);
121
126
  }
122
127
  catch (error) {
123
128
  log?.debug(`Failed to parse metadata: ${error instanceof Error ? error.message : String(error)}`);
124
129
  }
125
130
  }
126
- // Custom (manifest-declared) toolbar actions have no OData counterpart and are matched by label.
127
- // extractCustomToolBarActions filters strictly on actionType === 'Custom', so annotation-backed
128
- // actions (already captured via safeCheckActionButtonStates) are never duplicated here.
129
- toolBarActions = toolBarActions.concat(extractCustomToolBarActions(listReportPage.model, resolveLabel));
131
+ // Custom (manifest-declared) and menu (drop-down) toolbar actions have no OData counterpart in
132
+ // `safeCheckActionButtonStates` (which matches annotation actions by name). extractCustomToolBarActions
133
+ // adds custom actions (matched by label) and menu buttons with their child actions, without
134
+ // duplicating the annotation-backed actions already captured above.
135
+ toolBarActions = toolBarActions.concat(extractCustomToolBarActions(listReportPage.model, resolveLabel, convertedMetadata));
130
136
  // Custom filter fields are matched by rendered label, so resolve unresolved i18n
131
137
  // placeholders via the property's OData `@Common.Label`.
132
138
  const filterBarItems = filterFieldEntries.map((entry) => {
@@ -196,23 +202,31 @@ export function getToolBarActions(pageModel) {
196
202
  return actionAggregations;
197
203
  }
198
204
  /**
199
- * Extracts custom (manifest-declared) toolbar actions from the List Report table toolbar.
205
+ * Extracts custom (manifest-declared) and menu (drop-down) toolbar actions from the List Report
206
+ * table toolbar. Annotation-backed single actions are handled separately via the OData metadata
207
+ * path, so they are not emitted here.
200
208
  *
201
209
  * @param pageModel - the tree model containing the table toolbar definitions
202
210
  * @param resolveLabel - resolver for i18n placeholder labels
203
- * @returns array of custom toolbar action button states
211
+ * @param convertedMetadata - converted OData metadata, required to resolve annotation-backed menu children
212
+ * @returns array of custom and menu toolbar action button states
204
213
  */
205
- export function extractCustomToolBarActions(pageModel, resolveLabel) {
214
+ export function extractCustomToolBarActions(pageModel, resolveLabel, convertedMetadata) {
206
215
  const actionAggregations = getToolBarActions(pageModel);
207
- const customActions = [];
216
+ const schemaNamespace = convertedMetadata?.namespace ?? '';
217
+ const actions = [];
208
218
  for (const key of Object.keys(actionAggregations ?? {})) {
209
219
  const item = actionAggregations[key];
220
+ if (isMenuActionItem(item)) {
221
+ actions.push(buildMenuActionState(item, convertedMetadata, schemaNamespace, resolveLabel));
222
+ continue;
223
+ }
210
224
  if (item?.schema?.actionType !== 'Custom') {
211
225
  continue;
212
226
  }
213
227
  const { label, unresolved } = resolveLabel(item.description);
214
228
  if (label) {
215
- customActions.push({
229
+ actions.push({
216
230
  label,
217
231
  action: '',
218
232
  visible: true,
@@ -222,7 +236,7 @@ export function extractCustomToolBarActions(pageModel, resolveLabel) {
222
236
  });
223
237
  }
224
238
  }
225
- return customActions;
239
+ return actions;
226
240
  }
227
241
  /**
228
242
  * Retrieves filter field names from the page model using ux-specification.
@@ -453,10 +467,11 @@ export function isHiddenProperty(convertedMetadata, entitySetName, propertyName)
453
467
  * @param convertedMetadata The already-converted OData metadata
454
468
  * @param entitySetName The name of the entity set to check
455
469
  * @param actionNames Optional list of action names to filter (e.g., ['Check', 'deductDiscount']). If not provided, returns all actions.
470
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
456
471
  * @returns ActionButtonsResult containing the list of action buttons and their states
457
472
  * @throws {Error} If entity set is not found
458
473
  */
459
- export function checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames) {
474
+ export function checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames, criticalActions) {
460
475
  const entitySet = convertedMetadata.entitySets.find((es) => es.name === entitySetName);
461
476
  if (!entitySet) {
462
477
  throw new Error(`Entity set '${entitySetName}' not found in metadata`);
@@ -471,8 +486,8 @@ export function checkActionButtonStatesFromMetadata(convertedMetadata, entitySet
471
486
  }
472
487
  const dataFieldForActions = lineItemAnnotation.filter((item) => item.$Type === 'com.sap.vocabularies.UI.v1.DataFieldForAction');
473
488
  const actions = actionNames
474
- ? findActionStates(dataFieldForActions, actionNames, convertedMetadata)
475
- : extractAllActionStates(dataFieldForActions, convertedMetadata);
489
+ ? findActionStates(dataFieldForActions, actionNames, convertedMetadata, criticalActions)
490
+ : extractAllActionStates(dataFieldForActions, convertedMetadata, criticalActions);
476
491
  return { actions, entityType: entityType.name };
477
492
  }
478
493
  /**
@@ -499,9 +514,10 @@ export function checkActionButtonStates(metadataXml, entitySetName, actionNames)
499
514
  * @param dataFieldForActions List of DataFieldForAction items from UI.LineItem
500
515
  * @param actionNames List of action names to find
501
516
  * @param metadata The converted metadata
517
+ * @param criticalActions - Optional set of action method names annotated Common.IsActionCritical
502
518
  * @returns List of action button states for the specified actions
503
519
  */
504
- function findActionStates(dataFieldForActions, actionNames, metadata) {
520
+ function findActionStates(dataFieldForActions, actionNames, metadata, criticalActions) {
505
521
  const actionStates = [];
506
522
  for (const actionName of actionNames) {
507
523
  const item = dataFieldForActions.find((dfa) => {
@@ -509,7 +525,7 @@ function findActionStates(dataFieldForActions, actionNames, metadata) {
509
525
  return actionMethod === actionName || dfa.Label === actionName;
510
526
  });
511
527
  if (item) {
512
- actionStates.push(buildActionButtonState(item, metadata));
528
+ actionStates.push(buildActionButtonState(item, metadata, criticalActions));
513
529
  }
514
530
  }
515
531
  return actionStates;
@@ -519,10 +535,11 @@ function findActionStates(dataFieldForActions, actionNames, metadata) {
519
535
  *
520
536
  * @param dataFieldForActions List of DataFieldForAction items from UI.LineItem
521
537
  * @param metadata The converted metadata
538
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
522
539
  * @returns List of all action button states
523
540
  */
524
- function extractAllActionStates(dataFieldForActions, metadata) {
525
- return dataFieldForActions.map((item) => buildActionButtonState(item, metadata));
541
+ function extractAllActionStates(dataFieldForActions, metadata, criticalActions) {
542
+ return dataFieldForActions.map((item) => buildActionButtonState(item, metadata, criticalActions));
526
543
  }
527
544
  /**
528
545
  * Retrieves toolbar action names from the page model using ux-specification.
@@ -0,0 +1,11 @@
1
+ import type { ConvertedMetadata } from '@sap-ux/vocabularies-types';
2
+ /**
3
+ * Converts the service metadata merged with its annotation files into a single converted model.
4
+ * Annotation-only terms (e.g. `Common.IsActionCritical`) only surface once the annotation files are merged in.
5
+ *
6
+ * @param metadataXml The service metadata XML (metadata.xml), or undefined
7
+ * @param annotationXmls Annotation XML documents to merge, in manifest order
8
+ * @returns The merged converted metadata, or undefined if no metadata was provided
9
+ */
10
+ export declare function getMergedConvertedMetadata(metadataXml?: string, annotationXmls?: string[]): ConvertedMetadata | undefined;
11
+ //# sourceMappingURL=metadataXmlUtils.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { parse, merge } from '@sap-ux/edmx-parser';
2
+ import { convert } from '@sap-ux/annotation-converter';
3
+ /**
4
+ * Converts the service metadata merged with its annotation files into a single converted model.
5
+ * Annotation-only terms (e.g. `Common.IsActionCritical`) only surface once the annotation files are merged in.
6
+ *
7
+ * @param metadataXml The service metadata XML (metadata.xml), or undefined
8
+ * @param annotationXmls Annotation XML documents to merge, in manifest order
9
+ * @returns The merged converted metadata, or undefined if no metadata was provided
10
+ */
11
+ export function getMergedConvertedMetadata(metadataXml, annotationXmls = []) {
12
+ if (!metadataXml) {
13
+ return undefined;
14
+ }
15
+ const parsedDocs = [
16
+ parse(metadataXml),
17
+ ...annotationXmls.map((xml, index) => parse(xml, `annotation${index}.xml`))
18
+ ];
19
+ return convert(parsedDocs.length > 1 ? merge(...parsedDocs) : parsedDocs[0]);
20
+ }
21
+ //# sourceMappingURL=metadataXmlUtils.js.map
@@ -37,8 +37,8 @@ export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
37
37
  let objectPages = null;
38
38
  let fpmPage = null;
39
39
  let projectMetadata = metadata;
40
- let annotationFiles = [];
41
- let resolveLabel = passthroughLabelResolver;
40
+ let annotationXmls = [];
41
+ let resolveLabel;
42
42
  // Read application model to extract control information needed for test generation
43
43
  // specification and readApp might not be available due to specification version, fail gracefully
44
44
  try {
@@ -61,18 +61,20 @@ export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
61
61
  }
62
62
  }
63
63
  // Local annotation files (e.g. webapp/annotations/annotation.xml) are not part of the
64
- // service $metadata; read them so annotations defined only locally (e.g. UI.TextArrangement)
65
- // are available when the metadata is converted.
64
+ // service $metadata; read them so annotation-only terms (e.g. UI.TextArrangement,
65
+ // Common.IsActionCritical) are available when the metadata is converted.
66
66
  const annotationRefs = appAccess.project?.apps['']?.services?.mainService?.annotations ?? [];
67
- annotationFiles = annotationRefs
67
+ annotationXmls = annotationRefs
68
68
  .map((annotation) => annotation.local)
69
69
  .filter((path) => !!path)
70
70
  .map((path) => fs?.read(path))
71
71
  .filter((content) => !!content);
72
72
  resolveLabel = await buildLabelResolver(appAccess, log);
73
- listReportPage = appModel?.applicationModel ? getListReportPage(appModel.applicationModel) : listReportPage;
74
- objectPages = appModel?.applicationModel ? getObjectPages(appModel.applicationModel) : objectPages;
75
- fpmPage = appModel?.applicationModel ? getFPMPage(appModel.applicationModel) : fpmPage;
73
+ if (appModel?.applicationModel) {
74
+ listReportPage = getListReportPage(appModel.applicationModel);
75
+ objectPages = getObjectPages(appModel.applicationModel);
76
+ fpmPage = getFPMPage(appModel.applicationModel);
77
+ }
76
78
  }
77
79
  catch (error) {
78
80
  log?.warn('Error analyzing project model using specification. No dynamic tests will be generated. Error: ' +
@@ -86,10 +88,15 @@ export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
86
88
  // attempt to get individual feature data
87
89
  try {
88
90
  if (listReportPage) {
89
- featureData.listReport = getListReportFeatures(listReportPage, log, projectMetadata, manifest, resolveLabel, annotationFiles);
91
+ featureData.listReport = getListReportFeatures(listReportPage, log, projectMetadata, manifest, resolveLabel, annotationXmls);
90
92
  }
91
93
  if (objectPages) {
92
- featureData.objectPages = await getObjectPageFeatures(objectPages, listReportPage?.name, log, projectMetadata, manifest, listReportPage?.entitySet, resolveLabel);
94
+ featureData.objectPages = await getObjectPageFeatures(objectPages, listReportPage?.name, log, projectMetadata, {
95
+ manifest,
96
+ listReportEntitySet: listReportPage?.entitySet,
97
+ resolveLabel,
98
+ annotationXmls
99
+ });
93
100
  }
94
101
  if (fpmPage) {
95
102
  featureData.fpm = getFPMFeatures(fpmPage, log);
@@ -4,6 +4,19 @@ import type { ApplicationModel } from '@sap/ux-specification/dist/types/src/pars
4
4
  import type { ObjectPageFeatures } from '../types.js';
5
5
  import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application.js';
6
6
  import { type I18nLabelResolver } from './i18nUtils.js';
7
+ /**
8
+ * Optional context for {@link getObjectPageFeatures}.
9
+ */
10
+ export interface ObjectPageFeaturesOptions {
11
+ /** Application manifest, used to resolve the parent List Report's default table tab. */
12
+ manifest?: Manifest;
13
+ /** Entity set of the parent List Report, used to resolve the originating view. */
14
+ listReportEntitySet?: string;
15
+ /** Resolver for i18n placeholder labels (`{i18n>key}` → translated text). */
16
+ resolveLabel?: I18nLabelResolver;
17
+ /** Annotation XML documents to merge with the metadata (for annotation-only terms). */
18
+ annotationXmls?: string[];
19
+ }
7
20
  /**
8
21
  * Extracts feature data for object pages from the application model.
9
22
  *
@@ -11,12 +24,10 @@ import { type I18nLabelResolver } from './i18nUtils.js';
11
24
  * @param listReportPageKey - the key of the List Report page in the application model, used to find navigation routes to object pages
12
25
  * @param log - optional logger instance
13
26
  * @param metadata - optional metadata for the OPA test generation
14
- * @param manifest - optional application manifest, used to resolve the parent List Report's default table tab
15
- * @param listReportEntitySet - entity set of the parent List Report, used to resolve the originating view
16
- * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
27
+ * @param options - optional context (manifest, parent List Report entity set, label resolver, annotation XMLs)
17
28
  * @returns a record of object page feature data
18
29
  */
19
- export declare function getObjectPageFeatures(objectPages: PageWithModelV4[], listReportPageKey?: string, log?: Logger, metadata?: string, manifest?: Manifest, listReportEntitySet?: string, resolveLabel?: I18nLabelResolver): Promise<ObjectPageFeatures[]>;
30
+ export declare function getObjectPageFeatures(objectPages: PageWithModelV4[], listReportPageKey?: string, log?: Logger, metadata?: string, options?: ObjectPageFeaturesOptions): Promise<ObjectPageFeatures[]>;
20
31
  /**
21
32
  * Retrieves all Object Page definitions from the given application model, as long as the page is reachable via standard navigation routes.
22
33
  *