@sap-ux/ui5-test-writer 1.8.2 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fiori-elements-opa-writer.d.ts +11 -1
- package/dist/fiori-elements-opa-writer.js +33 -0
- package/dist/types.d.ts +32 -0
- package/dist/utils/actionUtils.d.ts +4 -3
- package/dist/utils/actionUtils.js +13 -15
- package/dist/utils/i18nUtils.d.ts +37 -0
- package/dist/utils/i18nUtils.js +39 -0
- package/dist/utils/listReportUtils.d.ts +11 -1
- package/dist/utils/listReportUtils.js +36 -1
- package/dist/utils/modelUtils.d.ts +3 -0
- package/dist/utils/modelUtils.js +22 -2
- package/dist/utils/objectPageUtils.d.ts +4 -2
- package/dist/utils/objectPageUtils.js +126 -10
- package/package.json +6 -6
- package/templates/v4/1.148/integration/ObjectPageJourney.js +37 -7
- package/templates/v4/1.148/integration/ObjectPageJourney.ts +39 -8
- package/templates/v4/latest/integration/ListReportJourney.js +8 -0
- package/templates/v4/latest/integration/ListReportJourney.ts +8 -0
- package/templates/v4/latest/integration/ObjectPageJourney.js +55 -7
- package/templates/v4/latest/integration/ObjectPageJourney.ts +58 -8
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
2
|
import type { Manifest } from '@sap-ux/project-access';
|
|
3
|
-
import type { WriteContext, OPAGenerationOptions } from './types.js';
|
|
3
|
+
import type { AppFeatures, WriteContext, OPAGenerationOptions } from './types.js';
|
|
4
4
|
import type { Logger } from '@sap-ux/logger';
|
|
5
|
+
/**
|
|
6
|
+
* Removes action tests the target template bucket cannot render, so journeys omit them instead of
|
|
7
|
+
* emitting assertions that fail on older runtimes:
|
|
8
|
+
* - custom (manifest-declared) actions: rendered only by the `latest` bucket.
|
|
9
|
+
* - menu (drop-down) actions: rendered by `1.148` and `latest`; the `1.84` bucket has no menu template.
|
|
10
|
+
*
|
|
11
|
+
* @param appFeatures - the extracted app feature data (mutated in place)
|
|
12
|
+
* @param templateUi5Version - the selected template bucket ('1.84' / '1.148' / 'latest')
|
|
13
|
+
*/
|
|
14
|
+
export declare function removeUnsupportedActions(appFeatures: AppFeatures, templateUi5Version: string): void;
|
|
5
15
|
/**
|
|
6
16
|
* Generate OPA test files for a Fiori elements for OData V4 application.
|
|
7
17
|
* Note: this can potentially overwrite existing files in the webapp/test folder.
|
|
@@ -33,6 +33,36 @@ function getTemplateUi5Version(ui5Version) {
|
|
|
33
33
|
}
|
|
34
34
|
return V4_TEMPLATE_1_84;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Removes action tests the target template bucket cannot render, so journeys omit them instead of
|
|
38
|
+
* emitting assertions that fail on older runtimes:
|
|
39
|
+
* - custom (manifest-declared) actions: rendered only by the `latest` bucket.
|
|
40
|
+
* - menu (drop-down) actions: rendered by `1.148` and `latest`; the `1.84` bucket has no menu template.
|
|
41
|
+
*
|
|
42
|
+
* @param appFeatures - the extracted app feature data (mutated in place)
|
|
43
|
+
* @param templateUi5Version - the selected template bucket ('1.84' / '1.148' / 'latest')
|
|
44
|
+
*/
|
|
45
|
+
export function removeUnsupportedActions(appFeatures, templateUi5Version) {
|
|
46
|
+
const stripCustom = templateUi5Version !== V4_TEMPLATE_LATEST;
|
|
47
|
+
const stripMenu = templateUi5Version === V4_TEMPLATE_1_84;
|
|
48
|
+
if (!stripCustom && !stripMenu) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const keep = (action) => !(stripCustom && action.custom) && !(stripMenu && action.menuType);
|
|
52
|
+
if (appFeatures.listReport?.toolBarActions) {
|
|
53
|
+
appFeatures.listReport.toolBarActions = appFeatures.listReport.toolBarActions.filter(keep);
|
|
54
|
+
}
|
|
55
|
+
appFeatures.objectPages?.forEach((objectPage) => {
|
|
56
|
+
if (objectPage.headerActions) {
|
|
57
|
+
objectPage.headerActions = objectPage.headerActions.filter(keep);
|
|
58
|
+
}
|
|
59
|
+
objectPage.bodySections?.forEach((section) => {
|
|
60
|
+
if (section.actions) {
|
|
61
|
+
section.actions = section.actions.filter(keep);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
36
66
|
/**
|
|
37
67
|
* Generate OPA test files for a Fiori elements for OData V4 application.
|
|
38
68
|
* Note: this can potentially overwrite existing files in the webapp/test folder.
|
|
@@ -60,6 +90,9 @@ export async function generateOPAFiles(basePath, options, metadata, fs, log, sta
|
|
|
60
90
|
const testOutDirPath = join(await getWebappPath(basePath), 'test');
|
|
61
91
|
// Access ux-specification to get feature data for OPA test generation
|
|
62
92
|
const appFeatures = await getAppFeatures(basePath, editor, log, metadata, manifest);
|
|
93
|
+
// Drop action tests the target template bucket cannot render (custom actions: latest only;
|
|
94
|
+
// menu actions: 1.148 and latest).
|
|
95
|
+
removeUnsupportedActions(appFeatures, templateUi5Version);
|
|
63
96
|
// OPA Journey file
|
|
64
97
|
const startPages = config.pages.filter((page) => page.isStartup).map((page) => page.targetKey);
|
|
65
98
|
const LROP = findLROP(config.pages, manifest);
|
package/dist/types.d.ts
CHANGED
|
@@ -235,6 +235,38 @@ export interface ActionButtonState {
|
|
|
235
235
|
* Populated for both List Report and Object Page actions extracted via metadata.
|
|
236
236
|
*/
|
|
237
237
|
unbound?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Set when this entry is a menu (drop-down) button rather than a single action.
|
|
240
|
+
* `menuActions` then holds the individual actions inside the menu.
|
|
241
|
+
*/
|
|
242
|
+
menuType?: 'Annotation' | 'CustomMenu';
|
|
243
|
+
/**
|
|
244
|
+
* The individual actions contained in a menu. Only set when `menuType` is present.
|
|
245
|
+
* Menu items are matched at runtime by label (the FE test API `iCheckMenuAction` /
|
|
246
|
+
* `iExecuteMenuAction` match menu entries by their rendered text, not by a stable id).
|
|
247
|
+
*/
|
|
248
|
+
menuActions?: MenuActionState[];
|
|
249
|
+
/**
|
|
250
|
+
* Set for custom (manifest-declared) actions that have no OData `DataFieldForAction` counterpart.
|
|
251
|
+
* These are matched at runtime by their rendered label, so the writer emits the label-string form
|
|
252
|
+
* `iCheckAction("<label>")` instead of the `{ service, action, unbound }` object form.
|
|
253
|
+
*/
|
|
254
|
+
custom?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Set when `label` is still an unresolved i18n placeholder (the app i18n bundle had no matching key).
|
|
257
|
+
* The writer emits a follow-up marker comment so the developer can fix the assertion.
|
|
258
|
+
*/
|
|
259
|
+
labelUnresolved?: boolean;
|
|
260
|
+
}
|
|
261
|
+
export interface MenuActionState {
|
|
262
|
+
label: string;
|
|
263
|
+
visible: boolean;
|
|
264
|
+
service?: string;
|
|
265
|
+
action?: string;
|
|
266
|
+
unbound?: boolean;
|
|
267
|
+
enabled?: boolean | 'dynamic';
|
|
268
|
+
dynamicPath?: string;
|
|
269
|
+
labelUnresolved?: boolean;
|
|
238
270
|
}
|
|
239
271
|
export type FPMFeatures = {
|
|
240
272
|
name?: string;
|
|
@@ -29,13 +29,14 @@ export declare function extractActionMethodName(actionName: string): string;
|
|
|
29
29
|
export declare function findOperationAvailableAnnotation(metadata: ConvertedMetadata, actionMethodName: string): OperationAvailableWithPaths | undefined;
|
|
30
30
|
/**
|
|
31
31
|
* Analyzes Core.OperationAvailable annotation to determine action availability.
|
|
32
|
-
*
|
|
32
|
+
* Bound actions require a row/context selection to be invoked, so they are disabled by default
|
|
33
|
+
* when no annotation is present.
|
|
33
34
|
*
|
|
34
35
|
* @param operationAvailable The OperationAvailable annotation value
|
|
35
|
-
* @param
|
|
36
|
+
* @param requiresSelection Whether the action needs a selected context to be enabled (true for any bound action)
|
|
36
37
|
* @returns Object containing enabled state and optional dynamic path
|
|
37
38
|
*/
|
|
38
|
-
export declare function analyzeOperationAvailability(operationAvailable: OperationAvailableWithPaths | undefined,
|
|
39
|
+
export declare function analyzeOperationAvailability(operationAvailable: OperationAvailableWithPaths | undefined, requiresSelection?: boolean): {
|
|
39
40
|
enabled: boolean | 'dynamic';
|
|
40
41
|
dynamicPath?: string;
|
|
41
42
|
};
|
|
@@ -48,15 +48,16 @@ export function findOperationAvailableAnnotation(metadata, actionMethodName) {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Analyzes Core.OperationAvailable annotation to determine action availability.
|
|
51
|
-
*
|
|
51
|
+
* Bound actions require a row/context selection to be invoked, so they are disabled by default
|
|
52
|
+
* when no annotation is present.
|
|
52
53
|
*
|
|
53
54
|
* @param operationAvailable The OperationAvailable annotation value
|
|
54
|
-
* @param
|
|
55
|
+
* @param requiresSelection Whether the action needs a selected context to be enabled (true for any bound action)
|
|
55
56
|
* @returns Object containing enabled state and optional dynamic path
|
|
56
57
|
*/
|
|
57
|
-
export function analyzeOperationAvailability(operationAvailable,
|
|
58
|
+
export function analyzeOperationAvailability(operationAvailable, requiresSelection) {
|
|
58
59
|
if (operationAvailable === undefined) {
|
|
59
|
-
return { enabled: !
|
|
60
|
+
return { enabled: !requiresSelection };
|
|
60
61
|
}
|
|
61
62
|
if (typeof operationAvailable === 'boolean') {
|
|
62
63
|
return { enabled: operationAvailable };
|
|
@@ -98,17 +99,15 @@ export function buildActionButtonState(item, metadata) {
|
|
|
98
99
|
const actionString = item.Action || '';
|
|
99
100
|
const actionMethod = extractActionMethodName(actionString);
|
|
100
101
|
const operationAvailable = findOperationAvailableAnnotation(metadata, actionMethod);
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
const isEntityBound = actionTarget?.isBound === true && actionTarget?.parameters?.[0]?.isCollection !== true;
|
|
106
|
-
const { enabled, dynamicPath } = analyzeOperationAvailability(operationAvailable, isEntityBound);
|
|
102
|
+
// Any bound action (single- or collection-bound) requires a selected context to be invoked, so
|
|
103
|
+
// it is disabled by default (no row selected)
|
|
104
|
+
const isBound = item.ActionTarget?.isBound === true;
|
|
105
|
+
const { enabled, dynamicPath } = analyzeOperationAvailability(operationAvailable, isBound);
|
|
107
106
|
return {
|
|
108
107
|
label: item.Label || '',
|
|
109
108
|
action: actionMethod,
|
|
110
109
|
service: metadata.namespace ?? '',
|
|
111
|
-
unbound: !
|
|
110
|
+
unbound: !isBound,
|
|
112
111
|
visible: true,
|
|
113
112
|
enabled,
|
|
114
113
|
dynamicPath,
|
|
@@ -135,15 +134,14 @@ export function buildActionStateFromSpecModelKey(aggregationKey, label, converte
|
|
|
135
134
|
const actionFullName = keyParts[1]; // "namespace.Method"
|
|
136
135
|
const actionMethod = extractActionMethodName(actionFullName);
|
|
137
136
|
const actionDefinition = convertedMetadata.actions?.find((action) => action.name === actionMethod || action.fullyQualifiedName?.includes(`.${actionMethod}(`));
|
|
138
|
-
const
|
|
139
|
-
const isEntityBound = actionDefinition?.isBound === true && firstParameter?.isCollection !== true;
|
|
137
|
+
const isBound = actionDefinition?.isBound === true;
|
|
140
138
|
const operationAvailable = findOperationAvailableAnnotation(convertedMetadata, actionMethod);
|
|
141
|
-
const { enabled, dynamicPath } = analyzeOperationAvailability(operationAvailable,
|
|
139
|
+
const { enabled, dynamicPath } = analyzeOperationAvailability(operationAvailable, isBound);
|
|
142
140
|
return {
|
|
143
141
|
label: label ?? '',
|
|
144
142
|
action: actionMethod,
|
|
145
143
|
service: schemaNamespace,
|
|
146
|
-
unbound: !
|
|
144
|
+
unbound: !isBound,
|
|
147
145
|
visible: true,
|
|
148
146
|
enabled,
|
|
149
147
|
dynamicPath
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves an action/menu label that may be an i18n placeholder (`{i18n>key}` or `{{key}}`) to its
|
|
3
|
+
* translated text. `unresolved` is true when a placeholder had no matching key in the app i18n bundle,
|
|
4
|
+
* so the writer can emit a follow-up marker comment for the developer.
|
|
5
|
+
*/
|
|
6
|
+
export type I18nLabelResolver = (label: string | undefined) => {
|
|
7
|
+
label: string;
|
|
8
|
+
unresolved: boolean;
|
|
9
|
+
};
|
|
10
|
+
interface I18nEntryLike {
|
|
11
|
+
value?: {
|
|
12
|
+
value?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
type I18nBundleLike = Record<string, I18nEntryLike[]>;
|
|
16
|
+
interface I18nBundlesLike {
|
|
17
|
+
'sap.app'?: I18nBundleLike;
|
|
18
|
+
models?: Record<string, I18nBundleLike>;
|
|
19
|
+
service?: I18nBundleLike;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Passes labels through unchanged. Used when the app i18n bundle is unavailable.
|
|
23
|
+
*
|
|
24
|
+
* @param label - the raw label
|
|
25
|
+
* @returns the label untouched, never flagged as unresolved
|
|
26
|
+
*/
|
|
27
|
+
export declare const passthroughLabelResolver: I18nLabelResolver;
|
|
28
|
+
/**
|
|
29
|
+
* Builds a label resolver over the app i18n bundles. Model bundles (where `{i18n>…}` placeholders
|
|
30
|
+
* resolve) take priority over the `sap.app` bundle on key collisions.
|
|
31
|
+
*
|
|
32
|
+
* @param bundles - i18n bundles from `ApplicationAccess.getI18nBundles()`
|
|
33
|
+
* @returns a resolver that replaces `{i18n>key}` / `{{key}}` placeholders with their translated text
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildI18nLabelResolver(bundles: I18nBundlesLike): I18nLabelResolver;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=i18nUtils.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passes labels through unchanged. Used when the app i18n bundle is unavailable.
|
|
3
|
+
*
|
|
4
|
+
* @param label - the raw label
|
|
5
|
+
* @returns the label untouched, never flagged as unresolved
|
|
6
|
+
*/
|
|
7
|
+
export const passthroughLabelResolver = (label) => ({ label: label ?? '', unresolved: false });
|
|
8
|
+
/**
|
|
9
|
+
* Builds a label resolver over the app i18n bundles. Model bundles (where `{i18n>…}` placeholders
|
|
10
|
+
* resolve) take priority over the `sap.app` bundle on key collisions.
|
|
11
|
+
*
|
|
12
|
+
* @param bundles - i18n bundles from `ApplicationAccess.getI18nBundles()`
|
|
13
|
+
* @returns a resolver that replaces `{i18n>key}` / `{{key}}` placeholders with their translated text
|
|
14
|
+
*/
|
|
15
|
+
export function buildI18nLabelResolver(bundles) {
|
|
16
|
+
const lookup = new Map();
|
|
17
|
+
const addBundle = (bundle) => {
|
|
18
|
+
for (const key of Object.keys(bundle ?? {})) {
|
|
19
|
+
const text = bundle?.[key]?.[0]?.value?.value;
|
|
20
|
+
if (text !== undefined && !lookup.has(key)) {
|
|
21
|
+
lookup.set(key, text);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
for (const modelKey of Object.keys(bundles.models ?? {})) {
|
|
26
|
+
addBundle(bundles.models?.[modelKey]);
|
|
27
|
+
}
|
|
28
|
+
addBundle(bundles['sap.app']);
|
|
29
|
+
return (label) => {
|
|
30
|
+
const raw = (label ?? '').trim();
|
|
31
|
+
const match = /^\{i18n>(.+)\}$/.exec(raw) ?? /^\{\{(.+)\}\}$/.exec(raw);
|
|
32
|
+
if (!match?.[1]) {
|
|
33
|
+
return { label: raw, unresolved: false };
|
|
34
|
+
}
|
|
35
|
+
const resolved = lookup.get(match[1]);
|
|
36
|
+
return resolved !== undefined ? { label: resolved, unresolved: false } : { label: raw, unresolved: true };
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=i18nUtils.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '@sap-ux/logger';
|
|
2
2
|
import type { TreeAggregations, TreeModel } from '@sap/ux-specification/dist/types/src/parser/index.js';
|
|
3
3
|
import type { ActionButtonsResult, ActionButtonState, ButtonState, FEV4ManifestTarget, ListReportFeatures } from '../types.js';
|
|
4
|
+
import { type I18nLabelResolver } from './i18nUtils.js';
|
|
4
5
|
import type { ConvertedMetadata } from '@sap-ux/vocabularies-types';
|
|
5
6
|
import { safeCheckButtonVisibility } from './actionUtils.js';
|
|
6
7
|
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application.js';
|
|
@@ -61,9 +62,10 @@ export declare function isALPFromManifest(manifest: Manifest, targetKey?: string
|
|
|
61
62
|
* @param log - optional logger instance
|
|
62
63
|
* @param metadata - optional metadata for the OPA test generation
|
|
63
64
|
* @param manifest - optional application manifest, used to detect ALP configuration
|
|
65
|
+
* @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
|
|
64
66
|
* @returns feature data extracted from the List Report page model
|
|
65
67
|
*/
|
|
66
|
-
export declare function getListReportFeatures(listReportPage: PageWithModelV4, log?: Logger, metadata?: string, manifest?: Manifest): ListReportFeatures;
|
|
68
|
+
export declare function getListReportFeatures(listReportPage: PageWithModelV4, log?: Logger, metadata?: string, manifest?: Manifest, resolveLabel?: I18nLabelResolver): ListReportFeatures;
|
|
67
69
|
/**
|
|
68
70
|
* Retrieves toolbar action definitions from the given tree model.
|
|
69
71
|
*
|
|
@@ -71,6 +73,14 @@ export declare function getListReportFeatures(listReportPage: PageWithModelV4, l
|
|
|
71
73
|
* @returns The toolbar actions aggregation object.
|
|
72
74
|
*/
|
|
73
75
|
export declare function getToolBarActions(pageModel: TreeModel): TreeAggregations;
|
|
76
|
+
/**
|
|
77
|
+
* Extracts custom (manifest-declared) toolbar actions from the List Report table toolbar.
|
|
78
|
+
*
|
|
79
|
+
* @param pageModel - the tree model containing the table toolbar definitions
|
|
80
|
+
* @param resolveLabel - resolver for i18n placeholder labels
|
|
81
|
+
* @returns array of custom toolbar action button states
|
|
82
|
+
*/
|
|
83
|
+
export declare function extractCustomToolBarActions(pageModel: TreeModel, resolveLabel: I18nLabelResolver): ActionButtonState[];
|
|
74
84
|
/**
|
|
75
85
|
* Retrieves filter field names from the page model using ux-specification.
|
|
76
86
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getFilterFields, getSelectionFieldItems, getSelectionFieldItemsWithLabels, getTableColumnData, getAggregations } from './modelUtils.js';
|
|
2
|
+
import { passthroughLabelResolver } from './i18nUtils.js';
|
|
2
3
|
import { extractContactCardColumnsFromNode, resolvePrimaryTableNode } from './tableUtils.js';
|
|
3
4
|
import { parse } from '@sap-ux/edmx-parser';
|
|
4
5
|
import { convert } from '@sap-ux/annotation-converter';
|
|
@@ -90,9 +91,10 @@ export function isALPFromManifest(manifest, targetKey) {
|
|
|
90
91
|
* @param log - optional logger instance
|
|
91
92
|
* @param metadata - optional metadata for the OPA test generation
|
|
92
93
|
* @param manifest - optional application manifest, used to detect ALP configuration
|
|
94
|
+
* @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
|
|
93
95
|
* @returns feature data extracted from the List Report page model
|
|
94
96
|
*/
|
|
95
|
-
export function getListReportFeatures(listReportPage, log, metadata, manifest) {
|
|
97
|
+
export function getListReportFeatures(listReportPage, log, metadata, manifest, resolveLabel = passthroughLabelResolver) {
|
|
96
98
|
const toolbarActions = getToolBarActionNames(listReportPage.model, log);
|
|
97
99
|
const filterFieldEntries = getFilterFieldItems(listReportPage.model, log);
|
|
98
100
|
const customFilterFieldProperties = getCustomFilterFieldProperties(manifest, listReportPage.name);
|
|
@@ -112,6 +114,10 @@ export function getListReportFeatures(listReportPage, log, metadata, manifest) {
|
|
|
112
114
|
log?.debug(`Failed to parse metadata: ${error instanceof Error ? error.message : String(error)}`);
|
|
113
115
|
}
|
|
114
116
|
}
|
|
117
|
+
// Custom (manifest-declared) toolbar actions have no OData counterpart and are matched by label.
|
|
118
|
+
// extractCustomToolBarActions filters strictly on actionType === 'Custom', so annotation-backed
|
|
119
|
+
// actions (already captured via safeCheckActionButtonStates) are never duplicated here.
|
|
120
|
+
toolBarActions = toolBarActions.concat(extractCustomToolBarActions(listReportPage.model, resolveLabel));
|
|
115
121
|
// Custom filter fields are matched by rendered label, so resolve unresolved i18n
|
|
116
122
|
// placeholders via the property's OData `@Common.Label`.
|
|
117
123
|
const filterBarItems = filterFieldEntries.map((entry) => {
|
|
@@ -169,6 +175,35 @@ export function getToolBarActions(pageModel) {
|
|
|
169
175
|
const actionAggregations = getAggregations(actions);
|
|
170
176
|
return actionAggregations;
|
|
171
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Extracts custom (manifest-declared) toolbar actions from the List Report table toolbar.
|
|
180
|
+
*
|
|
181
|
+
* @param pageModel - the tree model containing the table toolbar definitions
|
|
182
|
+
* @param resolveLabel - resolver for i18n placeholder labels
|
|
183
|
+
* @returns array of custom toolbar action button states
|
|
184
|
+
*/
|
|
185
|
+
export function extractCustomToolBarActions(pageModel, resolveLabel) {
|
|
186
|
+
const actionAggregations = getToolBarActions(pageModel);
|
|
187
|
+
const customActions = [];
|
|
188
|
+
for (const key of Object.keys(actionAggregations ?? {})) {
|
|
189
|
+
const item = actionAggregations[key];
|
|
190
|
+
if (item?.schema?.actionType !== 'Custom') {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const { label, unresolved } = resolveLabel(item.description);
|
|
194
|
+
if (label) {
|
|
195
|
+
customActions.push({
|
|
196
|
+
label,
|
|
197
|
+
action: '',
|
|
198
|
+
visible: true,
|
|
199
|
+
enabled: true,
|
|
200
|
+
custom: true,
|
|
201
|
+
labelUnresolved: unresolved || undefined
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return customActions;
|
|
206
|
+
}
|
|
172
207
|
/**
|
|
173
208
|
* Retrieves filter field names from the page model using ux-specification.
|
|
174
209
|
*
|
|
@@ -12,7 +12,10 @@ export interface AggregationItem extends TreeAggregation {
|
|
|
12
12
|
value: string;
|
|
13
13
|
}[];
|
|
14
14
|
dataType?: string;
|
|
15
|
+
actionType?: string;
|
|
15
16
|
};
|
|
17
|
+
/** Present on action nodes that are menus (drop-downs): 'Annotation' or 'CustomMenu'. */
|
|
18
|
+
menuType?: string;
|
|
16
19
|
}
|
|
17
20
|
export interface FieldItem extends AggregationItem {
|
|
18
21
|
name: string;
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -3,6 +3,24 @@ import { PageTypeV4 } from '@sap/ux-specification/dist/types/src/common/index.js
|
|
|
3
3
|
import { getObjectPageFeatures, getObjectPages } from './objectPageUtils.js';
|
|
4
4
|
import { getFilterFieldNames, getListReportFeatures } from './listReportUtils.js';
|
|
5
5
|
import { extractTableColumnsFromNode } from './tableUtils.js';
|
|
6
|
+
import { buildI18nLabelResolver, passthroughLabelResolver } from './i18nUtils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Builds the i18n label resolver from the app bundles, falling back to a passthrough resolver when
|
|
9
|
+
* the bundle can't be read (labels are then emitted unresolved).
|
|
10
|
+
*
|
|
11
|
+
* @param appAccess - application access used to read the i18n bundles
|
|
12
|
+
* @param log - optional logger instance
|
|
13
|
+
* @returns a resolver for `{i18n>key}` placeholder labels
|
|
14
|
+
*/
|
|
15
|
+
async function buildLabelResolver(appAccess, log) {
|
|
16
|
+
try {
|
|
17
|
+
return buildI18nLabelResolver(await appAccess.getI18nBundles());
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
log?.debug?.(`Unable to read the app i18n bundle; i18n action labels will be emitted unresolved. ${error instanceof Error ? error.message : String(error)}`);
|
|
21
|
+
return passthroughLabelResolver;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
6
24
|
/**
|
|
7
25
|
* Gets app features from the application model using ux-specification.
|
|
8
26
|
*
|
|
@@ -19,6 +37,7 @@ export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
|
19
37
|
let objectPages = null;
|
|
20
38
|
let fpmPage = null;
|
|
21
39
|
let projectMetadata = metadata;
|
|
40
|
+
let resolveLabel;
|
|
22
41
|
// Read application model to extract control information needed for test generation
|
|
23
42
|
// specification and readApp might not be available due to specification version, fail gracefully
|
|
24
43
|
try {
|
|
@@ -40,6 +59,7 @@ export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
|
40
59
|
projectMetadata = fs?.read(metadataPath);
|
|
41
60
|
}
|
|
42
61
|
}
|
|
62
|
+
resolveLabel = await buildLabelResolver(appAccess, log);
|
|
43
63
|
listReportPage = appModel?.applicationModel ? getListReportPage(appModel.applicationModel) : listReportPage;
|
|
44
64
|
objectPages = appModel?.applicationModel ? getObjectPages(appModel.applicationModel) : objectPages;
|
|
45
65
|
fpmPage = appModel?.applicationModel ? getFPMPage(appModel.applicationModel) : fpmPage;
|
|
@@ -56,10 +76,10 @@ export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
|
56
76
|
// attempt to get individual feature data
|
|
57
77
|
try {
|
|
58
78
|
if (listReportPage) {
|
|
59
|
-
featureData.listReport = getListReportFeatures(listReportPage, log, projectMetadata, manifest);
|
|
79
|
+
featureData.listReport = getListReportFeatures(listReportPage, log, projectMetadata, manifest, resolveLabel);
|
|
60
80
|
}
|
|
61
81
|
if (objectPages) {
|
|
62
|
-
featureData.objectPages = await getObjectPageFeatures(objectPages, listReportPage?.name, log, projectMetadata, manifest, listReportPage?.entitySet);
|
|
82
|
+
featureData.objectPages = await getObjectPageFeatures(objectPages, listReportPage?.name, log, projectMetadata, manifest, listReportPage?.entitySet, resolveLabel);
|
|
63
83
|
}
|
|
64
84
|
if (fpmPage) {
|
|
65
85
|
featureData.fpm = getFPMFeatures(fpmPage, log);
|
|
@@ -3,6 +3,7 @@ import type { Manifest } from '@sap-ux/project-access';
|
|
|
3
3
|
import type { ApplicationModel } from '@sap/ux-specification/dist/types/src/parser/index.js';
|
|
4
4
|
import type { ObjectPageFeatures } from '../types.js';
|
|
5
5
|
import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parser/application.js';
|
|
6
|
+
import { type I18nLabelResolver } from './i18nUtils.js';
|
|
6
7
|
/**
|
|
7
8
|
* Extracts feature data for object pages from the application model.
|
|
8
9
|
*
|
|
@@ -11,10 +12,11 @@ import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parse
|
|
|
11
12
|
* @param log - optional logger instance
|
|
12
13
|
* @param metadata - optional metadata for the OPA test generation
|
|
13
14
|
* @param manifest - optional application manifest, used to resolve the parent List Report's default table tab
|
|
14
|
-
* @param listReportEntitySet
|
|
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)
|
|
15
17
|
* @returns a record of object page feature data
|
|
16
18
|
*/
|
|
17
|
-
export declare function getObjectPageFeatures(objectPages: PageWithModelV4[], listReportPageKey?: string, log?: Logger, metadata?: string, manifest?: Manifest, listReportEntitySet?: string): Promise<ObjectPageFeatures[]>;
|
|
19
|
+
export declare function getObjectPageFeatures(objectPages: PageWithModelV4[], listReportPageKey?: string, log?: Logger, metadata?: string, manifest?: Manifest, listReportEntitySet?: string, resolveLabel?: I18nLabelResolver): Promise<ObjectPageFeatures[]>;
|
|
18
20
|
/**
|
|
19
21
|
* Retrieves all Object Page definitions from the given application model, as long as the page is reachable via standard navigation routes.
|
|
20
22
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getAggregations, parseDataFieldForAnnotationName } from './modelUtils.js';
|
|
2
|
+
import { passthroughLabelResolver } from './i18nUtils.js';
|
|
2
3
|
import { extractContactCardColumnsFromNode, extractTableColumnsFromNode } from './tableUtils.js';
|
|
3
4
|
import { PageTypeV4 } from '@sap/ux-specification/dist/types/src/common/page.js';
|
|
4
5
|
import { parse } from '@sap-ux/edmx-parser';
|
|
@@ -13,10 +14,11 @@ import { getListReportViews } from './listReportUtils.js';
|
|
|
13
14
|
* @param log - optional logger instance
|
|
14
15
|
* @param metadata - optional metadata for the OPA test generation
|
|
15
16
|
* @param manifest - optional application manifest, used to resolve the parent List Report's default table tab
|
|
16
|
-
* @param listReportEntitySet
|
|
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)
|
|
17
19
|
* @returns a record of object page feature data
|
|
18
20
|
*/
|
|
19
|
-
export async function getObjectPageFeatures(objectPages, listReportPageKey, log, metadata, manifest, listReportEntitySet) {
|
|
21
|
+
export async function getObjectPageFeatures(objectPages, listReportPageKey, log, metadata, manifest, listReportEntitySet, resolveLabel = passthroughLabelResolver) {
|
|
20
22
|
const objectPageFeatures = [];
|
|
21
23
|
if (!objectPages || objectPages.length === 0) {
|
|
22
24
|
log?.warn('Object Pages not found in application model. Dynamic tests will not be generated for Object Pages.');
|
|
@@ -37,10 +39,10 @@ export async function getObjectPageFeatures(objectPages, listReportPageKey, log,
|
|
|
37
39
|
// extract header sections (facets)
|
|
38
40
|
pageFeatureData.headerSections = extractObjectPageHeaderSectionsData(objectPage);
|
|
39
41
|
// extract body sections (includes section-level actions and standard create/delete buttons)
|
|
40
|
-
pageFeatureData.bodySections = extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log);
|
|
42
|
+
pageFeatureData.bodySections = extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log, resolveLabel);
|
|
41
43
|
// extract header-level actions
|
|
42
44
|
pageFeatureData.headerActions = convertedMetadata
|
|
43
|
-
? extractHeaderActions(objectPage, convertedMetadata, schemaNamespace)
|
|
45
|
+
? extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, resolveLabel)
|
|
44
46
|
: [];
|
|
45
47
|
// determine edit button visibility from UpdateRestrictions on the OP entity set
|
|
46
48
|
if (metadata && objectPage.entitySet) {
|
|
@@ -192,9 +194,10 @@ function extractObjectPageHeaderSectionsData(objectPage) {
|
|
|
192
194
|
* @param schemaNamespace - optional OData schema namespace used as service identifier in action assertions
|
|
193
195
|
* @param metadata - optional raw metadata XML for resolving standard button visibility (Create/Delete)
|
|
194
196
|
* @param log - optional logger instance
|
|
197
|
+
* @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
|
|
195
198
|
* @returns body sections data including sub-sections
|
|
196
199
|
*/
|
|
197
|
-
function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log) {
|
|
200
|
+
function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log, resolveLabel = passthroughLabelResolver) {
|
|
198
201
|
const bodySections = [];
|
|
199
202
|
if (objectPage.model) {
|
|
200
203
|
const sectionsAggregation = getAggregations(objectPage.model.root)['sections'];
|
|
@@ -222,7 +225,7 @@ function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schema
|
|
|
222
225
|
contactCardColumns,
|
|
223
226
|
subSections,
|
|
224
227
|
actions: !section.custom && convertedMetadata && schemaNamespace
|
|
225
|
-
? extractSectionActions(section, convertedMetadata, schemaNamespace)
|
|
228
|
+
? extractSectionActions(section, convertedMetadata, schemaNamespace, resolveLabel)
|
|
226
229
|
: []
|
|
227
230
|
};
|
|
228
231
|
// For table sections, resolve Create/Delete visibility from target entity set
|
|
@@ -239,15 +242,127 @@ function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schema
|
|
|
239
242
|
}
|
|
240
243
|
return bodySections;
|
|
241
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Determines whether an action aggregation entry is a menu (drop-down) grouping several actions.
|
|
247
|
+
*
|
|
248
|
+
* @param item - action aggregation entry from the spec model
|
|
249
|
+
* @returns true if the entry represents an annotation menu or a manifest (custom) menu
|
|
250
|
+
*/
|
|
251
|
+
function isMenuActionItem(item) {
|
|
252
|
+
return item.menuType !== undefined || item.schema?.dataType === 'DataFieldForActionGroup';
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Builds the individual menu item states contained in a menu action node.
|
|
256
|
+
*
|
|
257
|
+
* @param menuItem - the menu container aggregation entry
|
|
258
|
+
* @param convertedMetadata - converted OData metadata for resolving annotation actions
|
|
259
|
+
* @param schemaNamespace - OData schema namespace used as service identifier
|
|
260
|
+
* @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
|
|
261
|
+
* @returns array of menu item states
|
|
262
|
+
*/
|
|
263
|
+
function buildMenuItemStates(menuItem, convertedMetadata, schemaNamespace, resolveLabel) {
|
|
264
|
+
const innerContainer = getAggregations(menuItem)['actions'];
|
|
265
|
+
if (!innerContainer) {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
const innerEntries = getAggregations(innerContainer);
|
|
269
|
+
return Object.entries(innerEntries).map(([childKey, child]) => {
|
|
270
|
+
const annotationState = buildActionStateFromSpecModelKey(childKey, child.description, convertedMetadata, schemaNamespace);
|
|
271
|
+
if (annotationState) {
|
|
272
|
+
return {
|
|
273
|
+
label: annotationState.label,
|
|
274
|
+
visible: annotationState.visible,
|
|
275
|
+
service: annotationState.service,
|
|
276
|
+
action: annotationState.action,
|
|
277
|
+
unbound: annotationState.unbound,
|
|
278
|
+
enabled: annotationState.enabled,
|
|
279
|
+
dynamicPath: annotationState.dynamicPath
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const { label, unresolved } = resolveLabel(child.description);
|
|
283
|
+
return { label, visible: true, labelUnresolved: unresolved || undefined };
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Builds a menu action button state from a menu aggregation entry (annotation or custom menu).
|
|
288
|
+
*
|
|
289
|
+
* @param menuItem - the menu container aggregation entry
|
|
290
|
+
* @param convertedMetadata - converted OData metadata for resolving annotation actions
|
|
291
|
+
* @param schemaNamespace - OData schema namespace used as service identifier
|
|
292
|
+
* @param resolveLabel - resolver for i18n placeholder labels
|
|
293
|
+
* @returns the menu action button state
|
|
294
|
+
*/
|
|
295
|
+
function buildMenuActionState(menuItem, convertedMetadata, schemaNamespace, resolveLabel) {
|
|
296
|
+
const menuType = menuItem.menuType === 'Annotation' || menuItem.schema?.dataType === 'DataFieldForActionGroup'
|
|
297
|
+
? 'Annotation'
|
|
298
|
+
: 'CustomMenu';
|
|
299
|
+
const { label, unresolved } = resolveLabel(menuItem.description);
|
|
300
|
+
return {
|
|
301
|
+
label,
|
|
302
|
+
action: '',
|
|
303
|
+
visible: true,
|
|
304
|
+
enabled: true,
|
|
305
|
+
menuType,
|
|
306
|
+
labelUnresolved: unresolved || undefined,
|
|
307
|
+
menuActions: buildMenuItemStates(menuItem, convertedMetadata, schemaNamespace, resolveLabel)
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Builds an action button state for a custom (manifest-declared) action that has no OData
|
|
312
|
+
* `DataFieldForAction` counterpart. These are matched at runtime by their rendered label.
|
|
313
|
+
*
|
|
314
|
+
* @param item - the custom action aggregation entry
|
|
315
|
+
* @param resolveLabel - resolver for i18n placeholder labels
|
|
316
|
+
* @returns the custom action button state, or undefined if it has no usable label
|
|
317
|
+
*/
|
|
318
|
+
function buildCustomActionState(item, resolveLabel) {
|
|
319
|
+
const { label, unresolved } = resolveLabel(item.description);
|
|
320
|
+
if (!label) {
|
|
321
|
+
return undefined;
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
label,
|
|
325
|
+
action: '',
|
|
326
|
+
visible: true,
|
|
327
|
+
enabled: true,
|
|
328
|
+
custom: true,
|
|
329
|
+
labelUnresolved: unresolved || undefined
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Builds an action button state for a single action or a menu from a spec model aggregation entry.
|
|
334
|
+
*
|
|
335
|
+
* @param key - aggregation key
|
|
336
|
+
* @param item - aggregation entry
|
|
337
|
+
* @param convertedMetadata - converted OData metadata
|
|
338
|
+
* @param schemaNamespace - OData schema namespace used as service identifier
|
|
339
|
+
* @param resolveLabel - resolver for i18n placeholder labels
|
|
340
|
+
* @returns the action or menu button state, or undefined if the entry is neither
|
|
341
|
+
*/
|
|
342
|
+
function buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel) {
|
|
343
|
+
if (isMenuActionItem(item)) {
|
|
344
|
+
return buildMenuActionState(item, convertedMetadata, schemaNamespace, resolveLabel);
|
|
345
|
+
}
|
|
346
|
+
const odataState = buildActionStateFromSpecModelKey(key, item.description, convertedMetadata, schemaNamespace);
|
|
347
|
+
if (odataState) {
|
|
348
|
+
return odataState;
|
|
349
|
+
}
|
|
350
|
+
// Custom (manifest-declared) actions have no OData action; the spec model tags them `actionType: 'Custom'`.
|
|
351
|
+
if (item.schema?.actionType === 'Custom') {
|
|
352
|
+
return buildCustomActionState(item, resolveLabel);
|
|
353
|
+
}
|
|
354
|
+
return undefined;
|
|
355
|
+
}
|
|
242
356
|
/**
|
|
243
357
|
* Extracts header-level action button states from an object page model.
|
|
244
358
|
*
|
|
245
359
|
* @param objectPage - object page from the application model
|
|
246
360
|
* @param convertedMetadata - converted OData metadata for resolving action availability
|
|
247
361
|
* @param schemaNamespace - OData schema namespace used as service identifier in action assertions
|
|
362
|
+
* @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
|
|
248
363
|
* @returns array of action button states for the header toolbar
|
|
249
364
|
*/
|
|
250
|
-
function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace) {
|
|
365
|
+
function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace, resolveLabel) {
|
|
251
366
|
if (!objectPage.model) {
|
|
252
367
|
return [];
|
|
253
368
|
}
|
|
@@ -255,7 +370,7 @@ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace) {
|
|
|
255
370
|
const actionsAgg = getAggregations(headerAgg)['actions'];
|
|
256
371
|
const actionEntries = getAggregations(actionsAgg);
|
|
257
372
|
return Object.entries(actionEntries)
|
|
258
|
-
.map(([key, item]) =>
|
|
373
|
+
.map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel))
|
|
259
374
|
.filter((actionState) => actionState !== undefined);
|
|
260
375
|
}
|
|
261
376
|
/**
|
|
@@ -265,9 +380,10 @@ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace) {
|
|
|
265
380
|
* @param section - body section entry from the application model
|
|
266
381
|
* @param convertedMetadata - converted OData metadata for resolving action availability
|
|
267
382
|
* @param schemaNamespace - OData schema namespace used as service identifier in action assertions
|
|
383
|
+
* @param resolveLabel - resolver for i18n placeholder labels (`{i18n>key}` → translated text)
|
|
268
384
|
* @returns array of action button states for the section toolbar
|
|
269
385
|
*/
|
|
270
|
-
function extractSectionActions(section, convertedMetadata, schemaNamespace) {
|
|
386
|
+
function extractSectionActions(section, convertedMetadata, schemaNamespace, resolveLabel) {
|
|
271
387
|
let actionsAgg;
|
|
272
388
|
if (isTableSection(section)) {
|
|
273
389
|
const tableAgg = getAggregations(section)['table'];
|
|
@@ -283,7 +399,7 @@ function extractSectionActions(section, convertedMetadata, schemaNamespace) {
|
|
|
283
399
|
}
|
|
284
400
|
const actionEntries = getAggregations(actionsAgg);
|
|
285
401
|
return Object.entries(actionEntries)
|
|
286
|
-
.map(([key, item]) =>
|
|
402
|
+
.map(([key, item]) => buildActionOrMenuState(key, item, convertedMetadata, schemaNamespace, resolveLabel))
|
|
287
403
|
.filter((actionState) => actionState !== undefined);
|
|
288
404
|
}
|
|
289
405
|
/**
|
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.
|
|
4
|
+
"version": "1.9.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"@sap/ux-specification": "1.144.5",
|
|
29
29
|
"@sap-ux/edmx-parser": "0.10.0",
|
|
30
30
|
"@sap-ux/annotation-converter": "0.10.22",
|
|
31
|
-
"@sap-ux/ui5-application-writer": "2.1.
|
|
31
|
+
"@sap-ux/ui5-application-writer": "2.1.4",
|
|
32
32
|
"@sap-ux/logger": "1.0.3",
|
|
33
|
-
"@sap-ux/fiori-generator-shared": "1.2.
|
|
34
|
-
"@sap-ux/
|
|
35
|
-
"@sap-ux/
|
|
33
|
+
"@sap-ux/fiori-generator-shared": "1.2.9",
|
|
34
|
+
"@sap-ux/preview-middleware": "1.2.4",
|
|
35
|
+
"@sap-ux/project-access": "2.1.12"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@jest/globals": "30.4.1",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"rimraf": "6.1.3",
|
|
44
44
|
"fs-extra": "11.3.6",
|
|
45
45
|
"@sap-ux/vocabularies-types": "0.16.0",
|
|
46
|
-
"@sap-ux/jest-file-matchers": "1.0.
|
|
46
|
+
"@sap-ux/jest-file-matchers": "1.0.3"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=22.x"
|
|
@@ -54,12 +54,22 @@ sap.ui.define([
|
|
|
54
54
|
<% } -%>
|
|
55
55
|
<% headerActions.forEach(function(action) { -%>
|
|
56
56
|
<% if (action.visible) { -%>
|
|
57
|
-
<% if (action.
|
|
57
|
+
<% if (action.menuActions) { -%>
|
|
58
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
59
|
+
When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
60
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
61
|
+
<% if (menuAction.visible) { -%>
|
|
62
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
63
|
+
// When.onThe<%- name%>Generated.onHeader().iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
64
|
+
<% } -%>
|
|
65
|
+
<% }); -%>
|
|
66
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
58
67
|
Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
|
|
68
|
+
// When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
59
69
|
<% } else { -%>
|
|
60
70
|
Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
61
|
-
<% } -%>
|
|
62
71
|
// When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
72
|
+
<% } -%>
|
|
63
73
|
<% } -%>
|
|
64
74
|
<% }); -%>
|
|
65
75
|
});
|
|
@@ -94,7 +104,7 @@ sap.ui.define([
|
|
|
94
104
|
<% } -%>
|
|
95
105
|
<% if (bodySections?.length > 0) { -%>
|
|
96
106
|
<% bodySections.forEach(function(section) { -%>
|
|
97
|
-
opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1) { %>When<% } else { %>_When<% } %>, Then) {
|
|
107
|
+
opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1 || (section.actions && section.actions.some(function(a) { return a.visible && a.menuActions; }))) { %>When<% } else { %>_When<% } %>, Then) {
|
|
98
108
|
<% if (bodySections.length > 1) { -%>
|
|
99
109
|
When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
|
|
100
110
|
<% } -%>
|
|
@@ -103,19 +113,39 @@ sap.ui.define([
|
|
|
103
113
|
<% section.actions.forEach(function(action) { -%>
|
|
104
114
|
<% if (action.visible) { -%>
|
|
105
115
|
<% if (section.isTable && section.navigationProperty) { -%>
|
|
106
|
-
<% if (action.
|
|
116
|
+
<% if (action.menuActions) { -%>
|
|
117
|
+
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
118
|
+
When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
119
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
120
|
+
<% if (menuAction.visible) { -%>
|
|
121
|
+
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
122
|
+
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
123
|
+
<% } -%>
|
|
124
|
+
<% }); -%>
|
|
125
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
107
126
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
|
|
127
|
+
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
108
128
|
<% } else { -%>
|
|
109
129
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
110
|
-
<% } -%>
|
|
111
130
|
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
131
|
+
<% } -%>
|
|
112
132
|
<% } else { -%>
|
|
113
|
-
<% if (action.
|
|
133
|
+
<% if (action.menuActions) { -%>
|
|
134
|
+
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
135
|
+
When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
136
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
137
|
+
<% if (menuAction.visible) { -%>
|
|
138
|
+
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
139
|
+
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
140
|
+
<% } -%>
|
|
141
|
+
<% }); -%>
|
|
142
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
114
143
|
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
|
|
144
|
+
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
115
145
|
<% } else { -%>
|
|
116
146
|
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
117
|
-
<% } -%>
|
|
118
147
|
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
148
|
+
<% } -%>
|
|
119
149
|
<% } -%>
|
|
120
150
|
<% } -%>
|
|
121
151
|
<% }); -%>
|
|
@@ -31,6 +31,7 @@ const usesFormIdentifier = (bodySections || []).some(function(section) {
|
|
|
31
31
|
});
|
|
32
32
|
return subSectionsHaveForm || sectionHasFormFields || hasFormAction;
|
|
33
33
|
});
|
|
34
|
+
const headerHasMenu = (headerActions || []).some(function(action) { return action.visible && action.menuActions; });
|
|
34
35
|
-%>
|
|
35
36
|
<% if (usesFieldIdentifier) { -%>
|
|
36
37
|
import type { FieldIdentifier } from "sap/fe/test/api/BaseAPI";
|
|
@@ -65,7 +66,7 @@ function journey() {
|
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
<% if (headerActions?.length > 0) { -%>
|
|
68
|
-
opaTest("Check header actions of the Object Page", function (_Given: Given, _When: When
|
|
69
|
+
opaTest("Check header actions of the Object Page", function (_Given: Given, <% if (headerHasMenu) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
|
|
69
70
|
<% if (editButton?.visible) { -%>
|
|
70
71
|
// Ensure the opened entity is not in Draft state before uncommenting
|
|
71
72
|
// Then.onThe<%- name%>Generated.onHeader().iCheckEdit({ visible: true });
|
|
@@ -73,12 +74,22 @@ function journey() {
|
|
|
73
74
|
<% } -%>
|
|
74
75
|
<% headerActions.forEach(function(action) { -%>
|
|
75
76
|
<% if (action.visible) { -%>
|
|
76
|
-
<% if (action.
|
|
77
|
+
<% if (action.menuActions) { -%>
|
|
78
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
79
|
+
When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
80
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
81
|
+
<% if (menuAction.visible) { -%>
|
|
82
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
83
|
+
// When.onThe<%- name%>Generated.onHeader().iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
84
|
+
<% } -%>
|
|
85
|
+
<% }); -%>
|
|
86
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
77
87
|
Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
|
|
88
|
+
// When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
78
89
|
<% } else { -%>
|
|
79
90
|
Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
80
|
-
<% } -%>
|
|
81
91
|
// When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
92
|
+
<% } -%>
|
|
82
93
|
<% } -%>
|
|
83
94
|
<% }); -%>
|
|
84
95
|
});
|
|
@@ -113,7 +124,7 @@ function journey() {
|
|
|
113
124
|
<% } -%>
|
|
114
125
|
<% if (bodySections?.length > 0) { -%>
|
|
115
126
|
<% bodySections.forEach(function(section) { -%>
|
|
116
|
-
opaTest("Check the <%- section.id %> section of the Object Page", function (_Given: Given, <% if (bodySections.length > 1) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
|
|
127
|
+
opaTest("Check the <%- section.id %> section of the Object Page", function (_Given: Given, <% if (bodySections.length > 1 || (section.actions && section.actions.some(function(a) { return a.visible && a.menuActions; }))) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
|
|
117
128
|
<% if (bodySections.length > 1) { -%>
|
|
118
129
|
When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
|
|
119
130
|
<% } -%>
|
|
@@ -122,19 +133,39 @@ function journey() {
|
|
|
122
133
|
<% section.actions.forEach(function(action) { -%>
|
|
123
134
|
<% if (action.visible) { -%>
|
|
124
135
|
<% if (section.isTable && section.navigationProperty) { -%>
|
|
125
|
-
<% if (action.
|
|
136
|
+
<% if (action.menuActions) { -%>
|
|
137
|
+
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
138
|
+
When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
139
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
140
|
+
<% if (menuAction.visible) { -%>
|
|
141
|
+
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
142
|
+
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
143
|
+
<% } -%>
|
|
144
|
+
<% }); -%>
|
|
145
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
126
146
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
|
|
147
|
+
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
127
148
|
<% } else { -%>
|
|
128
149
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
129
|
-
<% } -%>
|
|
130
150
|
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
151
|
+
<% } -%>
|
|
131
152
|
<% } else { -%>
|
|
132
|
-
<% if (action.
|
|
153
|
+
<% if (action.menuActions) { -%>
|
|
154
|
+
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
155
|
+
When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
156
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
157
|
+
<% if (menuAction.visible) { -%>
|
|
158
|
+
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
159
|
+
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
160
|
+
<% } -%>
|
|
161
|
+
<% }); -%>
|
|
162
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
133
163
|
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
|
|
164
|
+
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
134
165
|
<% } else { -%>
|
|
135
166
|
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 %> });
|
|
136
|
-
<% } -%>
|
|
137
167
|
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
168
|
+
<% } -%>
|
|
138
169
|
<% } -%>
|
|
139
170
|
<% } -%>
|
|
140
171
|
<% }); -%>
|
|
@@ -86,9 +86,17 @@ sap.ui.define([
|
|
|
86
86
|
<%_ } _%>
|
|
87
87
|
<%_ toolBarActions.forEach(function(item) { _%>
|
|
88
88
|
<%_ if (item.visible) { _%>
|
|
89
|
+
<%_ if (item.custom) { _%>
|
|
90
|
+
<%_ if (item.labelUnresolved) { _%>
|
|
91
|
+
// TODO: label is an unresolved i18n key; replace with the rendered action text
|
|
92
|
+
<%_ } _%>
|
|
93
|
+
// When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
|
|
94
|
+
Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { visible: true });
|
|
95
|
+
<%_ } else { _%>
|
|
89
96
|
// When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
|
|
90
97
|
Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
|
|
91
98
|
<%_ } _%>
|
|
99
|
+
<%_ } _%>
|
|
92
100
|
<%_ }); -%>
|
|
93
101
|
<%_ } -%>
|
|
94
102
|
<%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
|
|
@@ -91,9 +91,17 @@ function journey() {
|
|
|
91
91
|
<%_ } _%>
|
|
92
92
|
<%_ toolBarActions.forEach(function(item) { _%>
|
|
93
93
|
<%_ if (item.visible) { _%>
|
|
94
|
+
<%_ if (item.custom) { _%>
|
|
95
|
+
<%_ if (item.labelUnresolved) { _%>
|
|
96
|
+
// TODO: label is an unresolved i18n key; replace with the rendered action text
|
|
97
|
+
<%_ } _%>
|
|
98
|
+
// When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
|
|
99
|
+
Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { visible: true });
|
|
100
|
+
<%_ } else { _%>
|
|
94
101
|
// When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
|
|
95
102
|
Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
|
|
96
103
|
<%_ } _%>
|
|
104
|
+
<%_ } _%>
|
|
97
105
|
<%_ }); -%>
|
|
98
106
|
<%_ } -%>
|
|
99
107
|
<%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
|
|
@@ -54,12 +54,28 @@ sap.ui.define([
|
|
|
54
54
|
<% } -%>
|
|
55
55
|
<% headerActions.forEach(function(action) { -%>
|
|
56
56
|
<% if (action.visible) { -%>
|
|
57
|
-
<% if (action.
|
|
57
|
+
<% if (action.menuActions) { -%>
|
|
58
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
59
|
+
When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
60
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
61
|
+
<% if (menuAction.visible) { -%>
|
|
62
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
63
|
+
// When.onThe<%- name%>Generated.onHeader().iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
64
|
+
<% } -%>
|
|
65
|
+
<% }); -%>
|
|
66
|
+
<% } else if (action.custom) { -%>
|
|
67
|
+
<% if (action.labelUnresolved) { -%>
|
|
68
|
+
// TODO: label is an unresolved i18n key; replace with the rendered action text
|
|
69
|
+
<% } -%>
|
|
70
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
|
|
71
|
+
// When.onThe<%- name%>Generated.onHeader().iPressAction(<%- JSON.stringify(action.label) %>);
|
|
72
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
58
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 %> });
|
|
59
75
|
<% } else { -%>
|
|
60
76
|
Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
61
|
-
<% } -%>
|
|
62
77
|
// When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
78
|
+
<% } -%>
|
|
63
79
|
<% } -%>
|
|
64
80
|
<% }); -%>
|
|
65
81
|
});
|
|
@@ -104,7 +120,7 @@ sap.ui.define([
|
|
|
104
120
|
<% } -%>
|
|
105
121
|
<% if (bodySections?.length > 0) { -%>
|
|
106
122
|
<% bodySections.forEach(function(section) { -%>
|
|
107
|
-
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); })) { %>When<% } else { %>_When<% } %>, Then) {
|
|
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) {
|
|
108
124
|
<% if (bodySections.length > 1) { -%>
|
|
109
125
|
When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>" });
|
|
110
126
|
<% } -%>
|
|
@@ -113,19 +129,51 @@ sap.ui.define([
|
|
|
113
129
|
<% section.actions.forEach(function(action) { -%>
|
|
114
130
|
<% if (action.visible) { -%>
|
|
115
131
|
<% if (section.isTable && section.navigationProperty) { -%>
|
|
116
|
-
<% if (action.
|
|
132
|
+
<% if (action.menuActions) { -%>
|
|
133
|
+
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
134
|
+
When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
135
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
136
|
+
<% if (menuAction.visible) { -%>
|
|
137
|
+
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
138
|
+
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
139
|
+
<% } -%>
|
|
140
|
+
<% }); -%>
|
|
141
|
+
<% } else if (action.custom) { -%>
|
|
142
|
+
<% if (action.labelUnresolved) { -%>
|
|
143
|
+
// TODO: label is an unresolved i18n key; replace with the rendered action text
|
|
144
|
+
<% } -%>
|
|
145
|
+
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) %>);
|
|
147
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
117
148
|
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 %> });
|
|
118
150
|
<% } else { -%>
|
|
119
151
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
120
|
-
<% } -%>
|
|
121
152
|
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
153
|
+
<% } -%>
|
|
122
154
|
<% } else { -%>
|
|
123
|
-
<% if (action.
|
|
155
|
+
<% if (action.menuActions) { -%>
|
|
156
|
+
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
157
|
+
When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
158
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
159
|
+
<% if (menuAction.visible) { -%>
|
|
160
|
+
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
161
|
+
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
162
|
+
<% } -%>
|
|
163
|
+
<% }); -%>
|
|
164
|
+
<% } else if (action.custom) { -%>
|
|
165
|
+
<% if (action.labelUnresolved) { -%>
|
|
166
|
+
// TODO: label is an unresolved i18n key; replace with the rendered action text
|
|
167
|
+
<% } -%>
|
|
168
|
+
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) %>);
|
|
170
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
124
171
|
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 %> });
|
|
125
173
|
<% } else { -%>
|
|
126
174
|
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
127
|
-
<% } -%>
|
|
128
175
|
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
176
|
+
<% } -%>
|
|
129
177
|
<% } -%>
|
|
130
178
|
<% } -%>
|
|
131
179
|
<% }); -%>
|
|
@@ -35,8 +35,10 @@ const usesWhenInBody = (bodySections || []).length > 1 || (bodySections || []).s
|
|
|
35
35
|
return (section.subSections && section.subSections.length > 1)
|
|
36
36
|
|| (section.contactCardFields && section.contactCardFields.length > 0)
|
|
37
37
|
|| (section.contactCardColumns && section.contactCardColumns.length > 0)
|
|
38
|
-
|| (section.subSections || []).some(function(sub) { return (sub.contactCardFields && sub.contactCardFields.length > 0) || (sub.contactCardColumns && sub.contactCardColumns.length > 0); })
|
|
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
40
|
});
|
|
41
|
+
const headerHasMenu = (headerActions || []).some(function(action) { return action.visible && action.menuActions; });
|
|
40
42
|
-%>
|
|
41
43
|
<% if (usesFieldIdentifier) { -%>
|
|
42
44
|
import type { FieldIdentifier } from "sap/fe/test/api/BaseAPI";
|
|
@@ -71,7 +73,7 @@ function journey() {
|
|
|
71
73
|
});
|
|
72
74
|
|
|
73
75
|
<% if (headerActions?.length > 0) { -%>
|
|
74
|
-
opaTest("Check header actions of the Object Page", function (_Given: Given, _When: When
|
|
76
|
+
opaTest("Check header actions of the Object Page", function (_Given: Given, <% if (headerHasMenu) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
|
|
75
77
|
<% if (editButton?.visible) { -%>
|
|
76
78
|
// Ensure the opened entity is not in Draft state before uncommenting
|
|
77
79
|
// Then.onThe<%- name%>Generated.onHeader().iCheckEdit({ visible: true });
|
|
@@ -79,12 +81,28 @@ function journey() {
|
|
|
79
81
|
<% } -%>
|
|
80
82
|
<% headerActions.forEach(function(action) { -%>
|
|
81
83
|
<% if (action.visible) { -%>
|
|
82
|
-
<% if (action.
|
|
84
|
+
<% if (action.menuActions) { -%>
|
|
85
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
86
|
+
When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
87
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
88
|
+
<% if (menuAction.visible) { -%>
|
|
89
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
90
|
+
// When.onThe<%- name%>Generated.onHeader().iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
91
|
+
<% } -%>
|
|
92
|
+
<% }); -%>
|
|
93
|
+
<% } else if (action.custom) { -%>
|
|
94
|
+
<% if (action.labelUnresolved) { -%>
|
|
95
|
+
// TODO: label is an unresolved i18n key; replace with the rendered action text
|
|
96
|
+
<% } -%>
|
|
97
|
+
Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
|
|
98
|
+
// When.onThe<%- name%>Generated.onHeader().iPressAction(<%- JSON.stringify(action.label) %>);
|
|
99
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
83
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 %> });
|
|
84
102
|
<% } else { -%>
|
|
85
103
|
Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
86
|
-
<% } -%>
|
|
87
104
|
// When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
105
|
+
<% } -%>
|
|
88
106
|
<% } -%>
|
|
89
107
|
<% }); -%>
|
|
90
108
|
});
|
|
@@ -138,19 +156,51 @@ function journey() {
|
|
|
138
156
|
<% section.actions.forEach(function(action) { -%>
|
|
139
157
|
<% if (action.visible) { -%>
|
|
140
158
|
<% if (section.isTable && section.navigationProperty) { -%>
|
|
141
|
-
<% if (action.
|
|
159
|
+
<% if (action.menuActions) { -%>
|
|
160
|
+
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
161
|
+
When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
162
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
163
|
+
<% if (menuAction.visible) { -%>
|
|
164
|
+
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
165
|
+
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
166
|
+
<% } -%>
|
|
167
|
+
<% }); -%>
|
|
168
|
+
<% } else if (action.custom) { -%>
|
|
169
|
+
<% if (action.labelUnresolved) { -%>
|
|
170
|
+
// TODO: label is an unresolved i18n key; replace with the rendered action text
|
|
171
|
+
<% } -%>
|
|
172
|
+
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) %>);
|
|
174
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
142
175
|
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 %> });
|
|
143
177
|
<% } else { -%>
|
|
144
178
|
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
|
|
145
|
-
<% } -%>
|
|
146
179
|
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
180
|
+
<% } -%>
|
|
147
181
|
<% } else { -%>
|
|
148
|
-
<% if (action.
|
|
182
|
+
<% if (action.menuActions) { -%>
|
|
183
|
+
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>);
|
|
184
|
+
When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>);
|
|
185
|
+
<% action.menuActions.forEach(function(menuAction) { -%>
|
|
186
|
+
<% if (menuAction.visible) { -%>
|
|
187
|
+
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
188
|
+
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
|
|
189
|
+
<% } -%>
|
|
190
|
+
<% }); -%>
|
|
191
|
+
<% } else if (action.custom) { -%>
|
|
192
|
+
<% if (action.labelUnresolved) { -%>
|
|
193
|
+
// TODO: label is an unresolved i18n key; replace with the rendered action text
|
|
194
|
+
<% } -%>
|
|
195
|
+
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) %>);
|
|
197
|
+
<% } else if (action.enabled === 'dynamic') { -%>
|
|
149
198
|
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 %> });
|
|
150
200
|
<% } else { -%>
|
|
151
201
|
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 %> });
|
|
152
|
-
<% } -%>
|
|
153
202
|
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
|
|
203
|
+
<% } -%>
|
|
154
204
|
<% } -%>
|
|
155
205
|
<% } -%>
|
|
156
206
|
<% }); -%>
|