@sap-ux/ui5-test-writer 1.19.16 → 1.19.18

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.
Files changed (39) hide show
  1. package/dist/fiori-elements-opa-writer.d.ts +2 -2
  2. package/dist/fiori-elements-opa-writer.js +6 -4
  3. package/dist/types.d.ts +2 -2
  4. package/package.json +4 -4
  5. package/templates/v4/1.120/integration/FPMJourney.js +43 -0
  6. package/templates/v4/1.120/integration/FPMJourney.ts +40 -0
  7. package/templates/v4/1.120/integration/FirstJourney.js +37 -0
  8. package/templates/v4/1.120/integration/FirstJourney.ts +34 -0
  9. package/templates/v4/1.120/integration/ListReportJourney.js +138 -0
  10. package/templates/v4/1.120/integration/ListReportJourney.ts +142 -0
  11. package/templates/v4/1.120/integration/ObjectPageJourney.js +171 -0
  12. package/templates/v4/1.120/integration/ObjectPageJourney.ts +189 -0
  13. package/templates/v4/1.120/integration/opaTests.qunit.html +28 -0
  14. package/templates/v4/1.120/integration/opaTests.qunit.js +33 -0
  15. package/templates/v4/1.120/integration/pages/FPM.js +30 -0
  16. package/templates/v4/1.120/integration/pages/FPM.ts +25 -0
  17. package/templates/v4/1.120/integration/pages/JourneyRunner.js +18 -0
  18. package/templates/v4/1.120/integration/pages/JourneyRunner.ts +37 -0
  19. package/templates/v4/1.120/integration/pages/ListReport.js +35 -0
  20. package/templates/v4/1.120/integration/pages/ListReport.ts +25 -0
  21. package/templates/v4/1.120/integration/pages/ObjectPage.js +42 -0
  22. package/templates/v4/1.120/integration/pages/ObjectPage.ts +35 -0
  23. package/templates/v4/1.120/integration/types/OpaJourneyTypes.d.ts +79 -0
  24. package/templates/v4/1.148/integration/types/OpaJourneyTypes.d.ts +7 -2
  25. package/templates/v4/1.152/integration/FirstJourney.ts +2 -2
  26. package/templates/v4/1.152/integration/ListReportJourney.ts +5 -8
  27. package/templates/v4/1.152/integration/ObjectPageJourney.ts +42 -47
  28. package/templates/v4/1.152/integration/pages/JourneyRunner.ts +1 -2
  29. package/templates/v4/1.152/integration/types/OpaJourneyTypes.d.ts +7 -2
  30. package/templates/v4/1.84/integration/ListReportJourney.js +2 -18
  31. package/templates/v4/1.84/integration/ListReportJourney.ts +0 -18
  32. package/templates/v4/1.84/integration/ObjectPageJourney.js +14 -14
  33. package/templates/v4/1.84/integration/ObjectPageJourney.ts +13 -13
  34. package/templates/v4/1.84/integration/types/OpaJourneyTypes.d.ts +7 -2
  35. package/templates/v4/latest/integration/FirstJourney.ts +2 -2
  36. package/templates/v4/latest/integration/ListReportJourney.ts +5 -8
  37. package/templates/v4/latest/integration/ObjectPageJourney.ts +42 -47
  38. package/templates/v4/latest/integration/pages/JourneyRunner.ts +1 -2
  39. package/templates/v4/latest/integration/types/OpaJourneyTypes.d.ts +7 -2
