@sap-ux/ui5-test-writer 1.3.1 → 1.4.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.
@@ -40,6 +40,16 @@ export interface HeaderSectionItem extends SectionItem {
40
40
  };
41
41
  };
42
42
  }
43
+ export interface HeaderItem extends TreeAggregation {
44
+ properties?: {
45
+ title?: {
46
+ value?: string;
47
+ };
48
+ description?: {
49
+ value?: string;
50
+ };
51
+ };
52
+ }
43
53
  export interface PageWithModelV4WithProperties extends PageWithModelV4 {
44
54
  routePattern?: string;
45
55
  }
@@ -25,7 +25,12 @@ export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
25
25
  // readApp calls createApplicationAccess internally if given a path, but it uses the "live" version of project-access without fs enhancement
26
26
  const appAccess = await createApplicationAccess(basePath, { fs: fs });
27
27
  const specification = await appAccess.getSpecification();
28
- const appModel = await specification.readApp({ app: appAccess, fs: fs });
28
+ const readAppOptions = {
29
+ app: appAccess,
30
+ fs: fs,
31
+ includeAnnotationProperties: true
32
+ };
33
+ const appModel = await specification.readApp(readAppOptions);
29
34
  if (!projectMetadata) {
30
35
  const metadataPath = appAccess.project?.apps['']?.services?.mainService?.local;
31
36
  if (metadataPath) {
@@ -31,6 +31,8 @@ export async function getObjectPageFeatures(objectPages, listReportPageKey, log,
31
31
  const pageFeatureData = {};
32
32
  pageFeatureData.name = objectPage.name;
33
33
  pageFeatureData.navigationParents = getObjectPageNavigationParents(objectPage.name, objectPages, listReportPageKey, parentLRTableIdentifier);
34
+ // extract header title binding path (for iCheckTitlePath)
35
+ pageFeatureData.headerTitle = getHeaderTitlePath(objectPage);
34
36
  // extract header sections (facets)
35
37
  pageFeatureData.headerSections = extractObjectPageHeaderSectionsData(objectPage);
36
38
  // extract body sections (includes section-level actions and standard create/delete buttons)
@@ -102,6 +104,24 @@ function getObjectPageNavigationParents(targetObjectPageKey, objectPages, listRe
102
104
  parentOPs
103
105
  };
104
106
  }
107
+ /**
108
+ * Returns the OData property path the Object Page header title is bound to, for use with
109
+ * `iCheckTitlePath`. Returns undefined for static titles that expose no binding path.
110
+ *
111
+ * @param objectPage - object page from the application model
112
+ * @returns the title binding path, or undefined
113
+ */
114
+ function getHeaderTitlePath(objectPage) {
115
+ if (!objectPage.model) {
116
+ return undefined;
117
+ }
118
+ const header = getAggregations(objectPage.model.root)['header'];
119
+ const titlePath = header?.properties?.title?.value;
120
+ if (!titlePath) {
121
+ return undefined;
122
+ }
123
+ return titlePath;
124
+ }
105
125
  /**
106
126
  * Extracts header sections data from an object page model.
107
127
  *
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.3.1",
4
+ "version": "1.4.0",
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.21",
31
- "@sap-ux/ui5-application-writer": "2.1.2",
31
+ "@sap-ux/ui5-application-writer": "2.1.3",
32
32
  "@sap-ux/logger": "1.0.3",
33
- "@sap-ux/fiori-generator-shared": "1.2.5",
34
- "@sap-ux/project-access": "2.1.9",
35
- "@sap-ux/preview-middleware": "1.1.0"
33
+ "@sap-ux/fiori-generator-shared": "1.2.6",
34
+ "@sap-ux/project-access": "2.1.10",
35
+ "@sap-ux/preview-middleware": "1.1.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@jest/globals": "30.4.1",
@@ -46,7 +46,7 @@ sap.ui.define([
46
46
  <% if (editButton?.visible) { -%>
47
47
  // Ensure the opened entity is not in Draft state before uncommenting
48
48
  // Then.onThe<%- name%>Generated.onHeader().iCheckEdit({ visible: true });
49
- // When.onThe<%- name%>Generated.onHeader().iPressEdit();
49
+ // When.onThe<%- name%>Generated.onHeader().iExecuteEdit();
50
50
  <% } -%>
51
51
  <% headerActions.forEach(function(action) { -%>
52
52
  <% if (action.visible) { -%>
@@ -61,6 +61,12 @@ sap.ui.define([
61
61
  });
62
62
  <% } -%>
63
63
 
64
+ <% if (headerTitle) { -%>
65
+ opaTest("Check header title of the Object Page", function (_Given, _When, Then) {
66
+ Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>);
67
+ });
68
+
69
+ <% } -%>
64
70
  <% if (headerSections?.length > 0) { -%>
65
71
  opaTest("Check header facets of the Object Page", function (Given, When, Then) {
66
72
  <% headerSections.forEach(function(section) { -%>
@@ -83,13 +89,12 @@ sap.ui.define([
83
89
  <% } -%>
84
90
 
85
91
  <% if (bodySections?.length > 0) { -%>
86
- opaTest("Check body sections of the Object Page", function (Given, When, Then) {
87
- <% if (bodySections?.length > 1) { -%>
92
+ <% const usesWhenInBody = bodySections.length > 1 || bodySections.some(function(section) { return section.subSections && section.subSections.length > 0; }); -%>
93
+ opaTest("Check body sections of the Object Page", function (_Given, <% if (usesWhenInBody) { %>When<% } else { %>_When<% } %>, Then) {
88
94
  Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>);
89
- <% } -%>
90
95
  <% bodySections.forEach(function(section) { -%>
91
96
  <% if (bodySections.length > 1) { -%>
92
- When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
97
+ When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>" });
93
98
  <% } -%>
94
99
  Then.onThe<%- name%>Generated.iCheckSection({ section: "<%- section.id %>" });
95
100
  <% if (section.actions && section.actions.length > 0) { -%>
@@ -125,7 +130,7 @@ sap.ui.define([
125
130
  <% } -%>
126
131
  <% if (section?.subSections?.length > 0) { -%>
127
132
  <% section.subSections.forEach(function(subSection) { -%>
128
- //When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
133
+ When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
129
134
  Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" });
130
135
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
131
136
  <% subSection.fields.forEach(function(field) { -%>
@@ -31,6 +31,9 @@ const usesFormIdentifier = (bodySections || []).some(function(section) {
31
31
  });
32
32
  return subSectionsHaveForm || sectionHasFormFields || hasFormAction;
33
33
  });
34
+ const usesWhenInBody = (bodySections || []).length > 1 || (bodySections || []).some(function(section) {
35
+ return section.subSections && section.subSections.length > 0;
36
+ });
34
37
  -%>
35
38
  <% if (usesFieldIdentifier) { -%>
36
39
  import type { FieldIdentifier } from "sap/fe/test/api/BaseAPI";
@@ -65,7 +68,7 @@ function journey() {
65
68
  <% if (editButton?.visible) { -%>
66
69
  // Ensure the opened entity is not in Draft state before uncommenting
67
70
  // Then.onThe<%- name%>Generated.onHeader().iCheckEdit({ visible: true });
68
- // When.onThe<%- name%>Generated.onHeader().iPressEdit();
71
+ // When.onThe<%- name%>Generated.onHeader().iExecuteEdit();
69
72
  <% } -%>
70
73
  <% headerActions.forEach(function(action) { -%>
71
74
  <% if (action.visible) { -%>
@@ -80,6 +83,12 @@ function journey() {
80
83
  });
81
84
  <% } -%>
82
85
 
86
+ <% if (headerTitle) { -%>
87
+ opaTest("Check header title of the Object Page", function (_Given: Given, _When: When, Then: Then) {
88
+ Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>);
89
+ });
90
+
91
+ <% } -%>
83
92
  <% if (headerSections?.length > 0) { -%>
84
93
  opaTest("Check header facets of the Object Page", function (_Given: Given, _When: When, Then: Then) {
85
94
  <% headerSections.forEach(function(section) { -%>
@@ -102,13 +111,11 @@ function journey() {
102
111
  <% } -%>
103
112
 
104
113
  <% if (bodySections?.length > 0) { -%>
105
- opaTest("Check body sections of the Object Page", function (_Given: Given, <% if (bodySections?.length > 1) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
106
- <% if (bodySections?.length > 1) { -%>
114
+ opaTest("Check body sections of the Object Page", function (_Given: Given, <% if (usesWhenInBody) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
107
115
  Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>);
108
- <% } -%>
109
116
  <% bodySections.forEach(function(section) { -%>
110
117
  <% if (bodySections.length > 1) { -%>
111
- When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
118
+ When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>" });
112
119
  <% } -%>
113
120
  Then.onThe<%- name%>Generated.iCheckSection({ section: "<%- section.id %>" }, {});
114
121
  <% if (section.actions && section.actions.length > 0) { -%>
@@ -144,7 +151,7 @@ function journey() {
144
151
  <% } -%>
145
152
  <% if (section?.subSections?.length > 0) { -%>
146
153
  <% section.subSections.forEach(function(subSection) { -%>
147
- //When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
154
+ When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
148
155
  Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" }, {});
149
156
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
150
157
  <% subSection.fields.forEach(function(field) { -%>
@@ -15,18 +15,11 @@
15
15
  * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
16
  ******************************************************************************/
17
17
 
18
- sap.ui.define(['sap/fe/test/ObjectPage', 'sap/ui/test/actions/Press'], function(ObjectPage, Press) {
18
+ sap.ui.define(['sap/fe/test/ObjectPage'], function(ObjectPage) {
19
19
  'use strict';
20
20
 
21
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
- },
22
+ actions: {},
30
23
  assertions: {}
31
24
  };
32
25
 
@@ -15,17 +15,7 @@
15
15
  * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
16
  ******************************************************************************/
17
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
- };
18
+ export const actions = {};
29
19
 
30
20
  export const assertions = {};
31
21
 
@@ -61,6 +61,12 @@ sap.ui.define([
61
61
  });
62
62
  <% } -%>
63
63
 
64
+ <% if (headerTitle) { -%>
65
+ opaTest("Check header title of the Object Page", function (_Given, _When, Then) {
66
+ Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>);
67
+ });
68
+
69
+ <% } -%>
64
70
  <% if (headerSections?.length > 0) { -%>
65
71
  opaTest("Check header facets of the Object Page", function (Given, When, Then) {
66
72
  <% headerSections.forEach(function(section) { -%>
@@ -80,6 +80,12 @@ function journey() {
80
80
  });
81
81
  <% } -%>
82
82
 
83
+ <% if (headerTitle) { -%>
84
+ opaTest("Check header title of the Object Page", function (_Given: Given, _When: When, Then: Then) {
85
+ Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>);
86
+ });
87
+
88
+ <% } -%>
83
89
  <% if (headerSections?.length > 0) { -%>
84
90
  opaTest("Check header facets of the Object Page", function (_Given: Given, _When: When, Then: Then) {
85
91
  <% headerSections.forEach(function(section) { -%>