@sap-ux/ui5-test-writer 1.10.7 → 1.11.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.
@@ -4,6 +4,14 @@ import type { DataFieldForAction } from '@sap-ux/vocabularies-types/vocabularies
4
4
  import type { OperationAvailable } from '@sap-ux/vocabularies-types/vocabularies/Core.js';
5
5
  import type { DeleteRestrictionsType, InsertRestrictionsType, UpdateRestrictionsType } from '@sap-ux/vocabularies-types/vocabularies/Capabilities.js';
6
6
  import type { Logger } from '@sap-ux/logger';
7
+ /**
8
+ * Collects the names of actions annotated with `Common.IsActionCritical` from converted metadata.
9
+ * The metadata must already include the annotation files (merged) for annotation-only terms to surface.
10
+ *
11
+ * @param metadata The converted (ideally annotation-merged) OData metadata
12
+ * @returns The set of critical action method names (empty if none)
13
+ */
14
+ export declare function collectCriticalActionNames(metadata?: ConvertedMetadata): Set<string>;
7
15
  type OperationAvailableWithPaths = OperationAvailable & {
8
16
  $Path?: string;
9
17
  path?: string;
@@ -52,9 +60,10 @@ export declare function extractEnumMemberValue(enumValue: unknown): string | und
52
60
  *
53
61
  * @param item The DataFieldForAction annotation item
54
62
  * @param metadata The converted metadata
63
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
55
64
  * @returns ActionButtonState for the action
56
65
  */
57
- export declare function buildActionButtonState(item: DataFieldForAction, metadata: ConvertedMetadata): ActionButtonState;
66
+ export declare function buildActionButtonState(item: DataFieldForAction, metadata: ConvertedMetadata, criticalActions?: Set<string>): ActionButtonState;
58
67
  /**
59
68
  * Builds an ActionButtonState from a spec model aggregation key.
60
69
  *
@@ -65,9 +74,10 @@ export declare function buildActionButtonState(item: DataFieldForAction, metadat
65
74
  * @param label Display label from the spec model item description
66
75
  * @param convertedMetadata The converted OData metadata
67
76
  * @param schemaNamespace The OData schema namespace (used as service identifier)
77
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
68
78
  * @returns ActionButtonState or undefined if the key is not a DataFieldForAction key
69
79
  */
70
- export declare function buildActionStateFromSpecModelKey(aggregationKey: string, label: string | undefined, convertedMetadata: ConvertedMetadata, schemaNamespace: string): ActionButtonState | undefined;
80
+ export declare function buildActionStateFromSpecModelKey(aggregationKey: string, label: string | undefined, convertedMetadata: ConvertedMetadata, schemaNamespace: string, criticalActions?: Set<string>): ActionButtonState | undefined;
71
81
  /**
72
82
  * Analyzes a restriction value (Insertable, Deletable, or Updatable) to determine button state.
73
83
  *
@@ -1,6 +1,26 @@
1
1
  import { parse } from '@sap-ux/edmx-parser';
2
2
  import { convert } from '@sap-ux/annotation-converter';
3
3
  const DATA_FIELD_FOR_ACTION = 'DataFieldForAction';
4
+ /**
5
+ * Collects the names of actions annotated with `Common.IsActionCritical` from converted metadata.
6
+ * The metadata must already include the annotation files (merged) for annotation-only terms to surface.
7
+ *
8
+ * @param metadata The converted (ideally annotation-merged) OData metadata
9
+ * @returns The set of critical action method names (empty if none)
10
+ */
11
+ export function collectCriticalActionNames(metadata) {
12
+ const names = new Set();
13
+ for (const action of metadata?.actions ?? []) {
14
+ if (action.name) {
15
+ // ponytail: IsActionCritical is present at runtime but missing from the vocabularies-types typings.
16
+ const common = action.annotations?.Common;
17
+ if (common?.IsActionCritical?.valueOf() === true) {
18
+ names.add(action.name);
19
+ }
20
+ }
21
+ }
22
+ return names;
23
+ }
4
24
  /**
5
25
  * Extracts the action method name from a fully qualified action string.
6
26
  *
@@ -93,9 +113,10 @@ export function extractEnumMemberValue(enumValue) {
93
113
  *
94
114
  * @param item The DataFieldForAction annotation item
95
115
  * @param metadata The converted metadata
116
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
96
117
  * @returns ActionButtonState for the action
97
118
  */
98
- export function buildActionButtonState(item, metadata) {
119
+ export function buildActionButtonState(item, metadata, criticalActions) {
99
120
  const actionString = item.Action || '';
100
121
  const actionMethod = extractActionMethodName(actionString);
101
122
  const operationAvailable = findOperationAvailableAnnotation(metadata, actionMethod);
@@ -115,7 +136,8 @@ export function buildActionButtonState(item, metadata) {
115
136
  visible: true,
116
137
  enabled,
117
138
  dynamicPath,
118
- invocationGrouping: item.InvocationGrouping ? extractEnumMemberValue(item.InvocationGrouping) : undefined
139
+ invocationGrouping: item.InvocationGrouping ? extractEnumMemberValue(item.InvocationGrouping) : undefined,
140
+ isCritical: criticalActions?.has(actionMethod) ?? false
119
141
  };
120
142
  }
121
143
  /**
@@ -128,9 +150,10 @@ export function buildActionButtonState(item, metadata) {
128
150
  * @param label Display label from the spec model item description
129
151
  * @param convertedMetadata The converted OData metadata
130
152
  * @param schemaNamespace The OData schema namespace (used as service identifier)
153
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
131
154
  * @returns ActionButtonState or undefined if the key is not a DataFieldForAction key
132
155
  */
133
- export function buildActionStateFromSpecModelKey(aggregationKey, label, convertedMetadata, schemaNamespace) {
156
+ export function buildActionStateFromSpecModelKey(aggregationKey, label, convertedMetadata, schemaNamespace, criticalActions) {
134
157
  const keyParts = aggregationKey.split('::');
135
158
  if (keyParts[0] !== DATA_FIELD_FOR_ACTION || !keyParts[1]) {
136
159
  return undefined;
@@ -151,7 +174,8 @@ export function buildActionStateFromSpecModelKey(aggregationKey, label, converte
151
174
  unbound: !isBound,
152
175
  visible: true,
153
176
  enabled,
154
- dynamicPath
177
+ dynamicPath,
178
+ isCritical: criticalActions?.has(actionMethod) ?? false
155
179
  };
156
180
  }
157
181
  /**
@@ -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
  *
@@ -194,10 +195,11 @@ export declare function isHiddenProperty(convertedMetadata: ConvertedMetadata, e
194
195
  * @param convertedMetadata The already-converted OData metadata
195
196
  * @param entitySetName The name of the entity set to check
196
197
  * @param actionNames Optional list of action names to filter (e.g., ['Check', 'deductDiscount']). If not provided, returns all actions.
198
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
197
199
  * @returns ActionButtonsResult containing the list of action buttons and their states
198
200
  * @throws {Error} If entity set is not found
199
201
  */
200
- export declare function checkActionButtonStatesFromMetadata(convertedMetadata: ConvertedMetadata, entitySetName: string, actionNames?: string[]): ActionButtonsResult;
202
+ export declare function checkActionButtonStatesFromMetadata(convertedMetadata: ConvertedMetadata, entitySetName: string, actionNames?: string[], criticalActions?: Set<string>): ActionButtonsResult;
201
203
  /**
202
204
  * Checks the state of action buttons defined in UI.LineItem annotations for a given entity set.
203
205
  *
@@ -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, 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,14 +112,17 @@ 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)}`);
@@ -453,10 +458,11 @@ export function isHiddenProperty(convertedMetadata, entitySetName, propertyName)
453
458
  * @param convertedMetadata The already-converted OData metadata
454
459
  * @param entitySetName The name of the entity set to check
455
460
  * @param actionNames Optional list of action names to filter (e.g., ['Check', 'deductDiscount']). If not provided, returns all actions.
461
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
456
462
  * @returns ActionButtonsResult containing the list of action buttons and their states
457
463
  * @throws {Error} If entity set is not found
458
464
  */
459
- export function checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames) {
465
+ export function checkActionButtonStatesFromMetadata(convertedMetadata, entitySetName, actionNames, criticalActions) {
460
466
  const entitySet = convertedMetadata.entitySets.find((es) => es.name === entitySetName);
461
467
  if (!entitySet) {
462
468
  throw new Error(`Entity set '${entitySetName}' not found in metadata`);
@@ -471,8 +477,8 @@ export function checkActionButtonStatesFromMetadata(convertedMetadata, entitySet
471
477
  }
472
478
  const dataFieldForActions = lineItemAnnotation.filter((item) => item.$Type === 'com.sap.vocabularies.UI.v1.DataFieldForAction');
473
479
  const actions = actionNames
474
- ? findActionStates(dataFieldForActions, actionNames, convertedMetadata)
475
- : extractAllActionStates(dataFieldForActions, convertedMetadata);
480
+ ? findActionStates(dataFieldForActions, actionNames, convertedMetadata, criticalActions)
481
+ : extractAllActionStates(dataFieldForActions, convertedMetadata, criticalActions);
476
482
  return { actions, entityType: entityType.name };
477
483
  }
478
484
  /**
@@ -499,9 +505,10 @@ export function checkActionButtonStates(metadataXml, entitySetName, actionNames)
499
505
  * @param dataFieldForActions List of DataFieldForAction items from UI.LineItem
500
506
  * @param actionNames List of action names to find
501
507
  * @param metadata The converted metadata
508
+ * @param criticalActions - Optional set of action method names annotated Common.IsActionCritical
502
509
  * @returns List of action button states for the specified actions
503
510
  */
504
- function findActionStates(dataFieldForActions, actionNames, metadata) {
511
+ function findActionStates(dataFieldForActions, actionNames, metadata, criticalActions) {
505
512
  const actionStates = [];
506
513
  for (const actionName of actionNames) {
507
514
  const item = dataFieldForActions.find((dfa) => {
@@ -509,7 +516,7 @@ function findActionStates(dataFieldForActions, actionNames, metadata) {
509
516
  return actionMethod === actionName || dfa.Label === actionName;
510
517
  });
511
518
  if (item) {
512
- actionStates.push(buildActionButtonState(item, metadata));
519
+ actionStates.push(buildActionButtonState(item, metadata, criticalActions));
513
520
  }
514
521
  }
515
522
  return actionStates;
@@ -519,10 +526,11 @@ function findActionStates(dataFieldForActions, actionNames, metadata) {
519
526
  *
520
527
  * @param dataFieldForActions List of DataFieldForAction items from UI.LineItem
521
528
  * @param metadata The converted metadata
529
+ * @param criticalActions Optional set of action method names annotated Common.IsActionCritical
522
530
  * @returns List of all action button states
523
531
  */
524
- function extractAllActionStates(dataFieldForActions, metadata) {
525
- return dataFieldForActions.map((item) => buildActionButtonState(item, metadata));
532
+ function extractAllActionStates(dataFieldForActions, metadata, criticalActions) {
533
+ return dataFieldForActions.map((item) => buildActionButtonState(item, metadata, criticalActions));
526
534
  }
527
535
  /**
528
536
  * 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
  *
@@ -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, 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
@@ -337,13 +340,14 @@ function buildCustomActionState(item, resolveLabel) {
337
340
  * @param convertedMetadata - converted OData metadata
338
341
  * @param schemaNamespace - OData schema namespace used as service identifier
339
342
  * @param resolveLabel - resolver for i18n placeholder labels
343
+ * @param criticalActions - set of action method names annotated Common.IsActionCritical
340
344
  * @returns the action or menu button state, or undefined if the entry is neither
341
345
  */
342
- function buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel) {
346
+ function buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel, criticalActions) {
343
347
  if (isMenuActionItem(item)) {
344
348
  return buildMenuActionState(item, convertedMetadata, schemaNamespace, resolveLabel);
345
349
  }
346
- const odataState = buildActionStateFromSpecModelKey(key, item.description, convertedMetadata, schemaNamespace);
350
+ const odataState = buildActionStateFromSpecModelKey(key, item.description, convertedMetadata, schemaNamespace, criticalActions);
347
351
  if (odataState) {
348
352
  return odataState;
349
353
  }
@@ -360,9 +364,10 @@ function buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, r
360
364
  * @param convertedMetadata - converted OData metadata for resolving action availability
361
365
  * @param schemaNamespace - OData schema namespace used as service identifier in action assertions
362
366
  * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
367
+ * @param criticalActions - set of action method names annotated Common.IsActionCritical
363
368
  * @returns array of action button states for the header toolbar
364
369
  */
365
- function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, resolveLabel) {
370
+ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, resolveLabel, criticalActions) {
366
371
  if (!objectPage.model) {
367
372
  return [];
368
373
  }
@@ -370,7 +375,7 @@ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, re
370
375
  const actionsAgg = getAggregations(headerAgg)['actions'];
371
376
  const actionEntries = getAggregations(actionsAgg);
372
377
  return Object.entries(actionEntries)
373
- .map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel))
378
+ .map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel, criticalActions))
374
379
  .filter((actionState) => actionState !== undefined);
375
380
  }
376
381
  /**
@@ -381,9 +386,10 @@ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, re
381
386
  * @param convertedMetadata - converted OData metadata for resolving action availability
382
387
  * @param schemaNamespace - OData schema namespace used as service identifier in action assertions
383
388
  * @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
389
+ * @param criticalActions - set of action method names annotated Common.IsActionCritical
384
390
  * @returns array of action button states for the section toolbar
385
391
  */
386
- function extractSectionActions(section, convertedMetadata, schemaNamespace, resolveLabel) {
392
+ function extractSectionActions(section, convertedMetadata, schemaNamespace, resolveLabel, criticalActions) {
387
393
  let actionsAgg;
388
394
  if (isTableSection(section)) {
389
395
  const tableAgg = getAggregations(section)['table'];
@@ -399,7 +405,7 @@ function extractSectionActions(section, convertedMetadata, schemaNamespace, reso
399
405
  }
400
406
  const actionEntries = getAggregations(actionsAgg);
401
407
  return Object.entries(actionEntries)
402
- .map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel))
408
+ .map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel, criticalActions))
403
409
  .filter((actionState) => actionState !== undefined);
404
410
  }
405
411
  /**
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.11.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -91,11 +91,31 @@ sap.ui.define([
91
91
  <%_ if (item.labelUnresolved) { _%>
92
92
  // TODO: label is an unresolved i18n key; replace with the rendered action text
93
93
  <%_ } _%>
94
- // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
94
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
95
95
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { visible: true });
96
96
  <%_ } else { _%>
97
97
  // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
98
98
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
99
+ <%_ if (item.isCritical && item.enabled === 'dynamic') { _%>
100
+ // "<%- 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.
101
+ <%_ if (!hideFilterBar) { _%>
102
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
103
+ <%_ } _%>
104
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
105
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
106
+ // Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
107
+ // When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
108
+ <%_ } else if (item.isCritical) { _%>
109
+ <%_ if (!hideFilterBar) { _%>
110
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
111
+ <%_ } _%>
112
+ <%_ if (item.enabled !== true) { _%>
113
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
114
+ <%_ } _%>
115
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
116
+ Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
117
+ When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
118
+ <%_ } _%>
99
119
  <%_ } _%>
100
120
  <%_ } _%>
101
121
  <%_ }); -%>
@@ -82,7 +82,7 @@ function journey() {
82
82
  // });
83
83
 
84
84
  <%_ 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) {
85
+ opaTest("Check table columns and actions", function (_Given: Given, <% if (toolBarActions && toolBarActions.some(function(item) { return item.visible && item.isCritical && item.enabled !== 'dynamic'; })) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
86
86
  <%_ if (toolBarActions && toolBarActions.length > 0) { -%>
87
87
  <%_ if (createButton.visible && !isALP) { _%>
88
88
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckCreate({ visible: true });
@@ -98,11 +98,31 @@ function journey() {
98
98
  <%_ if (item.labelUnresolved) { _%>
99
99
  // TODO: label is an unresolved i18n key; replace with the rendered action text
100
100
  <%_ } _%>
101
- // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
101
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
102
102
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { visible: true });
103
103
  <%_ } else { _%>
104
104
  // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
105
105
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
106
+ <%_ if (item.isCritical && item.enabled === 'dynamic') { _%>
107
+ // "<%- 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.
108
+ <%_ if (!hideFilterBar) { _%>
109
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
110
+ <%_ } _%>
111
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
112
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
113
+ // Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
114
+ // When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
115
+ <%_ } else if (item.isCritical) { _%>
116
+ <%_ if (!hideFilterBar) { _%>
117
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
118
+ <%_ } _%>
119
+ <%_ if (item.enabled !== true) { _%>
120
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
121
+ <%_ } _%>
122
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
123
+ Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
124
+ When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
125
+ <%_ } _%>
106
126
  <%_ } _%>
107
127
  <%_ } _%>
108
128
  <%_ }); -%>
@@ -68,12 +68,22 @@ sap.ui.define([
68
68
  // TODO: label is an unresolved i18n key; replace with the rendered action text
69
69
  <% } -%>
70
70
  Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
71
- // When.onThe<%- name%>Generated.onHeader().iPressAction(<%- JSON.stringify(action.label) %>);
71
+ // When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
72
72
  <% } else if (action.enabled === 'dynamic') { -%>
73
73
  Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
74
- // When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
75
74
  <% } else { -%>
76
75
  Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
76
+ <% } -%>
77
+ <% if (action.isCritical && action.enabled === 'dynamic') { -%>
78
+ // "<%- action.label || action.action %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the opened entity. Uncomment when the entity state enables it to test the confirmation dialog.
79
+ // When.onThe<%- name%>Generated.onHeader().iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
80
+ // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
81
+ // When.onThe<%- name%>Generated.onMessageDialog().iCancel();
82
+ <% } else if (action.isCritical) { -%>
83
+ When.onThe<%- name%>Generated.onHeader().iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
84
+ Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
85
+ When.onThe<%- name%>Generated.onMessageDialog().iCancel();
86
+ <% } else if (!action.custom && !action.menuActions) { -%>
77
87
  // When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
78
88
  <% } -%>
79
89
  <% } -%>
@@ -120,7 +130,7 @@ sap.ui.define([
120
130
  <% } -%>
121
131
  <% if (bodySections?.length > 0) { -%>
122
132
  <% bodySections.forEach(function(section) { -%>
123
- opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1 || (section.subSections && section.subSections.length > 1) || (section.contactCardFields && section.contactCardFields.length > 0) || (section.contactCardColumns && section.contactCardColumns.length > 0) || (section.subSections || []).some(function(sub){ return (sub.contactCardFields && sub.contactCardFields.length > 0) || (sub.contactCardColumns && sub.contactCardColumns.length > 0); }) || (section.actions && section.actions.some(function(a) { return a.visible && a.menuActions; }))) { %>When<% } else { %>_When<% } %>, Then) {
133
+ opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1 || (section.subSections && section.subSections.length > 1) || (section.contactCardFields && section.contactCardFields.length > 0) || (section.contactCardColumns && section.contactCardColumns.length > 0) || (section.subSections || []).some(function(sub){ return (sub.contactCardFields && sub.contactCardFields.length > 0) || (sub.contactCardColumns && sub.contactCardColumns.length > 0); }) || (section.actions || []).some(function(a){ return a.visible && ((a.isCritical && a.enabled !== 'dynamic') || a.menuActions); })) { %>When<% } else { %>_When<% } %>, Then) {
124
134
  <% if (bodySections.length > 1) { -%>
125
135
  When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>" });
126
136
  <% } -%>
@@ -143,12 +153,25 @@ sap.ui.define([
143
153
  // TODO: label is an unresolved i18n key; replace with the rendered action text
144
154
  <% } -%>
145
155
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
146
- // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction(<%- JSON.stringify(action.label) %>);
156
+ // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
147
157
  <% } else if (action.enabled === 'dynamic') { -%>
148
158
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
149
- // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
150
159
  <% } else { -%>
151
160
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
161
+ <% } -%>
162
+ <% if (action.isCritical && action.enabled === 'dynamic') { -%>
163
+ // "<%- action.label || action.action %>" 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.
164
+ // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iSelectRows(0);
165
+ // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
166
+ // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
167
+ // When.onThe<%- name%>Generated.onMessageDialog().iCancel();
168
+ <% } else if (action.isCritical) { -%>
169
+ // Critical action (Common.IsActionCritical): select a row, press it, assert the confirmation dialog opens, then cancel so it is not executed.
170
+ When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iSelectRows(0);
171
+ When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
172
+ Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
173
+ When.onThe<%- name%>Generated.onMessageDialog().iCancel();
174
+ <% } else if (!action.custom && !action.menuActions) { -%>
152
175
  // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
153
176
  <% } -%>
154
177
  <% } else { -%>
@@ -166,12 +189,23 @@ sap.ui.define([
166
189
  // TODO: label is an unresolved i18n key; replace with the rendered action text
167
190
  <% } -%>
168
191
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
169
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iPressAction(<%- JSON.stringify(action.label) %>);
192
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
170
193
  <% } else if (action.enabled === 'dynamic') { -%>
171
194
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
172
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
173
195
  <% } else { -%>
174
196
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
197
+ <% } -%>
198
+ <% if (action.isCritical && action.enabled === 'dynamic') { -%>
199
+ // "<%- action.label || action.action %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the opened entity. Uncomment when the entity state enables it to test the confirmation dialog.
200
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
201
+ // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
202
+ // When.onThe<%- name%>Generated.onMessageDialog().iCancel();
203
+ <% } else if (action.isCritical) { -%>
204
+ // Critical action (Common.IsActionCritical): press it, assert the confirmation dialog opens, then cancel so it is not executed.
205
+ When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
206
+ Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
207
+ When.onThe<%- name%>Generated.onMessageDialog().iCancel();
208
+ <% } else if (!action.custom && !action.menuActions) { -%>
175
209
  // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
176
210
  <% } -%>
177
211
  <% } -%>
@@ -36,7 +36,7 @@ const usesWhenInBody = (bodySections || []).length > 1 || (bodySections || []).s
36
36
  || (section.contactCardFields && section.contactCardFields.length > 0)
37
37
  || (section.contactCardColumns && section.contactCardColumns.length > 0)
38
38
  || (section.subSections || []).some(function(sub) { return (sub.contactCardFields && sub.contactCardFields.length > 0) || (sub.contactCardColumns && sub.contactCardColumns.length > 0); })
39
- || (section.actions || []).some(function(action) { return action.visible && action.menuActions; });
39
+ || (section.actions || []).some(function(action) { return action.visible && ((action.isCritical && action.enabled !== 'dynamic') || action.menuActions); });
40
40
  });
41
41
  const headerHasMenu = (headerActions || []).some(function(action) { return action.visible && action.menuActions; });
42
42
  -%>
@@ -73,7 +73,7 @@ function journey() {
73
73
  });
74
74
 
75
75
  <% if (headerActions?.length > 0) { -%>
76
- opaTest("Check header actions of the Object Page", function (_Given: Given, <% if (headerHasMenu) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
76
+ opaTest("Check header actions of the Object Page", function (_Given: Given, <% if (headerHasMenu || headerActions.some(function(action) { return action.visible && action.isCritical && action.enabled !== 'dynamic'; })) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
77
77
  <% if (editButton?.visible) { -%>
78
78
  // Ensure the opened entity is not in Draft state before uncommenting
79
79
  // Then.onThe<%- name%>Generated.onHeader().iCheckEdit({ visible: true });
@@ -95,12 +95,22 @@ function journey() {
95
95
  // TODO: label is an unresolved i18n key; replace with the rendered action text
96
96
  <% } -%>
97
97
  Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
98
- // When.onThe<%- name%>Generated.onHeader().iPressAction(<%- JSON.stringify(action.label) %>);
98
+ // When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
99
99
  <% } else if (action.enabled === 'dynamic') { -%>
100
100
  Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
101
- // When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
102
101
  <% } else { -%>
103
102
  Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
103
+ <% } -%>
104
+ <% if (action.isCritical && action.enabled === 'dynamic') { -%>
105
+ // "<%- action.label || action.action %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the opened entity. Uncomment when the entity state enables it to test the confirmation dialog.
106
+ // When.onThe<%- name%>Generated.onHeader().iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
107
+ // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
108
+ // When.onThe<%- name%>Generated.onMessageDialog().iCancel();
109
+ <% } else if (action.isCritical) { -%>
110
+ When.onThe<%- name%>Generated.onHeader().iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
111
+ Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
112
+ When.onThe<%- name%>Generated.onMessageDialog().iCancel();
113
+ <% } else if (!action.custom && !action.menuActions) { -%>
104
114
  // When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
105
115
  <% } -%>
106
116
  <% } -%>
@@ -170,12 +180,25 @@ function journey() {
170
180
  // TODO: label is an unresolved i18n key; replace with the rendered action text
171
181
  <% } -%>
172
182
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
173
- // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction(<%- JSON.stringify(action.label) %>);
183
+ // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
174
184
  <% } else if (action.enabled === 'dynamic') { -%>
175
185
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
176
- // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
177
186
  <% } else { -%>
178
187
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
188
+ <% } -%>
189
+ <% if (action.isCritical && action.enabled === 'dynamic') { -%>
190
+ // "<%- action.label || action.action %>" 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.
191
+ // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iSelectRows(0);
192
+ // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
193
+ // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
194
+ // When.onThe<%- name%>Generated.onMessageDialog().iCancel();
195
+ <% } else if (action.isCritical) { -%>
196
+ // Critical action (Common.IsActionCritical): select a row, press it, assert the confirmation dialog opens, then cancel so it is not executed.
197
+ When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iSelectRows(0);
198
+ When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
199
+ Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
200
+ When.onThe<%- name%>Generated.onMessageDialog().iCancel();
201
+ <% } else if (!action.custom && !action.menuActions) { -%>
179
202
  // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
180
203
  <% } -%>
181
204
  <% } else { -%>
@@ -193,12 +216,23 @@ function journey() {
193
216
  // TODO: label is an unresolved i18n key; replace with the rendered action text
194
217
  <% } -%>
195
218
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
196
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction(<%- JSON.stringify(action.label) %>);
219
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>);
197
220
  <% } else if (action.enabled === 'dynamic') { -%>
198
221
  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 } */);
199
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
200
222
  <% } else { -%>
201
223
  Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
224
+ <% } -%>
225
+ <% if (action.isCritical && action.enabled === 'dynamic') { -%>
226
+ // "<%- action.label || action.action %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the opened entity. Uncomment when the entity state enables it to test the confirmation dialog.
227
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
228
+ // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
229
+ // When.onThe<%- name%>Generated.onMessageDialog().iCancel();
230
+ <% } else if (action.isCritical) { -%>
231
+ // Critical action (Common.IsActionCritical): press it, assert the confirmation dialog opens, then cancel so it is not executed.
232
+ When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
233
+ Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
234
+ When.onThe<%- name%>Generated.onMessageDialog().iCancel();
235
+ <% } else if (!action.custom && !action.menuActions) { -%>
202
236
  // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
203
237
  <% } -%>
204
238
  <% } -%>