@sapui5/sap.fe.test 1.101.1 → 1.102.2

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.
@@ -0,0 +1,174 @@
1
+ /*
2
+ * ! SAP UI development toolkit for HTML5 (SAPUI5)
3
+ (c) Copyright 2009-2021 SAP SE. All rights reserved
4
+
5
+ */
6
+ sap.ui.define(
7
+ ["./DialogAssertions", "sap/ui/test/OpaBuilder", "sap/fe/test/builder/FEBuilder", "sap/fe/test/Utils"],
8
+ function (DialogAssertions, OpaBuilder, FEBuilder, Utils) {
9
+ "use strict";
10
+
11
+ /**
12
+ * Constructs a new DialogMassEditAssertions instance.
13
+ *
14
+ * @param {sap.fe.test.builder.DialogBuilder} oDialogBuilder The {@link sap.fe.test.builder.DialogBuilder} instance used to interact with the UI
15
+ * @param {string} [vDialogDescription] Description (optional) of the dialog to be used for logging messages
16
+ * @returns {sap.fe.test.api.DialogMassEditAssertions} The new instance
17
+ * @extends sap.fe.test.api.DialogAssertions
18
+ * @alias sap.fe.test.api.DialogMassEditAssertions
19
+ * @class
20
+ * @hideconstructor
21
+ * @private
22
+ */
23
+ var DialogMassEditAssertions = function (oDialogBuilder, vDialogDescription) {
24
+ return DialogAssertions.call(this, oDialogBuilder, vDialogDescription, 0);
25
+ };
26
+ DialogMassEditAssertions.prototype = Object.create(DialogAssertions.prototype);
27
+ DialogMassEditAssertions.prototype.constructor = DialogMassEditAssertions;
28
+ DialogMassEditAssertions.prototype.isAction = false;
29
+
30
+ /**
31
+ * A mass edit field identifier
32
+ *
33
+ * @typedef {object} MassEditFieldIdentifier
34
+ * @property {string} property The name of the property
35
+ * @name sap.fe.test.api.MassEditFieldIdentifier
36
+ * @private
37
+ */
38
+
39
+ /**
40
+ * A mass edit field value
41
+ *
42
+ * @typedef {object} MassEditValue
43
+ * @property {string} dropDownText The dropdown text for the selection
44
+ * @property {string} rawText The raw text for the selection
45
+ * @name sap.fe.test.api.MassEditValue
46
+ * @private
47
+ */
48
+
49
+ /**
50
+ * Check the value of the defined filter field.
51
+ *
52
+ * @param {string | sap.fe.test.api.MassEditFieldIdentifier} vMassEditFieldIdentifier The identifier for the mass edit field
53
+ * @param {string | sap.fe.test.api.MassEditValue} vMassEditValue The new target value
54
+ * @param {object} [mState] The state of the mass edit field
55
+ * @param {object} [mProperties] The Properties of the mass edit field
56
+ * @returns {object} The result of the {@link sap.ui.test.Opa5#waitFor} function, to be used for chained statements
57
+ * @private
58
+ */
59
+ DialogMassEditAssertions.prototype.iCheckField = function (vMassEditFieldIdentifier, vMassEditValue, mState, mProperties) {
60
+ var that = this,
61
+ sProperty = Utils.isOfType(vMassEditFieldIdentifier, String) ? vMassEditFieldIdentifier : vMassEditFieldIdentifier.property,
62
+ vValue =
63
+ vMassEditValue &&
64
+ (Utils.isOfType(vMassEditValue, String) ? vMassEditValue : vMassEditValue.rawText || vMassEditValue.dropDownText),
65
+ fieldRegEx = new RegExp("^MED(.*)" + sProperty + "$", "gi");
66
+ var sControlType;
67
+
68
+ var vTest = FEBuilder.create(this.getOpaInstance()).isDialogElement();
69
+ var vIdMatcher = FEBuilder.Matchers.id(fieldRegEx);
70
+ var vMatcher = [FEBuilder.Matchers.states(mState), vIdMatcher];
71
+ if (mState && mState.visible === false) {
72
+ // two possibilities for non-visible action: either visible property is false, or the control wasn't rendered at all
73
+ vMatcher = OpaBuilder.Matchers.some(vMatcher, OpaBuilder.Matchers.not(vIdMatcher));
74
+ vTest = vTest.has(vMatcher);
75
+ } else {
76
+ vTest = vTest
77
+ .has(vMatcher)
78
+ .hasProperties(mProperties)
79
+ .check(function (aSelect) {
80
+ sControlType = aSelect && aSelect[0] && aSelect[0].getMetadata().getName();
81
+ return (
82
+ aSelect.length === 1 &&
83
+ (sControlType === "sap.m.ComboBox" || sControlType === "sap.fe.core.controls.MassEditSelect")
84
+ );
85
+ })
86
+ .success(function (aSelect) {
87
+ var oSelect = aSelect[0],
88
+ oRet = OpaBuilder.create().hasId(oSelect.getId());
89
+
90
+ if (sControlType === "sap.m.ComboBox") {
91
+ oRet = oRet.hasProperties({ value: vValue });
92
+ } else if (sControlType === "sap.fe.core.controls.MassEditSelect") {
93
+ oRet = oRet.has(function (oSelectControl) {
94
+ return oSelectControl.getSelectedItem() ? oSelectControl.getSelectedItem().getText() === vValue : false;
95
+ });
96
+ }
97
+
98
+ return oRet
99
+ .description(
100
+ Utils.formatMessage(
101
+ "Value selection '{3}' found for '{0}' in mass edit dialog '{1}'",
102
+ sProperty,
103
+ that.getIdentifier(),
104
+ vValue.toString()
105
+ )
106
+ )
107
+ .execute();
108
+ })
109
+ .description(
110
+ Utils.formatMessage("Mass edit dropdown for '{0}' found in dialog '{1}'", sProperty, that.getIdentifier())
111
+ );
112
+ }
113
+
114
+ return that.prepareResult(vTest.execute());
115
+ };
116
+
117
+ /**
118
+ * Check the suggestions of the defined filter field.
119
+ *
120
+ * @param {string | sap.fe.test.api.MassEditFieldIdentifier} vMassEditFieldIdentifier The identifier for the mass edit field
121
+ * @param {string | sap.fe.test.api.MassEditValue} vMassEditValue The new target value
122
+ * @param {object} [mState] The state of the mass edit field
123
+ * @param {object} [mProperties] The Properties of the mass edit field
124
+ * @param {boolean} [bExists] Should the suggestion exist. Default is true
125
+ * @returns {object} The result of the {@link sap.ui.test.Opa5#waitFor} function, to be used for chained statements
126
+ * @private
127
+ */
128
+ DialogMassEditAssertions.prototype.iCheckFieldSuggestions = function (
129
+ vMassEditFieldIdentifier,
130
+ vMassEditValue,
131
+ mState,
132
+ mProperties,
133
+ bExists
134
+ ) {
135
+ var that = this,
136
+ sProperty = Utils.isOfType(vMassEditFieldIdentifier, String) ? vMassEditFieldIdentifier : vMassEditFieldIdentifier.property,
137
+ vValue =
138
+ vMassEditValue &&
139
+ (Utils.isOfType(vMassEditValue, String) ? vMassEditValue : vMassEditValue.dropDownText || vMassEditValue.rawText),
140
+ fieldRegEx = new RegExp("^MED(.*)" + sProperty + "$", "gi");
141
+
142
+ return that.prepareResult(
143
+ FEBuilder.create(this.getOpaInstance())
144
+ .isDialogElement()
145
+ .hasId(fieldRegEx)
146
+ .hasState(mState)
147
+ .hasProperties(mProperties)
148
+ .check(function (aSelect) {
149
+ var oRet = false,
150
+ oSelect = aSelect && aSelect[0],
151
+ sControlType = aSelect && aSelect[0] && aSelect[0].getMetadata().getName();
152
+
153
+ if (
154
+ aSelect.length === 1 &&
155
+ (sControlType === "sap.m.ComboBox" || sControlType === "sap.fe.core.controls.MassEditSelect")
156
+ ) {
157
+ var aItems = oSelect.getItems(),
158
+ iIndex = (aItems || []).findIndex(function (oItem) {
159
+ return oItem.getText() === vValue;
160
+ }),
161
+ bFound = iIndex != -1;
162
+
163
+ oRet = (bExists !== false) === bFound;
164
+ }
165
+ return oRet;
166
+ })
167
+ .description(Utils.formatMessage("Mass edit dropdown for '{0}' found in dialog '{1}'", sProperty, that.getIdentifier()))
168
+ .execute()
169
+ );
170
+ };
171
+
172
+ return DialogMassEditAssertions;
173
+ }
174
+ );
@@ -5,7 +5,7 @@
5
5
  */