@@ -0,0 +1,42 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ To add your own custom pages: ║ *
10
+ * ║ - Create a new page file in this directory. ║ *
11
+ * ║ - Follow the same pattern as this file. ║ *
12
+ * ║ - Add the new file to the JourneyRunner. ║ *
13
+ * ║ - Custom page files are not overwritten. ║ *
14
+ * ║ ║ *
15
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
+ ******************************************************************************/
17
+
18
+ sap.ui.define(['sap/fe/test/ObjectPage', 'sap/ui/test/actions/Press'], function(ObjectPage, Press) {
19
+ 'use strict';
20
+
21
+ const CustomPageDefinitions = {
22
+ actions: {
23
+ iPressSectionIconTabFilterButton: function (section) {
24
+ return this.waitFor({
25
+ id: new RegExp(`.*--fe::FacetSection::${section}-anchor$`),
26
+ actions: new Press()
27
+ });
28
+ }
29
+ },
30
+ assertions: {}
31
+ };
32
+
33
+ return new ObjectPage(
34
+ {
35
+ appId: '<%- appID %>',
36
+ componentId: '<%- componentID %>',<% if (locals.contextPath) { %>
37
+ contextPath: '<%- contextPath %>'<% } else if (locals.entitySet) { %>
38
+ entitySet: '<%- entitySet %>'<% } %>
39
+ },
40
+ CustomPageDefinitions
41
+ );
42
+ });
@@ -0,0 +1,35 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ To add your own custom pages: ║ *
10
+ * ║ - Create a new page file in this directory. ║ *
11
+ * ║ - Follow the same pattern as this file. ║ *
12
+ * ║ - Add the new file to the JourneyRunner. ║ *
13
+ * ║ - Custom page files are not overwritten. ║ *
14
+ * ║ ║ *
15
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
+ ******************************************************************************/
17
+
18
+ import type Opa5 from "sap/ui/test/Opa5";
19
+ import Press from "sap/ui/test/actions/Press";
20
+
21
+ export const actions = {
22
+ iPressSectionIconTabFilterButton(this: Opa5, section: string) {
23
+ return this.waitFor({
24
+ id: new RegExp(`.*--fe::FacetSection::${section}-anchor$`),
25
+ actions: new Press()
26
+ });
27
+ }
28
+ };
29
+
30
+ export const assertions = {};
31
+
32
+ export default class ObjectPage {
33
+ actions = actions;
34
+ assertions = assertions;
35
+ }
@@ -0,0 +1,79 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ Do not edit this file directly. Any changes will be lost. ║ *
10
+ * ║ ║ *
11
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
12
+ ******************************************************************************/
13
+
14
+ import type Opa5 from "sap/ui/test/Opa5";
15
+ <% if (pages.some(p => p.template === 'ListReport')) { -%>
16
+ import type { actions as ListReportActions, assertions as ListReportAssertions } from "sap/fe/test/ListReport";
17
+ <% } -%>
18
+ <% if (pages.some(p => p.template === 'ObjectPage')) { -%>
19
+ import type { actions as ObjectPageActions, assertions as ObjectPageAssertions } from "sap/fe/test/ObjectPage";
20
+ <% } -%>
21
+ <% if (pages.some(p => p.template === 'ListReport' || p.template === 'ObjectPage' || p.template === 'FPM')) { -%>
22
+ import type { actions as TemplatePageActions, assertions as TemplatePageAssertions } from "sap/fe/test/TemplatePage";
23
+ <% } -%>
24
+ import type Shell from "sap/fe/test/Shell";
25
+ import type BaseArrangements from "sap/fe/test/BaseArrangements";
26
+ <% pages.filter((p) => p.template === 'ListReport' || p.template === 'ObjectPage' || p.template === 'FPM').forEach(function(page) { -%>
27
+ import type { actions as <%- page.targetKey %>GeneratedCustomActions, assertions as <%- page.targetKey %>GeneratedCustomAssertions } from "../pages/<%- page.targetKey %>.gen";
28
+ <% }); -%>
29
+
30
+ /**
31
+ * Enables OPA5 fluent `.and` chaining on page objects and their sub-objects.
32
+ *
33
+ * @example
34
+ * Then.onTheObjectPageGenerated.iCheckSection({ section: "A" }).and.iCheckSection({ section: "B" });
35
+ * When.onTheListReportGenerated.onFilterBar().iExecuteSearch().and.iClearFilterBar();
36
+ */
37
+ type WithAnd<T> = {
38
+ [K in keyof T | 'and']: K extends 'and'
39
+ ? WithAnd<T>
40
+ : K extends keyof T
41
+ ? T[K] extends (...args: infer A) => infer R
42
+ ? (...args: A) => (R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>)
43
+ : T[K]
44
+ : never;
45
+ };
46
+
47
+ export type Given = Opa5 & BaseArrangements & {
48
+ iTearDownMyApp: () => Given;
49
+ iStartMyApp: (sAppHash?: string, mInUrlParameters?: object) => Given;
50
+ iResetMockData: (oAppInfo?: { AppId?: string; ServiceUri?: string }) => Given;
51
+ iResetTestData: () => Given;
52
+ and: Given;
53
+ };
54
+
55
+ export type When = Opa5 & BaseArrangements & {
56
+ <% pages.forEach(function(page) { -%>
57
+ <% if (page.template === 'ListReport') { -%>
58
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ListReportActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
59
+ <% } else if (page.template === 'ObjectPage') { -%>
60
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ObjectPageActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
61
+ <% } else if (page.template === 'FPM') { -%>
62
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
63
+ <% } -%>
64
+ <% }); -%>
65
+ onTheShell: Shell;
66
+ };
67
+
68
+ export type Then = Opa5 & BaseArrangements & {
69
+ <% pages.forEach(function(page) { -%>
70
+ <% if (page.template === 'ListReport') { -%>
71
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ListReportAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
72
+ <% } else if (page.template === 'ObjectPage') { -%>
73
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ObjectPageAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
74
+ <% } else if (page.template === 'FPM') { -%>
75
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
76
+ <% } -%>
77
+ <% }); -%>
78
+ onTheShell: Shell;
79
+ };
@@ -34,12 +34,17 @@ import type { actions as <%- page.targetKey %>GeneratedCustomActions, assertions
34
34
  * Then.onTheObjectPageGenerated.iCheckSection({ section: "A" }).and.iCheckSection({ section: "B" });
35
35
  * When.onTheListReportGenerated.onFilterBar().iExecuteSearch().and.iClearFilterBar();
36
36
  */
37
+ type WrapReturn<R, T> = R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>;
38
+ // `infer A` on an overloaded function keeps only the last overload; the 2-overload branch preserves both.
39
+ // A 3rd overload would be dropped SILENTLY (no error) — add a 3-overload branch if @sapui5/types grows one.
37
40
  type WithAnd<T> = {
38
41
  [K in keyof T | 'and']: K extends 'and'
39
42
  ? WithAnd<T>
40
43
  : K extends keyof T
41
- ? T[K] extends (...args: infer A) => infer R
42
- ? (...args: A) => (R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>)
44
+ ? T[K] extends { (...args: infer A1): infer R1; (...args: infer A2): infer R2 }
45
+ ? { (...args: A1): WrapReturn<R1, T>; (...args: A2): WrapReturn<R2, T> }
46
+ : T[K] extends (...args: infer A) => infer R
47
+ ? (...args: A) => WrapReturn<R, T>
43
48
  : T[K]
44
49
  : never;
45
50
  };
@@ -18,9 +18,9 @@ function journey() {
18
18
  <% if (!hideFilterBar) { %>
19
19
  When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
20
20
  <%} %>
21
- Then.onThe<%- startLR%>Generated.onTable("").iCheckRows();
21
+ Then.onThe<%- startLR%>Generated.onTable().iCheckRows();
22
22
  <% if (navigatedOP) { %>
23
- When.onThe<%- startLR%>Generated.onTable("").iPressRow(0);
23
+ When.onThe<%- startLR%>Generated.onTable().iPressRow(0);
24
24
  Then.onThe<%- navigatedOP%>Generated.iSeeThisPage();
25
25
  <%} %>
26
26
  });
