@sap-ux/ui5-test-writer 1.16.3 → 1.17.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.
@@ -20,11 +20,6 @@ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
20
  <%_
21
21
  const usesFilterFieldIdentifier =
22
22
  !hideFilterBar && filterBarItems && filterBarItems.some(function(item) { return item.custom; });
23
- const toolBarHasMenu = (toolBarActions || []).some(function(item) { return item.visible && item.menuActions && !item.splitButton; });
24
- const toolBarHasDialogAction = (toolBarActions || []).some(function(item) {
25
- return item.visible && !item.menuActions && !item.custom && item.enabled !== 'dynamic' &&
26
- (item.isCritical || (item.parameterDialogFields && item.parameterDialogFields.length > 0));
27
- });
28
23
  -%>
29
24
  <% if (usesFilterFieldIdentifier) { -%>
30
25
  import type { FilterFieldIdentifier } from "sap/fe/test/api/FilterBarAPI";
@@ -89,34 +84,134 @@ function journey() {
89
84
  // });
90
85
 
91
86
  <%_ if (tabs && tabs.length > 0) { -%>
92
- opaTest("Check table columns and actions per tab", function (_Given: Given, When: When, Then: Then) {
93
- <%_ tabs.forEach(function(tab) { _%>
87
+ <%_ tabs.forEach(function(tab) { -%>
88
+ /// View "<%- tab.key %>" ///
89
+ <%_ if (tab.createButton.visible && !isALP) { -%>
90
+ opaTest(<%- JSON.stringify("Check the create button in view " + tab.key) %>, function (_Given: Given, When: When, Then: Then) {
94
91
  When.onThe<%- startLR%>Generated.iGoToView({ key: "<%- tab.key %>" });
95
- <%_ if (tab.createButton.visible && !isALP) { _%>
96
92
  Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckCreate({ visible: true });
97
- // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iPressCreate();
93
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteCreate();
94
+ });
95
+
96
+ <%_ } -%>
97
+ <%_ if (tab.deleteButton.visible) { -%>
98
+ opaTest(<%- JSON.stringify("Check the delete button in view " + tab.key) %>, function (_Given: Given, When: When, Then: Then) {
99
+ When.onThe<%- startLR%>Generated.iGoToView({ key: "<%- tab.key %>" });
100
+ <%_ const deleteIsSelectionGated = tab.deleteButton.enabled === true; _%>
101
+ <%_ if (deleteIsSelectionGated) { _%>
102
+ Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckDelete({ visible: true, enabled: false });
103
+ <%_ if (!hideFilterBar) { _%>
104
+ // Populate the table and select a row so Delete becomes enabled.
105
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
98
106
  <%_ } _%>
99
- <%_ if (tab.deleteButton.visible) { _%>
100
- // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iPressDelete();
107
+ When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iSelectRows(0);
108
+ Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckDelete({ visible: true, enabled: true });
109
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteDelete();
110
+ // Deselect the row so the following actions start with an empty selection.
111
+ When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iSelectRows(0);
112
+ <%_ } else { _%>
101
113
  Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckDelete({ visible: true });
114
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteDelete();
102
115
  <%_ } _%>
103
- <%_ tab.toolBarActions.forEach(function(item) { _%>
104
- <%_ if (item.visible) { _%>
105
- <%_ if (item.custom) { _%>
116
+ });
117
+
118
+ <%_ } -%>
119
+ <%_ tab.toolBarActions.forEach(function(item) { -%>
120
+ <%_ if (item.visible) { -%>
121
+ opaTest(<%- JSON.stringify("Check the " + item.label + " action in view " + tab.key) %>, function (_Given: Given, When: When, Then: Then) {
122
+ When.onThe<%- startLR%>Generated.iGoToView({ key: "<%- tab.key %>" });
123
+ <%_ if (item.menuActions) { _%>
124
+ <%_ if (item.splitButton) { _%>
125
+ // "<%- item.label %>" is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
126
+ Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckAction("<%- item.label %>");
127
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteAction("<%- item.label %>");
128
+ <%_ } else { _%>
129
+ Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckAction("<%- item.label %>");
130
+ When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteAction("<%- item.label %>");
131
+ <%_ item.menuActions.forEach(function(menuAction) { _%>
132
+ <%_ if (menuAction.visible) { _%>
133
+ Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckMenuAction("<%- menuAction.label %>");
134
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteMenuAction("<%- menuAction.label %>");
135
+ <%_ } _%>
136
+ <%_ }); _%>
137
+ <%_ } _%>
138
+ <%_ } else if (item.custom) { _%>
106
139
  <%_ if (item.labelUnresolved) { _%>
107
140
  // TODO: label is an unresolved i18n key; replace with the rendered action text
108
141
  <%_ } _%>
109
- // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iPressAction("<%- item.label %>");
110
142
  Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckAction("<%- item.label %>", { visible: true });
143
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteAction("<%- item.label %>");
111
144
  <%_ } else { _%>
112
- // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iPressAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> });
145
+ <%_ const hasParamDialog = item.parameterDialogFields && item.parameterDialogFields.length > 0; _%>
113
146
  Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> }, { enabled: <%- item.enabled === true %> });
147
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> });
148
+ <%_ if (item.selectionEnables && !item.isCritical && !hasParamDialog) { _%>
149
+ <%_ if (!hideFilterBar) { _%>
150
+ // Populate the table and select a row so the action becomes enabled.
151
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
114
152
  <%_ } _%>
153
+ When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iSelectRows(0);
154
+ Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> }, { enabled: true });
155
+ // Deselect the row so the following actions start with an empty selection.
156
+ When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iSelectRows(0);
157
+ <%_ } else if ((item.isCritical || hasParamDialog) && item.enabled === 'dynamic') { _%>
158
+ // "<%- item.label %>" is conditionally enabled (Core.OperationAvailable path); it may be disabled for the selected row. Uncomment and select a row that enables it to test the <%- hasParamDialog ? 'action parameter dialog' : 'confirmation dialog' %>.
159
+ <%_ if (!hideFilterBar) { _%>
160
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
115
161
  <%_ } _%>
162
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iSelectRows(0);
163
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> });
164
+ <%_ if (hasParamDialog) { _%>
165
+ <%_ item.parameterDialogFields.forEach(function(parameter) { _%>
166
+ // Then.onThe<%- startLR%>Generated.onActionDialog().iCheckActionParameterDialogField({ property: "<%- parameter %>" }, undefined, { visible: true });
116
167
  <%_ }); _%>
117
- <%_ if (Object.keys(tab.tableColumns).length > 0) { _%>
118
- Then.onThe<%- startLR %>Generated.onTable("<%- tab.key %>").iCheckColumns(undefined, <%- JSON.stringify(tab.tableColumns) %>);
168
+ // When.onThe<%- startLR%>Generated.onActionDialog().iCancel();
169
+ <%_ } else { _%>
170
+ // Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
171
+ // When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
172
+ <%_ } _%>
173
+ // When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iSelectRows(0);
174
+ <%_ } else if (item.isCritical || hasParamDialog) { _%>
175
+ <%_ if (!hideFilterBar) { _%>
176
+ // Populate the table so the action below has a row to select.
177
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
178
+ <%_ } _%>
179
+ <%_ if (item.enabled !== true) { _%>
180
+ When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iSelectRows(0);
181
+ <%_ } _%>
182
+ When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iExecuteAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> });
183
+ <%_ if (hasParamDialog) { _%>
184
+ <%_ item.parameterDialogFields.forEach(function(parameter) { _%>
185
+ Then.onThe<%- startLR%>Generated.onActionDialog().iCheckActionParameterDialogField({ property: "<%- parameter %>" }, undefined, { visible: true });
186
+ <%_ }); _%>
187
+ When.onThe<%- startLR%>Generated.onActionDialog().iCancel();
188
+ <%_ } else { _%>
189
+ Then.onThe<%- startLR%>Generated.onMessageDialog().iCheckState();
190
+ When.onThe<%- startLR%>Generated.onMessageDialog().iCancel();
191
+ <%_ } _%>
192
+ <%_ if (item.enabled !== true) { _%>
193
+ // Deselect the row so the following actions start with an empty selection.
194
+ When.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iSelectRows(0);
195
+ <%_ } _%>
119
196
  <%_ } _%>
197
+ <%_ } _%>
198
+ });
199
+
200
+ <%_ } -%>
201
+ <%_ }); -%>
202
+ <%_ if (Object.keys(tab.tableColumns).length > 0) { -%>
203
+ opaTest(<%- JSON.stringify("Check table columns in view " + tab.key) %>, function (_Given: Given, When: When, Then: Then) {
204
+ When.onThe<%- startLR%>Generated.iGoToView({ key: "<%- tab.key %>" });
205
+ Then.onThe<%- startLR %>Generated.onTable("<%- tab.key %>").iCheckColumns(undefined, <%- JSON.stringify(tab.tableColumns) %>);
206
+ });
207
+
208
+ <%_ } -%>
209
+ opaTest(<%- JSON.stringify("Check table rows in view " + tab.key) %>, function (_Given: Given, When: When, Then: Then) {
210
+ When.onThe<%- startLR%>Generated.iGoToView({ key: "<%- tab.key %>" });
211
+ <%_ if (!hideFilterBar) { -%>
212
+ // Populate the table so the row check has data.
213
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
214
+ <%_ } -%>
120
215
  Then.onThe<%- startLR%>Generated.onTable("<%- tab.key %>").iCheckRows();
121
216
  <%_ if (tab.contactCardColumns.length > 0) { _%>
122
217
  // Reveal popin details so low-priority (e.g. contact-card) columns become clickable; no-op on grid/analytical tables.
@@ -127,26 +222,44 @@ function journey() {
127
222
  When.onThe<%- startLR %>Generated.onTable("<%- tab.key %>").iClickLink(0, "<%- column.property %>");
128
223
  Then.onThe<%- startLR %>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
129
224
  <%_ }); _%>
130
- <%_ }); -%>
131
225
  });
226
+
227
+ <%_ }); -%>
132
228
  <%_ } else { -%>
133
- <%_ if ((toolBarActions && toolBarActions.length > 0 ) || (tableColumns && Object.keys(tableColumns).length > 0)) { -%>
134
- opaTest("Check table columns and actions", function (_Given: Given, <% if (toolBarHasMenu || toolBarHasDialogAction) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
135
- <%_ if (toolBarActions && toolBarActions.length > 0) { -%>
136
- <%_ if (createButton.visible && !isALP) { _%>
229
+ <%_ if (createButton.visible && !isALP) { -%>
230
+ opaTest("Check the create button", function (_Given: Given, _When: When, Then: Then) {
137
231
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckCreate({ visible: true });
138
- // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressCreate();
232
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteCreate();
233
+ });
234
+
235
+ <%_ } -%>
236
+ <%_ if (deleteButton.visible) { -%>
237
+ <%_ /* deleteButton.enabled = Capabilities Deletable (not current UI state); when deletable, Delete is selection-gated: disabled with no selection, enabled once a row is selected. */ -%>
238
+ <%_ const deleteIsSelectionGated = deleteButton.enabled === true; -%>
239
+ opaTest("Check the delete button", function (_Given: Given, <% if (deleteIsSelectionGated) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
240
+ <%_ if (deleteIsSelectionGated) { _%>
241
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckDelete({ visible: true, enabled: false });
242
+ <%_ if (!hideFilterBar) { _%>
243
+ // Populate the table and select a row so Delete becomes enabled.
244
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
139
245
  <%_ } _%>
140
- <%_ if (deleteButton.visible) { _%>
141
- // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressDelete();
246
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
247
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckDelete({ visible: true, enabled: true });
248
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteDelete();
249
+ // Deselect the row so the following actions start with an empty selection.
250
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
251
+ <%_ } else { _%>
142
252
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckDelete({ visible: true });
253
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteDelete();
143
254
  <%_ } _%>
144
- <%_ if (!hideFilterBar && toolBarHasDialogAction) { _%>
145
- // Populate the table so the actions below have a row to select.
146
- When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
147
- <%_ } _%>
148
- <%_ toolBarActions.forEach(function(item) { _%>
149
- <%_ if (item.visible) { _%>
255
+ });
256
+
257
+ <%_ } -%>
258
+ <%_ (toolBarActions || []).forEach(function(item) { -%>
259
+ <%_ if (item.visible) { -%>
260
+ <%_ const hasParamDialog = item.parameterDialogFields && item.parameterDialogFields.length > 0; _%>
261
+ <%_ const usesWhen = (item.menuActions && !item.splitButton) || (!item.menuActions && !item.custom && ((item.selectionEnables && !item.isCritical && !hasParamDialog) || ((item.isCritical || hasParamDialog) && item.enabled !== 'dynamic'))); _%>
262
+ opaTest(<%- JSON.stringify("Check the " + item.label + " action") %>, function (_Given: Given, <% if (usesWhen) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
150
263
  <%_ if (item.menuActions) { _%>
151
264
  <%_ if (item.splitButton) { _%>
152
265
  // "<%- item.label %>" is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
@@ -166,13 +279,21 @@ function journey() {
166
279
  <%_ if (item.labelUnresolved) { _%>
167
280
  // TODO: label is an unresolved i18n key; replace with the rendered action text
168
281
  <%_ } _%>
169
- // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
170
282
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { visible: true });
283
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction("<%- item.label %>");
171
284
  <%_ } else { _%>
172
- // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> });
173
285
  Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> }, { enabled: <%- item.enabled === true %> });
174
- <%_ const hasParamDialog = item.parameterDialogFields && item.parameterDialogFields.length > 0; _%>
175
- <%_ if ((item.isCritical || hasParamDialog) && item.enabled === 'dynamic') { _%>
286
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iExecuteAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> });
287
+ <%_ if (item.selectionEnables && !item.isCritical && !hasParamDialog) { _%>
288
+ <%_ if (!hideFilterBar) { _%>
289
+ // Populate the table and select a row so the action becomes enabled.
290
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
291
+ <%_ } _%>
292
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
293
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction({ service: "<%- item.service %>", action: "<%- item.action %>", unbound: <%- item.unbound === true %> }, { enabled: true });
294
+ // Deselect the row so the following actions start with an empty selection.
295
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
296
+ <%_ } else if ((item.isCritical || hasParamDialog) && item.enabled === 'dynamic') { _%>
176
297
  // "<%- item.label %>" is conditionally enabled (Core.OperationAvailable path); it may be disabled for the selected row. Uncomment and select a row that enables it to test the <%- hasParamDialog ? 'action parameter dialog' : 'confirmation dialog' %>.
177
298
  <%_ if (!hideFilterBar) { _%>
178
299
  // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
@@ -190,6 +311,10 @@ function journey() {
190
311
  <%_ } _%>
191
312
  // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
192
313
  <%_ } else if (item.isCritical || hasParamDialog) { _%>
314
+ <%_ if (!hideFilterBar) { _%>
315
+ // Populate the table so the action below has a row to select.
316
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
317
+ <%_ } _%>
193
318
  <%_ if (item.enabled !== true) { _%>
194
319
  When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
195
320
  <%_ } _%>
@@ -209,13 +334,15 @@ function journey() {
209
334
  <%_ } _%>
210
335
  <%_ } _%>
211
336
  <%_ } _%>
212
- <%_ } _%>
213
- <%_ }); -%>
214
- <%_ } -%>
215
- <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
337
+ });
338
+
339
+ <%_ } -%>
340
+ <%_ }); -%>
341
+ <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
342
+ opaTest("Check table columns", function (_Given: Given, _When: When, Then: Then) {
216
343
  Then.onThe<%- startLR %>Generated.onTable(defaultTableId).iCheckColumns(undefined, <%- JSON.stringify(tableColumns) %>);
217
- <%_ } -%>
218
344
  });
345
+
219
346
  <%_ } -%>
220
347
  <%_ if (startLR && textAnnotationColumns && textAnnotationColumns.length > 0) { -%>
221
348
  opaTest("Check text annotation for columns", function (_Given: Given, When: When, Then: Then) {
@@ -232,6 +359,7 @@ function journey() {
232
359
  <%_ } _%>
233
360
  <%_ }); -%>
234
361
  });
362
+
235
363
  <%_ } -%>
236
364
  <%_ if (startLR && textAnnotationColumns && textAnnotationColumns.length > 0 && columnPersonalizationSupported !== false) { -%>
237
365
  opaTest("Check columns in adaptation dialog", function (_Given: Given, When: When, Then: Then) {
@@ -242,8 +370,8 @@ function journey() {
242
370
  <%_ }); -%>
243
371
  When.onThe<%- startLR%>Generated.onTable(defaultTableId).iConfirmColumnAdaptation();
244
372
  });
245
- <%_ } -%>
246
373
 
374
+ <%_ } -%>
247
375
  <%_ if (contactCardColumns.length > 0) { -%>
248
376
  opaTest("Check contact card links", function (_Given: Given, When: When, Then: Then) {
249
377
  // Reveal popin details so low-priority (e.g. contact-card) columns become clickable; no-op on grid/analytical tables.