@sap-ux/ui5-test-writer 0.7.106 → 0.7.108

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
@@ -81,17 +81,30 @@ export type ObjectPageNavigationParents = {
81
81
  parentOPName?: string;
82
82
  parentOPTableSection?: string;
83
83
  };
84
+ export type SectionFormField = {
85
+ property: string;
86
+ };
87
+ export type TableColumn = {
88
+ header?: string;
89
+ };
90
+ export type TableColumnFeatureData = Record<string, TableColumn>;
84
91
  export type BodySubSectionFeatureData = {
85
92
  id: string;
93
+ navigationProperty?: string;
86
94
  isTable: boolean;
87
95
  custom: boolean;
88
96
  order: number;
97
+ fields: SectionFormField[];
98
+ tableColumns: TableColumnFeatureData;
89
99
  };
90
100
  export type BodySectionFeatureData = {
91
101
  id: string;
102
+ navigationProperty?: string;
92
103
  isTable: boolean;
93
104
  custom: boolean;
94
105
  order: number;
106
+ fields: SectionFormField[];
107
+ tableColumns: TableColumnFeatureData;
95
108
  subSections: BodySubSectionFeatureData[];
96
109
  };
97
110
  export type ObjectPageFeatures = {
@@ -107,11 +107,4 @@ export declare function getSelectionFieldItems(selectionFieldsAgg: TreeAggregati
107
107
  * @returns An array of filter field descriptions.
108
108
  */
109
109
  export declare function getFilterFields(pageModel: TreeModel): TreeAggregations;
110
- /**
111
- * Retrieves the table columns aggregation from the given tree model.
112
- *
113
- * @param pageModel - The tree model containing table column definitions.
114
- * @returns The table columns aggregation object.
115
- */
116
- export declare function getTableColumns(pageModel: TreeModel): TreeAggregations;
117
110
  //# sourceMappingURL=modelUtils.d.ts.map
@@ -8,11 +8,11 @@ exports.getFPMFeatures = getFPMFeatures;
8
8
  exports.getAggregations = getAggregations;
9
9
  exports.getSelectionFieldItems = getSelectionFieldItems;
10
10
  exports.getFilterFields = getFilterFields;
11
- exports.getTableColumns = getTableColumns;
12
11
  const project_access_1 = require("@sap-ux/project-access");
13
12
  const page_1 = require("@sap/ux-specification/dist/types/src/common/page");
14
13
  const objectPageUtils_1 = require("./objectPageUtils");
15
14
  const listReportUtils_1 = require("./listReportUtils");
15
+ const tableUtils_1 = require("./tableUtils");
16
16
  /**
17
17
  * Gets app features from the application model using ux-specification.
18
18
  *
@@ -74,39 +74,6 @@ async function getAppFeatures(basePath, fs, log, metadata, manifest) {
74
74
  }
75
75
  return featureData;
76
76
  }
77
- /**
78
- * Gets identifier of a column for OPA5 tests.
79
- * If the column is custom, the identifier is taken from the 'Key' entry in the schema keys.
80
- * If the column is not custom, the identifier is taken from the 'Value' entry in the schema keys.
81
- * If no such entry is found, undefined is returned.
82
- *
83
- * @param column - column module from ux specification
84
- * @param column.custom boolean indicating whether the column is custom
85
- * @param column.schema schema of the column
86
- * @param column.schema.keys keys of the column; expected to have an entry with the name 'Key' or 'Value'
87
- * @returns identifier of the column for OPA5 tests; can be the name or index
88
- */
89
- function getColumnIdentifier(column) {
90
- const key = column.custom ? 'Key' : 'Value';
91
- const keyEntry = column.schema.keys.find((entry) => entry.name === key);
92
- return keyEntry?.value;
93
- }
94
- /**
95
- * Transforms column aggregations from the ux specification model into a map of columns for OPA5 tests.
96
- *
97
- * @param columnAggregations column aggregations from the ux specification model
98
- * @returns a map of columns for OPA5 tests
99
- */
100
- function transformTableColumns(columnAggregations) {
101
- const columns = {};
102
- Object.values(columnAggregations).forEach((columnAggregation, index) => {
103
- columns[getColumnIdentifier(columnAggregation) ?? index] = {
104
- header: columnAggregation.description
105
- // TODO possibly more reliable properties could be used?
106
- };
107
- });
108
- return columns;
109
- }
110
77
  /**
111
78
  * Retrieves table column data from the page model using ux-specification.
112
79
  *
@@ -117,8 +84,7 @@ function transformTableColumns(columnAggregations) {
117
84
  function getTableColumnData(pageModel, log) {
118
85
  let tableColumns = {};
119
86
  try {
120
- const columnAggregations = getTableColumns(pageModel);
121
- tableColumns = transformTableColumns(columnAggregations);
87
+ tableColumns = (0, tableUtils_1.extractTableColumnsFromNode)(pageModel.root);
122
88
  }
123
89
  catch (error) {
124
90
  log?.debug(error);
@@ -218,17 +184,4 @@ function getFilterFields(pageModel) {
218
184
  const selectionFieldsAggregations = getAggregations(selectionFields);
219
185
  return selectionFieldsAggregations;
220
186
  }
221
- /**
222
- * Retrieves the table columns aggregation from the given tree model.
223
- *
224
- * @param pageModel - The tree model containing table column definitions.
225
- * @returns The table columns aggregation object.
226
- */
227
- function getTableColumns(pageModel) {
228
- const table = getAggregations(pageModel.root)['table'];
229
- const tableAggregations = getAggregations(table);
230
- const columns = tableAggregations['columns'];
231
- const columnAggregations = getAggregations(columns);
232
- return columnAggregations;
233
- }
234
187
  //# sourceMappingURL=modelUtils.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getObjectPageFeatures = getObjectPageFeatures;
4
4
  exports.getObjectPages = getObjectPages;
5
5
  const modelUtils_1 = require("./modelUtils");
6
+ const tableUtils_1 = require("./tableUtils");
6
7
  const page_1 = require("@sap/ux-specification/dist/types/src/common/page");
7
8
  /**
8
9
  * Extracts feature data for object pages from the application model.
@@ -121,9 +122,12 @@ function extractObjectPageBodySectionsData(objectPage) {
121
122
  const subSections = extractBodySubSectionsData(section, sectionId);
122
123
  bodySections.push({
123
124
  id: sectionId,
125
+ navigationProperty: getNavigationPropertyFromKey(sectionKey),
124
126
  isTable: !!section.isTable,
125
127
  custom: !!section.custom,
126
128
  order: section?.order ?? -1, // put a negative order number to signal that order was not in spec
129
+ fields: section.custom || section.isTable ? [] : extractFormFields(section),
130
+ tableColumns: section.custom || !section.isTable ? {} : (0, tableUtils_1.extractTableColumnsFromNode)(section),
127
131
  subSections
128
132
  });
129
133
  });
@@ -145,13 +149,50 @@ function extractBodySubSectionsData(section, parentSectionId) {
145
149
  const subSectionId = getSectionIdentifier(subSection) ?? `${parentSectionId}_${subSectionKey}`;
146
150
  subSections.push({
147
151
  id: subSectionId,
152
+ navigationProperty: getNavigationPropertyFromKey(subSectionKey),
148
153
  isTable: !!subSection.isTable,
149
154
  custom: !!subSection.custom,
150
- order: subSection?.order ?? -1 // put a negative order number to signal that order was not in spec
155
+ order: subSection?.order ?? -1, // put a negative order number to signal that order was not in spec
156
+ fields: subSection.custom || subSection.isTable ? [] : extractFormFields(subSection),
157
+ tableColumns: subSection.custom || !subSection.isTable ? {} : (0, tableUtils_1.extractTableColumnsFromNode)(subSection)
151
158
  });
152
159
  });
153
160
  return subSections;
154
161
  }
162
+ /**
163
+ * Extracts form field property paths from a body sub-section's form aggregation.
164
+ *
165
+ * @param subSection - body sub-section entry from the application model
166
+ * @returns array of form field property paths for use with iCheckField({ property })
167
+ */
168
+ function extractFormFields(subSection) {
169
+ const fields = [];
170
+ const formAggregation = (0, modelUtils_1.getAggregations)(subSection)['form'];
171
+ if (!formAggregation) {
172
+ return fields;
173
+ }
174
+ const fieldsAggregation = (0, modelUtils_1.getAggregations)(formAggregation)['fields'];
175
+ const fieldItems = (0, modelUtils_1.getAggregations)(fieldsAggregation);
176
+ Object.values(fieldItems).forEach((field) => {
177
+ const property = field.schema?.keys?.find((key) => key.name === 'Value')?.value;
178
+ if (property) {
179
+ fields.push({ property });
180
+ }
181
+ });
182
+ return fields;
183
+ }
184
+ /**
185
+ * Extracts the OData navigation property from a spec model section key.
186
+ * Section keys for table sections follow the pattern `_NavProperty::@annotation`, so the
187
+ * navigation property is the part before `::` when it starts with an underscore.
188
+ *
189
+ * @param sectionKey - the key of the section in the spec model aggregations
190
+ * @returns navigation property (e.g. '_Booking'), or undefined for non-navigation sections
191
+ */
192
+ function getNavigationPropertyFromKey(sectionKey) {
193
+ const prefix = sectionKey.split('::')[0];
194
+ return prefix.startsWith('_') ? prefix : undefined;
195
+ }
155
196
  /**
156
197
  * Gets the identifier of a section for OPA5 tests.
157
198
  *
@@ -0,0 +1,42 @@
1
+ import type { TreeAggregation, TreeAggregations } from '@sap/ux-specification/dist/types/src/parser';
2
+ import type { TableColumnFeatureData } from '../types';
3
+ type ColumnModelItem = {
4
+ custom?: boolean;
5
+ description?: string;
6
+ schema: {
7
+ keys: {
8
+ name: string;
9
+ value: string;
10
+ }[];
11
+ };
12
+ };
13
+ export type ColumnAggregations = TreeAggregations & {
14
+ [key: string]: ColumnModelItem;
15
+ };
16
+ /**
17
+ * Gets the identifier of a column for OPA5 tests.
18
+ * Custom columns use the 'Key' entry; standard columns use the 'Value' entry from the schema keys.
19
+ *
20
+ * @param column - column item from ux specification
21
+ * @returns identifier of the column for OPA5 tests; undefined if no matching key entry is found
22
+ */
23
+ export declare function getColumnIdentifier(column: ColumnModelItem): string | undefined;
24
+ /**
25
+ * Transforms column aggregations from the ux specification model into a map of columns for OPA5 tests.
26
+ * Each column entry includes the column header label for display verification.
27
+ *
28
+ * @param columnAggregations - column aggregations from the ux specification model
29
+ * @returns a map of column identifiers to column state objects for use with iCheckColumns()
30
+ */
31
+ export declare function transformTableColumns(columnAggregations: ColumnAggregations): TableColumnFeatureData;
32
+ /**
33
+ * Extracts table column data from a spec model node that contains a 'table' aggregation.
34
+ * Covers both page-level nodes (List Report, FPM) via their root and section-level nodes
35
+ * (Object Page body sections) — both are TreeAggregation nodes that expose a 'table' aggregation.
36
+ *
37
+ * @param node - tree aggregation node that exposes a 'table' aggregation
38
+ * @returns a map of column identifiers to column state objects for use with iCheckColumns()
39
+ */
40
+ export declare function extractTableColumnsFromNode(node: TreeAggregation): TableColumnFeatureData;
41
+ export {};
42
+ //# sourceMappingURL=tableUtils.d.ts.map
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getColumnIdentifier = getColumnIdentifier;
4
+ exports.transformTableColumns = transformTableColumns;
5
+ exports.extractTableColumnsFromNode = extractTableColumnsFromNode;
6
+ const modelUtils_1 = require("./modelUtils");
7
+ /**
8
+ * Gets the identifier of a column for OPA5 tests.
9
+ * Custom columns use the 'Key' entry; standard columns use the 'Value' entry from the schema keys.
10
+ *
11
+ * @param column - column item from ux specification
12
+ * @returns identifier of the column for OPA5 tests; undefined if no matching key entry is found
13
+ */
14
+ function getColumnIdentifier(column) {
15
+ const key = column.custom ? 'Key' : 'Value';
16
+ return column.schema.keys.find((k) => k.name === key)?.value;
17
+ }
18
+ /**
19
+ * Transforms column aggregations from the ux specification model into a map of columns for OPA5 tests.
20
+ * Each column entry includes the column header label for display verification.
21
+ *
22
+ * @param columnAggregations - column aggregations from the ux specification model
23
+ * @returns a map of column identifiers to column state objects for use with iCheckColumns()
24
+ */
25
+ function transformTableColumns(columnAggregations) {
26
+ const columns = {};
27
+ Object.values(columnAggregations).forEach((column, index) => {
28
+ const id = getColumnIdentifier(column) ?? String(index);
29
+ const state = {};
30
+ if (column.description) {
31
+ state['header'] = column.description;
32
+ }
33
+ columns[id] = state;
34
+ });
35
+ return columns;
36
+ }
37
+ /**
38
+ * Extracts table column data from a spec model node that contains a 'table' aggregation.
39
+ * Covers both page-level nodes (List Report, FPM) via their root and section-level nodes
40
+ * (Object Page body sections) — both are TreeAggregation nodes that expose a 'table' aggregation.
41
+ *
42
+ * @param node - tree aggregation node that exposes a 'table' aggregation
43
+ * @returns a map of column identifiers to column state objects for use with iCheckColumns()
44
+ */
45
+ function extractTableColumnsFromNode(node) {
46
+ const tableAggregation = (0, modelUtils_1.getAggregations)(node)['table'];
47
+ if (!tableAggregation) {
48
+ return {};
49
+ }
50
+ const columnsAggregation = (0, modelUtils_1.getAggregations)(tableAggregation)['columns'];
51
+ if (!columnsAggregation) {
52
+ return {};
53
+ }
54
+ const columnItems = (0, modelUtils_1.getAggregations)(columnsAggregation);
55
+ return transformTableColumns(columnItems);
56
+ }
57
+ //# sourceMappingURL=tableUtils.js.map
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.106",
4
+ "version": "0.7.108",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,7 +29,7 @@
29
29
  "@sap-ux/annotation-converter": "0.10.21",
30
30
  "@sap-ux/ui5-application-writer": "1.8.7",
31
31
  "@sap-ux/logger": "0.8.5",
32
- "@sap-ux/project-access": "1.35.21"
32
+ "@sap-ux/project-access": "1.36.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/ejs": "3.1.5",
@@ -74,8 +74,25 @@ sap.ui.define([
74
74
  <% section.subSections.forEach(function(subSection) { -%>
75
75
  //When.onThe<%- name%>.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
76
76
  Then.onThe<%- name%>.iCheckSubSection({ section: "<%- subSection.id %>" });
77
+ <% if (subSection.fields && subSection.fields.length > 0) { -%>
78
+ <% subSection.fields.forEach(function(field) { -%>
79
+ Then.onThe<%- name%>.onForm({ section: "<%- subSection.id %>" }).iCheckField({ property: "<%- field.property %>" });
77
80
  <% }) -%>
78
81
  <% } -%>
82
+ <% if (subSection.tableColumns && Object.keys(subSection.tableColumns).length > 0 && subSection.navigationProperty) { -%>
83
+ Then.onThe<%- name%>.onTable({ property: "<%- subSection.navigationProperty %>" }).iCheckColumns(<%- JSON.stringify(subSection.tableColumns) %>);
84
+ <% } -%>
85
+ <% }) -%>
86
+ <% } else { -%>
87
+ <% if (section.fields && section.fields.length > 0) { -%>
88
+ <% section.fields.forEach(function(field) { -%>
89
+ Then.onThe<%- name%>.onForm({ section: "<%- section.id %>" }).iCheckField({ property: "<%- field.property %>" });
90
+ <% }) -%>
91
+ <% } -%>
92
+ <% if (section.tableColumns && Object.keys(section.tableColumns).length > 0 && section.navigationProperty) { -%>
93
+ Then.onThe<%- name%>.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(<%- JSON.stringify(section.tableColumns) %>);
94
+ <% } -%>
95
+ <% } -%>
79
96
  <% }) -%>
80
97
  });
81
98
  <% } -%>