@@ -17,12 +17,9 @@
17
17
 
18
18
  import opaTest from "sap/ui/test/opaQunit";
19
19
  import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
- <%_
21
- const usesFilterFieldIdentifier =
22
- !hideFilterBar && filterBarItems && filterBarItems.some(function(item) { return item.custom; });
23
- -%>
24
- <% if (usesFilterFieldIdentifier) { -%>
25
- import type { FilterFieldIdentifier } from "sap/fe/test/api/FilterBarAPI";
20
+ <%_ const usesDialogIdentifier = (tabs && tabs.some(function(tab) { return tab.contactCardColumns && tab.contactCardColumns.length > 0; })) || (contactCardColumns && contactCardColumns.length > 0); -%>
21
+ <% if (usesDialogIdentifier) { -%>
22
+ import type { DialogIdentifier } from "sap/fe/test/api/BaseAPI";
26
23
  <% } -%>
27
24
  import runner from "./pages/JourneyRunner";
28
25
  <%_ const needsSortOrder = startLR && ((textAnnotationColumns && textAnnotationColumns.length > 0) || (defaultSortOrder && defaultSortOrder.length > 0) || (tabs && tabs.some(function(tab) { return (tab.textAnnotationColumns && tab.textAnnotationColumns.length > 0) || (tab.defaultSortOrder && tab.defaultSortOrder.length > 0); }))); -%>
@@ -48,7 +45,7 @@ function journey() {
48
45
  opaTest("Check filter bar", function (_Given: Given, _When: When, Then: Then) {
49
46
  <%_ filterBarItems.forEach(function(item) { _%>
50
47
  <%_ if (item.custom) { _%>
51
- Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField("<%- item.description %>" as unknown as FilterFieldIdentifier);
48
+ Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField("<%- item.description %>");
52
49
  <%_ } else { _%>
53
50
  Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField({ property: "<%- item.property %>" });
54
51
  <%_ } _%>
@@ -246,7 +243,7 @@ function journey() {
246
243
  <%_ tab.contactCardColumns.forEach(function(column) { _%>
247
244
  // May fail if the mock data has no row at index 0 or that row does not render the contact link; adjust the row selector if needed.
248
245
  When.onThe<%- startLR %>Generated.onTable("<%- tab.key %>").iClickLink(0, "<%- column.property %>");
249
- Then.onThe<%- startLR %>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
246
+ Then.onThe<%- startLR %>Generated.onDialog({} as unknown as DialogIdentifier).iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
250
247
  <%_ }); _%>
251
248
  });
252
249
 
@@ -18,19 +18,20 @@
18
18
  import opaTest from "sap/ui/test/opaQunit";
19
19
  import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
20
  <%_
21
- const usesFieldIdentifier = (headerSections || []).some(function(section) {
22
- return section.form && section.fields && section.fields.length > 0;
23
- });
24
- const usesFormIdentifier = (bodySections || []).some(function(section) {
25
- const subSectionsHaveForm = (section.subSections || []).some(function(sub) {
26
- return sub.fields && sub.fields.some(function(field) { return !field.checkBoxGroup; });
27
- });
28
- const sectionHasFormFields = !(section.subSections && section.subSections.length > 0) && section.fields && section.fields.some(function(field) { return !field.checkBoxGroup; });
29
- const hasFormAction = (section.actions || []).some(function(action) {
30
- return action.visible && !(section.isTable && section.navigationProperty);
21
+ const usesDialogIdentifier = (headerSections || []).some(function(s) { return (s.contactCardFields && s.contactCardFields.length > 0); })
22
+ || (bodySections || []).some(function(s) {
23
+ return (s.contactCardFields && s.contactCardFields.length > 0)
24
+ || (s.contactCardColumns && s.contactCardColumns.length > 0)
25
+ || (s.subSections || []).some(function(sub) {
26
+ return (sub.contactCardFields && sub.contactCardFields.length > 0)
27
+ || (sub.contactCardColumns && sub.contactCardColumns.length > 0);
28
+ });
31
29
  });
32
- return subSectionsHaveForm || sectionHasFormFields || hasFormAction;
33
- });
30
+ -%>
31
+ <% if (usesDialogIdentifier) { -%>
32
+ import type { DialogIdentifier } from "sap/fe/test/api/BaseAPI";
33
+ <% } -%>
34
+ <%_
34
35
  const usesWhenInBody = (bodySections || []).length > 1 || (bodySections || []).some(function(section) {
35
36
  return (section.subSections && section.subSections.length > 1)
36
37
  || (section.contactCardFields && section.contactCardFields.length > 0)
@@ -41,12 +42,6 @@ const usesWhenInBody = (bodySections || []).length > 1 || (bodySections || []).s
41
42
  });
42
43
  const headerHasMenu = (headerActions || []).some(function(action) { return action.visible && action.menuActions && !action.splitButton; });
43
44
  -%>
44
- <% if (usesFieldIdentifier) { -%>
45
- import type { FieldIdentifier } from "sap/fe/test/api/BaseAPI";
46
- <% } -%>
47
- <% if (usesFormIdentifier) { -%>
48
- import type { FormIdentifier } from "sap/fe/test/api/FormAPI";
49
- <% } -%>
50
45
  import runner from "./pages/JourneyRunner";
51
46
 
52
47
  function journey() {
@@ -137,7 +132,7 @@ function journey() {
137
132
  opaTest("Check header facets of the Object Page", function (_Given: Given, <% if (headerSections.some(function(section) { return section.contactCardFields?.length > 0; })) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
138
133
  <% headerSections.forEach(function(section) { -%>
139
134
  <% if (section.microChart) { -%>
140
- Then.onThe<%- name%>Generated.onHeader().iCheckMicroChart("<%- section.title %>", "");
135
+ Then.onThe<%- name%>Generated.onHeader().iCheckMicroChart("<%- section.title %>");
141
136
  <% } else { -%>
142
137
  Then.onThe<%- name%>Generated.onHeader().iCheckHeaderFacet({ facetId: "<%- section.facetId %>"<% if (section.custom) { %>, custom: true<% } %> });
143
138
  <% if (section.form) { -%>
@@ -146,11 +141,11 @@ function journey() {
146
141
  fieldGroup: "<%- field.fieldGroupQualifier %>",
147
142
  field: "<%- field.field %>",
148
143
  targetAnnotation: "<%- field.targetAnnotation %>"
149
- } as unknown as FieldIdentifier);
144
+ });
150
145
  <% }) -%>
151
146
  <% section.contactCardFields.forEach(function(field) { -%>
152
- When.onThe<%- name%>Generated.onHeader().iClickLink({ property: "<%- field.property %>" } as unknown as FieldIdentifier);
153
- Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
147
+ When.onThe<%- name%>Generated.onHeader().iClickLink({ property: "<%- field.property %>" });
148
+ Then.onThe<%- name%>Generated.onDialog({} as unknown as DialogIdentifier).iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
154
149
  <% }) -%>
155
150
  <% } -%>
156
151
  <% } -%>
@@ -170,7 +165,7 @@ function journey() {
170
165
  <% if (bodySections.length > 1) { -%>
171
166
  When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>" });
172
167
  <% } -%>
173
- Then.onThe<%- name%>Generated.iCheckSection({ section: "<%- section.id %>" }, {});
168
+ Then.onThe<%- name%>Generated.iCheckSection({ section: "<%- section.id %>" });
174
169
  <% if (section.actions && section.actions.length > 0) { -%>
175
170
  <% section.actions.forEach(function(action) { -%>
176
171
  <% if (action.visible) { -%>
@@ -222,15 +217,15 @@ function journey() {
222
217
  <% if (action.menuActions) { -%>
223
218
  <% if (action.splitButton) { -%>
224
219
  // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action:
225
- Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>);
226
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>);
220
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
221
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
227
222
  <% } else { -%>
228
- Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>);
229
- When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>);
223
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction(<%- JSON.stringify(action.label) %>);
224
+ When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
230
225
  <% action.menuActions.forEach(function(menuAction) { -%>
231
226
  <% if (menuAction.visible) { -%>
232
- Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
233
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
227
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>);
228
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>);
234
229
  <% } -%>
235
230
  <% }); -%>
236
231
  <% } -%>
@@ -238,25 +233,25 @@ function journey() {
238
233
  <% if (action.labelUnresolved) { -%>
239
234
  // TODO: label is an unresolved i18n key; replace with the rendered action text
240
235
  <% } -%>
241
- Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
242
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>);
236
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true });
237
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>);
243
238
  <% } else if (action.enabled === 'dynamic') { -%>
244
- 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 } */);
239
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */);
245
240
  <% } else { -%>
246
- 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 %> });
241
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> });
247
242
  <% } -%>
