@sap-ux/ui5-test-writer 0.7.96 → 0.7.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -67,12 +67,26 @@ export type ObjectPageNavigationParents = {
67
67
  parentOPName?: string;
68
68
  parentOPTableSection?: string;
69
69
  };
70
+ export type BodySubSectionFeatureData = {
71
+ id: string;
72
+ isTable: boolean;
73
+ custom: boolean;
74
+ order: number;
75
+ };
76
+ export type BodySectionFeatureData = {
77
+ id: string;
78
+ isTable: boolean;
79
+ custom: boolean;
80
+ order: number;
81
+ subSections: BodySubSectionFeatureData[];
82
+ };
70
83
  export type ObjectPageFeatures = {
71
84
  name?: string;
72
85
  navigationParents?: ObjectPageNavigationParents;
73
86
  headerTitle?: string;
74
87
  headerDescription?: string;
75
88
  headerSections?: HeaderSectionFeatureData[];
89
+ bodySections?: BodySectionFeatureData[];
76
90
  };
77
91
  export type ListReportFeatures = {
78
92
  name?: string;
@@ -19,6 +19,7 @@ export interface SectionItem extends AggregationItem {
19
19
  title?: string;
20
20
  custom?: boolean;
21
21
  name?: string;
22
+ order?: number;
22
23
  schema: {
23
24
  keys: {
24
25
  name: string;
@@ -27,6 +28,9 @@ export interface SectionItem extends AggregationItem {
27
28
  dataType?: string;
28
29
  };
29
30
  }
31
+ export interface BodySectionItem extends SectionItem {
32
+ isTable?: boolean;
33
+ }
30
34
  export interface HeaderSectionItem extends SectionItem {
31
35
  properties: {
32
36
  stashed: {
@@ -25,6 +25,8 @@ async function getObjectPageFeatures(objectPages, listReportPageKey, log) {
25
25
  pageFeatureData.navigationParents = getObjectPageNavigationParents(objectPage.name, objectPages, listReportPageKey);
26
26
  // extract header sections (facets)
27
27
  pageFeatureData.headerSections = extractObjectPageHeaderSectionsData(objectPage);
28
+ // extract body sections
29
+ pageFeatureData.bodySections = extractObjectPageBodySectionsData(objectPage);
28
30
  objectPageFeatures.push(pageFeatureData);
29
31
  }
30
32
  return objectPageFeatures;
@@ -103,6 +105,53 @@ function extractObjectPageHeaderSectionsData(objectPage) {
103
105
  }
104
106
  return headerSections;
105
107
  }
108
+ /**
109
+ * Extracts body sections data from an object page model.
110
+ *
111
+ * @param objectPage - object page from the application model
112
+ * @returns body sections data including sub-sections
113
+ */
114
+ function extractObjectPageBodySectionsData(objectPage) {
115
+ const bodySections = [];
116
+ if (objectPage.model) {
117
+ const sectionsAggregation = (0, modelUtils_1.getAggregations)(objectPage.model.root)['sections'];
118
+ const sections = (0, modelUtils_1.getAggregations)(sectionsAggregation);
119
+ Object.entries(sections).forEach(([sectionKey, section]) => {
120
+ const sectionId = getSectionIdentifier(section) ?? sectionKey;
121
+ const subSections = extractBodySubSectionsData(section, sectionId);
122
+ bodySections.push({
123
+ id: sectionId,
124
+ isTable: !!section.isTable,
125
+ custom: !!section.custom,
126
+ order: section?.order ?? -1, // put a negative order number to signal that order was not in spec
127
+ subSections
128
+ });
129
+ });
130
+ }
131
+ return bodySections;
132
+ }
133
+ /**
134
+ * Extracts sub-sections data from a body section.
135
+ *
136
+ * @param section - body section entry from the application model
137
+ * @param parentSectionId - identifier of the parent section (used as fallback key prefix)
138
+ * @returns array of sub-section feature data
139
+ */
140
+ function extractBodySubSectionsData(section, parentSectionId) {
141
+ const subSections = [];
142
+ const subSectionsAggregation = (0, modelUtils_1.getAggregations)(section)['subSections'];
143
+ const subSectionItems = (0, modelUtils_1.getAggregations)(subSectionsAggregation);
144
+ Object.entries(subSectionItems).forEach(([subSectionKey, subSection]) => {
145
+ const subSectionId = getSectionIdentifier(subSection) ?? `${parentSectionId}_${subSectionKey}`;
146
+ subSections.push({
147
+ id: subSectionId,
148
+ isTable: !!subSection.isTable,
149
+ custom: !!subSection.custom,
150
+ order: subSection?.order ?? -1 // put a negative order number to signal that order was not in spec
151
+ });
152
+ });
153
+ return subSections;
154
+ }
106
155
  /**
107
156
  * Gets the identifier of a section for OPA5 tests.
108
157
  *
@@ -113,14 +162,14 @@ function getSectionIdentifier(section) {
113
162
  return getSectionIdentifierFromKey(section) ?? getSectionIdentifierFromTitle(section);
114
163
  }
115
164
  /**
116
- * Gets the identifier of a section from the 'ID' entry in the schema keys for OPA5 tests.
165
+ * Gets the identifier of a section from the 'ID' or 'Key' entry in the schema keys for OPA5 tests.
117
166
  * If no such entry is found, undefined is returned.
118
167
  *
119
168
  * @param section - section entry from ux specification
120
- * @returns identifier of the section for OPA5 tests; can be undefined if no 'ID' entry is found
169
+ * @returns identifier of the section for OPA5 tests; can be undefined if no 'ID' or 'Key' entry is found
121
170
  */
122
171
  function getSectionIdentifierFromKey(section) {
123
- const keyEntry = section?.schema?.keys?.find((key) => key.name === 'ID');
172
+ const keyEntry = section?.schema?.keys?.find((key) => key.name === 'ID' || key.name === 'Key');
124
173
  return keyEntry ? keyEntry.value.replace('#', '::') : undefined;
125
174
  }
126
175
  /**
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": "0.7.96",
4
+ "version": "0.7.97",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -27,9 +27,9 @@
27
27
  "@sap/ux-specification": "1.144.0",
28
28
  "@sap-ux/edmx-parser": "0.10.0",
29
29
  "@sap-ux/annotation-converter": "0.10.21",
30
+ "@sap-ux/ui5-application-writer": "1.8.3",
30
31
  "@sap-ux/logger": "0.8.4",
31
- "@sap-ux/project-access": "1.35.17",
32
- "@sap-ux/ui5-application-writer": "1.8.3"
32
+ "@sap-ux/project-access": "1.35.17"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/ejs": "3.1.5",
@@ -59,6 +59,22 @@ sap.ui.define([
59
59
  });
60
60
  <% } -%>
61
61
 
62
+ <% if (bodySections?.length > 0) { -%>
63
+ opaTest("Check body sections of the Object Page", function (Given, When, Then) {
64
+ Then.onThe<%- name%>.iCheckNumberOfSections(<%- bodySections.length %>);
65
+ <% bodySections.forEach(function(section) { -%>
66
+ When.onThe<%- name%>.iGoToSection({ section: "<%- section.id %>" });
67
+ Then.onThe<%- name%>.iCheckSection({ section: "<%- section.id %>" });
68
+ <% if (section?.subSections?.length > 0) { -%>
69
+ <% section.subSections.forEach(function(subSection) { -%>
70
+ When.onThe<%- name%>.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
71
+ Then.onThe<%- name%>.iCheckSubSection({ section: "<%- subSection.id %>" });
72
+ <% }) -%>
73
+ <% } -%>
74
+ <% }) -%>
75
+ });
76
+ <% } -%>
77
+
62
78
  opaTest("Teardown", function (Given, When, Then) {
63
79
  // Cleanup
64
80
  Given.iTearDownMyApp();