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

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
@@ -135,6 +135,11 @@ export type AppFeatures = {
135
135
  objectPages?: ObjectPageFeatures[];
136
136
  fpm?: FPMFeatures;
137
137
  };
138
+ export type FormField = {
139
+ fieldGroupQualifier?: string;
140
+ field?: string;
141
+ targetAnnotation?: string;
142
+ };
138
143
  export type HeaderSectionFeatureData = {
139
144
  facetId?: string;
140
145
  title?: string;
@@ -143,10 +148,7 @@ export type HeaderSectionFeatureData = {
143
148
  microChart?: boolean;
144
149
  form?: boolean;
145
150
  stashed?: boolean | string;
146
- fields?: {
147
- fieldGroupQualifier?: string;
148
- field?: string;
149
- }[];
151
+ fields?: FormField[];
150
152
  };
151
153
  export interface ButtonState {
152
154
  visible: boolean;
@@ -10,6 +10,7 @@ export interface AggregationItem extends TreeAggregation {
10
10
  name: string;
11
11
  value: string;
12
12
  }[];
13
+ dataType?: string;
13
14
  };
14
15
  }
15
16
  export interface FieldItem extends AggregationItem {
@@ -204,16 +204,38 @@ function getHeaderSectionFormFields(section) {
204
204
  if (fields) {
205
205
  Object.keys(fields).forEach((fieldKey) => {
206
206
  const field = fields[fieldKey];
207
- if (field?.name) {
208
- formFields.push({
209
- fieldGroupQualifier: getFieldGroupQualifier(formAggregation),
210
- field: field.schema.keys.find((key) => key.name === 'Value')?.value
211
- });
207
+ const fieldData = getFormFieldData(field, formAggregation);
208
+ if (fieldData) {
209
+ formFields.push(fieldData);
212
210
  }
213
211
  });
214
212
  }
215
213
  return formFields;
216
214
  }
215
+ /**
216
+ * Gets field data for a form field in a header section for OPA5 tests, including its identifier, bound property, and target annotation.
217
+ *
218
+ * @param field - field entry from ux specification
219
+ * @param formAggregation - form aggregation entry from ux specification, used to get field group qualifier for the field
220
+ * @returns field data including its identifier, bound property, and target annotation for OPA5 tests; can be undefined if the field type is not supported or necessary information is missing
221
+ */
222
+ function getFormFieldData(field, formAggregation) {
223
+ if (!field.name) {
224
+ return undefined;
225
+ }
226
+ let [_, propertyName, targetAnnotation] = field.name.split('::');
227
+ // fall back to Value property in case of malformed or otherwise irregular field name
228
+ if (!propertyName) {
229
+ propertyName = field.schema.keys.find((key) => key.name === 'Value')?.value;
230
+ }
231
+ const fieldIdentifier = {
232
+ fieldGroupQualifier: getFieldGroupQualifier(formAggregation),
233
+ field: propertyName,
234
+ targetAnnotation: targetAnnotation
235
+ };
236
+ // avoid creating identifier if field property could not be determined
237
+ return fieldIdentifier.field ? fieldIdentifier : undefined;
238
+ }
217
239
  /**
218
240
  * Gets the field group qualifier of a form aggregation for OPA5 tests.
219
241
  *
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.97",
4
+ "version": "0.7.98",
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",
31
30
  "@sap-ux/logger": "0.8.4",
32
- "@sap-ux/project-access": "1.35.17"
31
+ "@sap-ux/project-access": "1.35.17",
32
+ "@sap-ux/ui5-application-writer": "1.8.3"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/ejs": "3.1.5",
@@ -51,6 +51,7 @@ sap.ui.define([
51
51
  Then.onThe<%- name%>.onHeader().iCheckFieldInFieldGroup({
52
52
  fieldGroup: "FieldGroup::<%- field.fieldGroupQualifier %>",
53
53
  field: "<%- field.field %>",
54
+ targetAnnotation: "<%- field.targetAnnotation %>"
54
55
  });
55
56
  <% }) -%>
56
57
  <% } -%>