248
243
  <% if (action.isCritical && action.enabled === 'dynamic') { -%>
249
244
  // "<%- action.label || action.action %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the opened entity. Uncomment when the entity state enables it to test the confirmation dialog.
250
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
245
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
251
246
  // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
252
247
  // When.onThe<%- name%>Generated.onMessageDialog().iCancel();
253
248
  <% } else if (action.isCritical) { -%>
254
249
  // Critical action (Common.IsActionCritical): press it, assert the confirmation dialog opens, then cancel so it is not executed.
255
- When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
250
+ When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
256
251
  Then.onThe<%- name%>Generated.onMessageDialog().iCheckState();
257
252
  When.onThe<%- name%>Generated.onMessageDialog().iCancel();
258
253
  <% } else if (!action.custom && !action.menuActions) { -%>
259
- // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
254
+ // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> });
260
255
  <% } -%>
261
256
  <% } -%>
262
257
  <% } -%>
@@ -273,14 +268,14 @@ function journey() {
273
268
  <% } -%>
274
269
  <% section.contactCardColumns.forEach(function(column) { -%>
275
270
  When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iClickLink(0, "<%- column.property %>");
276
- Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
271
+ Then.onThe<%- name%>Generated.onDialog({} as unknown as DialogIdentifier).iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
277
272
  <% }) -%>