6
6
  sap.ui.define(
7
7
  [],
8
- function() {
8
+ function () {
9
9
  "use strict";
10
10
 
11
11
  /**
@@ -69,7 +69,16 @@ sap.ui.define(
69
69
  * @type {string}
70
70
  * @public
71
71
  */
72
- Create: "Create"
72
+ Create: "Create",
73
+ /**
74
+ * A dialog used for mass edit
75
+ *
76
+ * @name sap.fe.test.api.DialogType.MassEdit
77
+ * @constant
78
+ * @type {string}
79
+ * @private
80
+ */
81
+ MassEdit: "MassEdit"
73
82
  };
74
83
  },
75
84
  true
@@ -12,7 +12,7 @@ sap.ui.define(
12
12
  "sap/fe/test/builder/MacroFieldBuilder",
13
13
  "./APIHelper"
14
14
  ],
15
- function(HeaderAPI, Utils, OpaBuilder, FEBuilder, FieldBuilder, APIHelper) {
15
+ function (HeaderAPI, Utils, OpaBuilder, FEBuilder, FieldBuilder, APIHelper) {
16
16
  "use strict";
17
17
 
18
18
  /**
@@ -26,7 +26,7 @@ sap.ui.define(
26
26
  * @hideconstructor
27
27
  * @public
28
28
  */
29
- var HeaderAssertions = function(oHeaderBuilder, vHeaderDescription) {
29
+ var HeaderAssertions = function (oHeaderBuilder, vHeaderDescription) {
30
30
  this._sObjectPageLayoutId = vHeaderDescription.id;
31
31
  this._sHeaderId = vHeaderDescription.headerId;
32
32
  this._sHeaderContentId = vHeaderDescription.headerContentId;
@@ -48,7 +48,7 @@ sap.ui.define(
48
48
  *
49
49
  * @public
50
50
  */
51
- HeaderAssertions.prototype.iCheckAction = function(vActionIdentifier, mState) {
51
+ HeaderAssertions.prototype.iCheckAction = function (vActionIdentifier, mState) {
52
52
  var oOverflowToolbarBuilder = this.createOverflowToolbarBuilder(this._sObjectPageLayoutId);
53
53
  return this.prepareResult(
54
54
  oOverflowToolbarBuilder
@@ -66,7 +66,7 @@ sap.ui.define(
66
66
  *
67
67
  * @public
68
68
  */
69
- HeaderAssertions.prototype.iCheckEdit = function(mState) {
69
+ HeaderAssertions.prototype.iCheckEdit = function (mState) {
70
70
  return this.iCheckAction({ service: "StandardAction", action: "Edit", unbound: true }, mState);
71
71
  };
72
72
 
@@ -78,7 +78,7 @@ sap.ui.define(
78
78
  *
79
79
  * @public
80
80
  */
81
- HeaderAssertions.prototype.iCheckDelete = function(mState) {
81
+ HeaderAssertions.prototype.iCheckDelete = function (mState) {
82
82
  return this.iCheckAction({ service: "StandardAction", action: "Delete", unbound: true }, mState);
83
83
  };
84
84
 
@@ -90,7 +90,7 @@ sap.ui.define(
90
90
  *
91
91
  * @public
92
92
  */
93
- HeaderAssertions.prototype.iCheckRelatedApps = function(mState) {
93
+ HeaderAssertions.prototype.iCheckRelatedApps = function (mState) {
94
94
  return this.iCheckAction({ service: "fe", action: "RelatedApps", unbound: true }, mState);
95
95
  };
96
96
 
@@ -102,7 +102,7 @@ sap.ui.define(
102
102
  *
103
103
  * @public
104
104
  */
105
- HeaderAssertions.prototype.iCheckMenuAction = function(vAction) {
105
+ HeaderAssertions.prototype.iCheckMenuAction = function (vAction) {
106
106
  return this.prepareResult(APIHelper.createMenuActionCheckBuilder(vAction).execute());
107
107
  };
108
108
 
@@ -115,15 +115,15 @@ sap.ui.define(
115
115
  *
116
116
  * @ui5-restricted
117
117
  */
118
- HeaderAssertions.prototype.iCheckNumberOfHeaderContentItems = function(iNumberOfItems, bIncludeHidden) {
118
+ HeaderAssertions.prototype.iCheckNumberOfHeaderContentItems = function (iNumberOfItems, bIncludeHidden) {
119
119
  var oHeaderContentBuilder = this.getObjectPageDynamicHeaderContentBuilder(this._sHeaderContentId);
120
120
 
121
121
  return this.prepareResult(
122
122
  oHeaderContentBuilder
123
- .has(function(oOPHeaderContent) {
123
+ .has(function (oOPHeaderContent) {
124
124
  var aItems = oOPHeaderContent.getContent()[0].getItems();
125
125
  if (!bIncludeHidden) {
126
- aItems = aItems.filter(function(oControl) {
126
+ aItems = aItems.filter(function (oControl) {
127
127
  return oControl.getVisible();
128
128
  });
129
129
  }
@@ -151,7 +151,7 @@ sap.ui.define(
151
151
  *
152
152
  * @public
153
153
  */
154
- HeaderAssertions.prototype.iCheckFieldInFieldGroup = function(vFieldIdentifier, vValue, mState) {
154
+ HeaderAssertions.prototype.iCheckFieldInFieldGroup = function (vFieldIdentifier, vValue, mState) {
155
155
  var aArguments = Utils.parseArguments([Object, [Array, String], Object], arguments),
156
156
  sFieldId =
157
157
  (vFieldIdentifier.targetAnnotation
@@ -184,7 +184,7 @@ sap.ui.define(
184
184
  *
185
185
  * @ui5-restricted
186
186
  */
187
- HeaderAssertions.prototype.iCheckDataPoint = function(sTitle, sValue) {
187
+ HeaderAssertions.prototype.iCheckDataPoint = function (sTitle, sValue) {
188
188
  var oHeaderContentBuilder = this.getObjectPageDynamicHeaderContentBuilder(this._sHeaderContentId);
189
189
 
190
190
  return this.prepareResult(
@@ -194,7 +194,7 @@ sap.ui.define(
194
194
  OpaBuilder.create(this)
195
195
  .hasType("sap.m.ObjectNumber")
196
196
  .hasProperties({ number: sValue })
197
- .has(function(oObjectNumber) {
197
+ .has(function (oObjectNumber) {
198
198
  return oObjectNumber.getParent();
199
199
  })
200
200
  .hasAggregationProperties("items", { text: sTitle })
@@ -216,24 +216,18 @@ sap.ui.define(
216
216
  *
217
217
  * @public
218
218
  */
219
- HeaderAssertions.prototype.iCheckTitle = function(sTitle, sDescription) {
219
+ HeaderAssertions.prototype.iCheckTitle = function (sTitle, sDescription) {
220
220
  var oHeaderTitleBuilder = this.getObjectPageDynamicHeaderTitleBuilder(this._sObjectPageLayoutId);
221
221
  return this.prepareResult(
222
222
  oHeaderTitleBuilder
223
223
  .hasConditional(
224
224
  sTitle !== undefined,
225
- OpaBuilder.Matchers.childrenMatcher(
226
- OpaBuilder.create(this)
227
- .hasType("sap.m.Title")
228
- .hasProperties({ text: sTitle })
229
- )
225
+ OpaBuilder.Matchers.childrenMatcher(OpaBuilder.create(this).hasType("sap.m.Title").hasProperties({ text: sTitle }))
230
226
  )
231
227
  .hasConditional(
232
228
  sDescription !== undefined,
233
229
  OpaBuilder.Matchers.childrenMatcher(
234
- OpaBuilder.create(this)
235
- .hasType("sap.m.Label")
236
- .hasProperties({ text: sDescription })
230
+ OpaBuilder.create(this).hasType("sap.m.Label").hasProperties({ text: sDescription })
237
231
  )
238
232
  )
239
233
  .description(
@@ -253,7 +247,7 @@ sap.ui.define(
253
247
  *
254
248
  * @public
255
249
  */
256
- HeaderAssertions.prototype.iCheckPaginatorDown = function(mState) {
250
+ HeaderAssertions.prototype.iCheckPaginatorDown = function (mState) {
257
251
  return this.prepareResult(
258
252
  this.createPaginatorBuilder(
259
253
  OpaBuilder.Matchers.properties({ icon: "sap-icon://navigation-down-arrow" }),
@@ -273,7 +267,7 @@ sap.ui.define(
273
267
  *
274
268
  * @public
275
269
  */
276
- HeaderAssertions.prototype.iCheckPaginatorUp = function(mState) {
270
+ HeaderAssertions.prototype.iCheckPaginatorUp = function (mState) {
277
271
  return this.prepareResult(
278
272
  this.createPaginatorBuilder(
279
273
  OpaBuilder.Matchers.properties({ icon: "sap-icon://navigation-up-arrow" }),
@@ -294,7 +288,7 @@ sap.ui.define(
294
288
  * @returns {object} The result of the {@link sap.ui.test.Opa5#waitFor} function, to be used for chained statements
295
289
  * @ui5-restricted
296
290
  */
297
- HeaderAssertions.prototype.iCheckMicroChart = function(vMicroChartIdentifier, sUoMLabel) {
291
+ HeaderAssertions.prototype.iCheckMicroChart = function (vMicroChartIdentifier, sUoMLabel) {
298
292
  var oOpaBuilder = OpaBuilder.create(this.getOpaInstance());
299
293
 
300
294
  if (!Utils.isOfType(vMicroChartIdentifier, String)) {
@@ -349,7 +343,7 @@ sap.ui.define(
349
343
  *
350
344
  * @public
351
345
  */
352
- HeaderAssertions.prototype.iCheckHeaderFacet = function(vFacetIdentifier, mState) {
346
+ HeaderAssertions.prototype.iCheckHeaderFacet = function (vFacetIdentifier, mState) {
353
347
  var aArguments = Utils.parseArguments([[Object, String], Object], arguments),
354
348
  oHeaderContentBuilder = this.getObjectPageDynamicHeaderContentBuilder(this._sHeaderContentId),
355
349
  sId = new RegExp("fe::HeaderFacetContainer::" + vFacetIdentifier.facetId + "$");
@@ -362,13 +356,7 @@ sap.ui.define(
362
356
 
363
357
  return this.prepareResult(
364
358
  oHeaderContentBuilder
365
- .has(
366
- OpaBuilder.Matchers.childrenMatcher(
367
- FEBuilder.create(this.getOpaInstance())
368
- .hasId(sId)
369
- .hasState(mState)
370
- )
371
- )
359
+ .has(OpaBuilder.Matchers.childrenMatcher(FEBuilder.create(this.getOpaInstance()).hasId(sId).hasState(mState)))
372
360
  .description(Utils.formatMessage("Checking Header Facet '{0}' with state='{1}'", aArguments[0], aArguments[1]))
373
361
  .execute()
374
362
  );
@@ -390,7 +378,7 @@ sap.ui.define(
390
378
  *
391
379
  * @ui5-restricted
392
380
  */
393
- HeaderAssertions.prototype.iCheckBreadCrumb = function(sLink) {
381
+ HeaderAssertions.prototype.iCheckBreadCrumb = function (sLink) {
394
382
  var oFEBuilder = FEBuilder.create(this.getOpaInstance()).hasId(this._sBreadCrumbId);
395
383
 
396
384
  if (sLink !== undefined && sLink.length > 0) {
@@ -416,7 +404,7 @@ sap.ui.define(
416
404
  *
417
405
  * @public
418
406
  */
419
- HeaderAssertions.prototype.iCheckSaveAsTile = function(mState) {
407
+ HeaderAssertions.prototype.iCheckSaveAsTile = function (mState) {
420
408
  var oOverflowToolbarBuilder = this.createOverflowToolbarBuilder(this._sObjectPageLayoutId),
421
409
  sShareId = "fe::Share";
422
410
 
@@ -442,7 +430,7 @@ sap.ui.define(
442
430
  *
443
431
  * @public
444
432
  */
445
- HeaderAssertions.prototype.iCheckSendEmail = function(mState) {
433
+ HeaderAssertions.prototype.iCheckSendEmail = function (mState) {
446
434
  var oOverflowToolbarBuilder = this.createOverflowToolbarBuilder(this._sObjectPageLayoutId),
447
435
  sShareId = "fe::Share";
448
436
 
@@ -471,7 +459,7 @@ sap.ui.define(
471
459
  *
472
460
  * @private
473
461
  */
474
- HeaderAssertions.prototype.iCheckLink = function(vLinkIdentifier, mState) {
462
+ HeaderAssertions.prototype.iCheckLink = function (vLinkIdentifier, mState) {
475
463
  // TODO this function needs to aligned with onForm().iCheckLink - for now vLinkIdentifier must be the link text!
476
464
  var aArguments = Utils.parseArguments([String, Object], arguments),
477
465
  oHeaderContentBuilder = this.getObjectPageDynamicHeaderContentBuilder(this._sHeaderContentId);
@@ -479,10 +467,7 @@ sap.ui.define(
479
467
  oHeaderContentBuilder
480
468
  .has(
481
469
  OpaBuilder.Matchers.childrenMatcher(
482
- FEBuilder.create()
483
- .hasType("sap.m.Link")
484
- .hasProperties({ text: vLinkIdentifier })
485
- .hasState(aArguments[1])
470
+ FEBuilder.create().hasType("sap.m.Link").hasProperties({ text: vLinkIdentifier }).hasState(aArguments[1])
486
471
  )
487
472
  )
488
473
  .description(Utils.formatMessage("Checking link '{0}' with state='{1}'", aArguments[0], aArguments[1]))
@@ -490,6 +475,56 @@ sap.ui.define(
490
475
  );
491
476
  };
492
477
 
478
+ /**
479
+ * Checks the number of users collaborating in the draft.
480
+ *
481
+ * @param {number} iExpectedNumber The expected number of users
482
+ * @returns {object} The result of the {@link sap.ui.test.Opa5#waitFor} function, to be used for chained statements
483
+ *
484
+ * @ui5-restricted
485
+ */
486
+ HeaderAssertions.prototype.iCheckNumberOfCollaboratingUsers = function (iExpectedNumber) {
487
+ var objectPageBuilder = FEBuilder.create(this.getOpaInstance()).hasId(this._sObjectPageLayoutId);
488
+
489
+ return this.prepareResult(
490
+ objectPageBuilder
491
+ .hasChildren(
492
+ FEBuilder.create(this)
493
+ .hasType("sap.uxap.ObjectPageDynamicHeaderTitle")
494
+ .hasChildren(
495
+ FEBuilder.create(this)
496
+ .hasType("sap.m.Avatar")
497
+ .checkNumberOfMatches(iExpectedNumber + 1) // +1 because of avatar to add a user
498
+ )
499
+ )
500
+ .description(Utils.formatMessage("Checking number of collaborating user: {0}", iExpectedNumber))
501
+ .execute()
502
+ );
503
+ };
504
+
505
+ /**
506
+ * Checks if a collaborating user is present.
507
+ *
508
+ * @param {string} sInitials The initials of the user (displayed in the avatar)
509
+ * @returns {object} The result of the {@link sap.ui.test.Opa5#waitFor} function, to be used for chained statements
510
+ *
511
+ * @ui5-restricted
512
+ */
513
+ HeaderAssertions.prototype.iCheckCollaboratingUser = function (sInitials) {
514
+ var objectPageBuilder = FEBuilder.create(this.getOpaInstance()).hasId(this._sObjectPageLayoutId);
515
+
516
+ return this.prepareResult(
517
+ objectPageBuilder
518
+ .hasChildren(
519
+ FEBuilder.create(this)
520
+ .hasType("sap.uxap.ObjectPageDynamicHeaderTitle")
521
+ .hasChildren(FEBuilder.create(this).hasType("sap.m.Avatar").hasProperties({ initials: sInitials }))
522
+ )
523
+ .description(Utils.formatMessage("Checking collaborating user with initials '{0}'", sInitials))
524
+ .execute()
525
+ );
526
+ };
527
+
493
528
  return HeaderAssertions;
494
529
  }
495
530
  );