278
273
  <% } -%>
279
274
  <% if (section?.subSections?.length > 0) { -%>
280
275
  <% section.subSections.forEach(function(subSection) { -%>
281
276
  <% if (section.subSections.length > 1) { -%>
282
277
  When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
283
- Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" }, {});
278
+ Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" });
284
279
  <% } -%>
285
280
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
286
281
  <% subSection.fields.forEach(function(field, fieldIndex) { -%>
@@ -288,15 +283,15 @@ function journey() {
288
283
  <% if (fieldIndex === 0 || !subSection.fields[fieldIndex - 1].checkBoxGroup) { -%>
289
284
  // Checkbox-group members cannot be addressed by sap.fe.test.api
290
285
  <% } -%>
291
- // Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>", fieldGroup: "<%- field.fieldGroup %>" });
286
+ // Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" }).iCheckField({ property: "<%- field.property %>", fieldGroup: "<%- field.fieldGroup %>" });
292
287
  <% } else { -%>
293
- Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
288
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" }).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
294
289
  <% } -%>
295
290
  <% }) -%>
296
291
  <% } -%>
297
292
  <% subSection.contactCardFields.forEach(function(field) { -%>
298
- When.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" } as unknown as FormIdentifier).iClickLink({ property: "<%- field.property %>" });
299
- Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
293
+ When.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" }).iClickLink({ property: "<%- field.property %>" });
294
+ Then.onThe<%- name%>Generated.onDialog({} as unknown as DialogIdentifier).iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
300
295
  <% }) -%>
301
296
  <% if (subSection.tableColumns && Object.keys(subSection.tableColumns).length > 0 && subSection.navigationProperty) { -%>
302
297
  Then.onThe<%- name%>Generated.onTable({ property: "<%- subSection.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(subSection.tableColumns) %>);
@@ -304,7 +299,7 @@ function journey() {
304
299
  <% if (subSection.navigationProperty) { -%>
305
300
  <% subSection.contactCardColumns.forEach(function(column) { -%>
306
301
  When.onThe<%- name%>Generated.onTable({ property: "<%- subSection.navigationProperty %>" }).iClickLink(0, "<%- column.property %>");
307
- Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
302
+ Then.onThe<%- name%>Generated.onDialog({} as unknown as DialogIdentifier).iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
308
303
  <% }) -%>
309
304
  <% } -%>
310
305
  <% }) -%>
@@ -315,15 +310,15 @@ function journey() {
315
310
  <% if (fieldIndex === 0 || !section.fields[fieldIndex - 1].checkBoxGroup) { -%>
316
311
  // Checkbox-group members cannot be addressed by sap.fe.test.api
317
312
  <% } -%>
318
- // Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>", fieldGroup: "<%- field.fieldGroup %>" });
313
+ // Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckField({ property: "<%- field.property %>", fieldGroup: "<%- field.fieldGroup %>" });
319
314
  <% } else { -%>
320
- Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
315
+ Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
321
316
  <% } -%>
322
317
  <% }) -%>
323
318
  <% } -%>
324
319
  <% section.contactCardFields.forEach(function(field) { -%>
325
- When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iClickLink({ property: "<%- field.property %>" });
326
- Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
320
+ When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" }).iClickLink({ property: "<%- field.property %>" });
321
+ Then.onThe<%- name%>Generated.onDialog({} as unknown as DialogIdentifier).iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" });
327
322
  <% }) -%>
328
323
  <% if (section.tableColumns && Object.keys(section.tableColumns).length > 0 && section.navigationProperty) { -%>
329
324
  Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(section.tableColumns) %>);
@@ -23,8 +23,7 @@ const runner = new JourneyRunner({
23
23
  ' {\n' +
24
24
  ' appId: "' + page.appID + '",\n' +
25
25
  ' componentId: "' + page.componentID + '",\n' +
26
- ' entitySet: "' + (page.entitySet || '') + '",\n' +
27
- ' contextPath: "' + (page.contextPath || '') + '"\n' +
26
+ ' ' + (page.contextPath ? 'contextPath: "' + page.contextPath : 'entitySet: "' + (page.entitySet || '')) + '"\n' +
28
27
  ' },\n' +
29
28
  ' Custom' + page.targetKey + 'Generated\n' +
30
29
  ' )'
@@ -34,12 +34,17 @@ import type { actions as <%- page.targetKey %>GeneratedCustomActions, assertions
34
34
  * Then.onTheObjectPageGenerated.iCheckSection({ section: "A" }).and.iCheckSection({ section: "B" });
35
35
  * When.onTheListReportGenerated.onFilterBar().iExecuteSearch().and.iClearFilterBar();
36
36
  */
37
+ type WrapReturn<R, T> = R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>;
38
+ // `infer A` on an overloaded function keeps only the last overload; the 2-overload branch preserves both.
39
+ // A 3rd overload would be dropped SILENTLY (no error) — add a 3-overload branch if @sapui5/types grows one.
37
40
  type WithAnd<T> = {
38
41
  [K in keyof T | 'and']: K extends 'and'
39
42
  ? WithAnd<T>
40
43
  : K extends keyof T
41
- ? T[K] extends (...args: infer A) => infer R
42
- ? (...args: A) => (R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>)
44
+ ? T[K] extends { (...args: infer A1): infer R1; (...args: infer A2): infer R2 }
45
+ ? { (...args: A1): WrapReturn<R1, T>; (...args: A2): WrapReturn<R2, T> }
46
+ : T[K] extends (...args: infer A) => infer R
47
+ ? (...args: A) => WrapReturn<R, T>
43
48
  : T[K]
44
49
  : never;
45
50
  };
@@ -15,12 +15,10 @@
15
15
  * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
16
  ******************************************************************************/
17
17
 
18
- <%_ const needsSortOrder = startLR && (defaultSortOrder && defaultSortOrder.length > 0); -%>
19
18
  sap.ui.define([
20
19
  "sap/ui/test/opaQunit",
21
- "./pages/JourneyRunner"<% if (needsSortOrder) { %>,
22
- "sap/ui/core/library"<% } %>
23
- ], function (opaTest, runner<% if (needsSortOrder) { %>, coreLibrary<% } %>) {
20
+ "./pages/JourneyRunner"
21
+ ], function (opaTest, runner) {
24
22
  "use strict";
25
23
 
26
24
  function journey() {
@@ -100,20 +98,6 @@ sap.ui.define([
100
98
 
101
99
  <%_ } -%>
102
100
  <%_ }); -%>
103
- <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
104
- opaTest("Check table columns", function (Given, When, Then) {
105
- Then.onThe<%- startLR %>Generated.onTable(defaultTableId).iCheckColumns(undefined, <%- JSON.stringify(tableColumns) %>);
106
- });
107
-
108
- <%_ } -%>
109
- <%_ if (startLR && defaultSortOrder && defaultSortOrder.length > 0) { -%>
110
- opaTest("Check default sort order from PresentationVariant", function (Given, When, Then) {
111
- <%_ defaultSortOrder.forEach(function(sort) { _%>
112
- Then.onThe<%- startLR %>Generated.onTable(defaultTableId).iCheckSortOrder({ name: "<%- sort.property %>" }, coreLibrary.SortOrder.<%- sort.descending ? 'Descending' : 'Ascending' %>, true);
113
- <%_ }); -%>
114
- });
115
-
116
- <%_ } -%>
117
101
  <%_ if (startLR && defaultFilterValues && defaultFilterValues.length > 0) { -%>
118
102
  opaTest("Check default filter values from SelectionVariant", function (Given, When, Then) {
119
103
  <%_ defaultFilterValues.forEach(function(filter) { _%>
@@ -25,10 +25,6 @@ const usesFilterFieldIdentifier =
25
25
  import type { FilterFieldIdentifier } from "sap/fe/test/api/FilterBarAPI";
26
26
  <% } -%>
27
27
  import runner from "./pages/JourneyRunner";
28
- <%_ const needsSortOrder = startLR && ((defaultSortOrder && defaultSortOrder.length > 0)); -%>
29
- <%_ if (needsSortOrder) { -%>
30
- import { SortOrder } from "sap/ui/core/library";
31
- <%_ } -%>
32
28
 
33
29
  function journey() {
34
30
  QUnit.module("<%- name%>ListReport journey");
@@ -107,20 +103,6 @@ function journey() {
107
103
 
108
104
  <%_ } -%>
109
105
  <%_ }); -%>
110
- <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
111
- opaTest("Check table columns", function (_Given: Given, _When: When, Then: Then) {
112
- Then.onThe<%- startLR %>Generated.onTable(defaultTableId).iCheckColumns(undefined, <%- JSON.stringify(tableColumns) %>);
113
- });
114
-
115
- <%_ } -%>
116
- <%_ if (startLR && defaultSortOrder && defaultSortOrder.length > 0) { -%>
117
- opaTest("Check default sort order from PresentationVariant", function (_Given: Given, _When: When, Then: Then) {
118
- <%_ defaultSortOrder.forEach(function(sort) { _%>
119
- Then.onThe<%- startLR %>Generated.onTable(defaultTableId).iCheckSortOrder({ name: "<%- sort.property %>" }, SortOrder.<%- sort.descending ? 'Descending' : 'Ascending' %>, true);
120
- <%_ }); -%>
121
- });
122
-
123
- <%_ } -%>
124
106
  <%_ if (startLR && defaultFilterValues && defaultFilterValues.length > 0) { -%>
125
107
  opaTest("Check default filter values from SelectionVariant", function (_Given: Given, _When: When, Then: Then) {
126
108
  <%_ defaultFilterValues.forEach(function(filter) { _%>
@@ -88,19 +88,24 @@ sap.ui.define([
88
88
  });
89
89
  <% } -%>
90
90
 
91
- <% if (bodySections?.length > 1) { -%>
92
- opaTest("Check the number of sections of the Object Page", function (_Given, _When, Then) {
93
- Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>);
94
- });
95
-
96
- <% } -%>
97
91
  <% if (bodySections?.length > 0) { -%>
98
92
  <% bodySections.forEach(function(section) { -%>
93
+ <%
94
+ // Below 1.120 the section/column level assertions are unavailable, so a table section with
95
+ // no actions, create/delete buttons, sub-sections or form fields would leave an opaTest body
96
+ // with only a When call. OPA5 rejects a test that runs zero assertions, so skip emitting the
97
+ // block entirely in that case.
98
+ const _hasVisibleAction = (section.actions || []).some(function(a) { return a.visible; });
99
+ const _hasTableButton = section.isTable && section.navigationProperty && (section.createButton?.visible || section.deleteButton?.visible);
100
+ const _hasSubSectionAssertion = (section.subSections?.length > 1) || (section.subSections || []).some(function(s) { return s.fields && s.fields.length > 0; });
101
+ const _hasFormFields = !(section.subSections?.length > 0) && section.fields && section.fields.length > 0;
102
+ const _hasSectionAssertion = _hasVisibleAction || _hasTableButton || _hasSubSectionAssertion || _hasFormFields;
103
+ -%>
104
+ <% if (_hasSectionAssertion) { -%>
99
105
  opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1) { %>When<% } else { %>_When<% } %>, Then) {
100
106
  <% if (bodySections.length > 1) { -%>
101
107
  When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
102
108
  <% } -%>
103
- Then.onThe<%- name%>Generated.iCheckSection({ section: "<%- section.id %>" });
104
109
  <% if (section.actions && section.actions.length > 0) { -%>
105
110
  <% section.actions.forEach(function(action) { -%>
106
111
  <% if (action.visible) { -%>
@@ -150,9 +155,6 @@ sap.ui.define([
150
155
  <% } -%>
151
156
  <% }) -%>
152
157
  <% } -%>
153
- <% if (subSection.tableColumns && Object.keys(subSection.tableColumns).length > 0 && subSection.navigationProperty) { -%>
154
- Then.onThe<%- name%>Generated.onTable({ property: "<%- subSection.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(subSection.tableColumns) %>);
155
- <% } -%>
156
158
  <% }) -%>
157
159
  <% } else { -%>
158
160
  <% if (section.fields && section.fields.length > 0) { -%>
@@ -167,15 +169,13 @@ sap.ui.define([
167
169
  <% } -%>
168
170
  <% }) -%>
169
171
  <% } -%>
170
- <% if (section.tableColumns && Object.keys(section.tableColumns).length > 0 && section.navigationProperty) { -%>
171
- Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(section.tableColumns) %>);
172
- <% } -%>
173
172
  <% } -%>
174
173
  });
175
174
 
175
+ <% } -%>
176
176
  <% }) -%>
177
177
  <% } -%>
178
- opaTest("Teardown", function (Given, When, Then) {
178
+ opaTest("Teardown", function (Given, When, Then) {
179
179
  // Cleanup
180
180
  Given.iTearDownMyApp();
181
181
  });