@mtes-mct/monitor-ui 11.9.0 → 11.10.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/GlobalStyle.d.ts.map +1 -1
  3. package/assets/stylesheets/rsuite-override.css +2 -461
  4. package/components/Dialog/Action.d.ts.map +1 -1
  5. package/components/Dialog/index.d.ts +1 -1
  6. package/components/Dialog/index.d.ts.map +1 -1
  7. package/components/Message.d.ts +1 -1
  8. package/components/Message.d.ts.map +1 -1
  9. package/components/Notifier/index.d.ts +1 -1
  10. package/components/Notifier/index.d.ts.map +1 -1
  11. package/cypress/global.d.ts +18 -23
  12. package/cypress/index.js +420 -878
  13. package/cypress/index.js.map +1 -1
  14. package/elements/FieldError.d.ts +1 -1
  15. package/fields/CheckPicker.d.ts +5 -4
  16. package/fields/CheckPicker.d.ts.map +1 -1
  17. package/fields/Checkbox.d.ts +15 -2
  18. package/fields/Checkbox.d.ts.map +1 -1
  19. package/fields/CoordinatesInput/DDCoordinatesInput.d.ts +4 -3
  20. package/fields/CoordinatesInput/DDCoordinatesInput.d.ts.map +1 -1
  21. package/fields/CoordinatesInput/DMDCoordinatesInput.d.ts +4 -3
  22. package/fields/CoordinatesInput/DMDCoordinatesInput.d.ts.map +1 -1
  23. package/fields/CoordinatesInput/DMSCoordinatesInput.d.ts +4 -3
  24. package/fields/CoordinatesInput/DMSCoordinatesInput.d.ts.map +1 -1
  25. package/fields/CoordinatesInput/index.d.ts +11 -4
  26. package/fields/CoordinatesInput/index.d.ts.map +1 -1
  27. package/fields/DatePicker/CalendarPicker.d.ts +0 -1
  28. package/fields/DatePicker/CalendarPicker.d.ts.map +1 -1
  29. package/fields/DatePicker/index.d.ts +7 -4
  30. package/fields/DatePicker/index.d.ts.map +1 -1
  31. package/fields/DateRangePicker/DateInput.d.ts +6 -0
  32. package/fields/DateRangePicker/DateInput.d.ts.map +1 -1
  33. package/fields/DateRangePicker/NumberInput.d.ts +2 -0
  34. package/fields/DateRangePicker/NumberInput.d.ts.map +1 -1
  35. package/fields/DateRangePicker/RangeCalendarPicker.d.ts.map +1 -1
  36. package/fields/DateRangePicker/TimeInput.d.ts +6 -0
  37. package/fields/DateRangePicker/TimeInput.d.ts.map +1 -1
  38. package/fields/DateRangePicker/constants.d.ts.map +1 -1
  39. package/fields/DateRangePicker/index.d.ts +8 -5
  40. package/fields/DateRangePicker/index.d.ts.map +1 -1
  41. package/fields/MultiCascader/index.d.ts +21 -0
  42. package/fields/MultiCascader/index.d.ts.map +1 -0
  43. package/fields/MultiCascader/utils.d.ts +34 -0
  44. package/fields/MultiCascader/utils.d.ts.map +1 -0
  45. package/fields/MultiCheckbox.d.ts +4 -2
  46. package/fields/MultiCheckbox.d.ts.map +1 -1
  47. package/fields/MultiRadio.d.ts +5 -4
  48. package/fields/MultiRadio.d.ts.map +1 -1
  49. package/fields/MultiSelect.d.ts +5 -5
  50. package/fields/MultiSelect.d.ts.map +1 -1
  51. package/fields/MultiZoneEditor/index.d.ts +10 -6
  52. package/fields/MultiZoneEditor/index.d.ts.map +1 -1
  53. package/fields/NumberInput.d.ts +5 -2
  54. package/fields/NumberInput.d.ts.map +1 -1
  55. package/fields/Radio.d.ts +15 -0
  56. package/fields/Radio.d.ts.map +1 -0
  57. package/fields/RichBooleanCheckbox/index.d.ts +1 -1
  58. package/fields/RichBooleanCheckbox/index.d.ts.map +1 -1
  59. package/fields/Search.d.ts +9 -5
  60. package/fields/Search.d.ts.map +1 -1
  61. package/fields/Select.d.ts +6 -7
  62. package/fields/Select.d.ts.map +1 -1
  63. package/fields/TextInput.d.ts +3 -2
  64. package/fields/TextInput.d.ts.map +1 -1
  65. package/fields/Textarea.d.ts +5 -2
  66. package/fields/Textarea.d.ts.map +1 -1
  67. package/fields/Toggle/index.d.ts +16 -0
  68. package/fields/Toggle/index.d.ts.map +1 -0
  69. package/fields/Toggle/utils.d.ts +5 -0
  70. package/fields/Toggle/utils.d.ts.map +1 -0
  71. package/fields/shared/StyledRsuiteCalendarBox.d.ts +2 -0
  72. package/fields/shared/StyledRsuiteCalendarBox.d.ts.map +1 -0
  73. package/fields/shared/StyledRsuitePickerBox.d.ts +10 -0
  74. package/fields/shared/StyledRsuitePickerBox.d.ts.map +1 -0
  75. package/fields/shared/types.d.ts +14 -0
  76. package/fields/shared/types.d.ts.map +1 -0
  77. package/fields/shared/utils.d.ts +7 -0
  78. package/fields/shared/utils.d.ts.map +1 -0
  79. package/formiks/FormikCheckPicker.d.ts +5 -0
  80. package/formiks/FormikCheckPicker.d.ts.map +1 -0
  81. package/formiks/FormikCheckbox.d.ts.map +1 -1
  82. package/formiks/FormikCoordinatesInput.d.ts.map +1 -1
  83. package/formiks/FormikDatePicker.d.ts +2 -6
  84. package/formiks/FormikDatePicker.d.ts.map +1 -1
  85. package/formiks/FormikDateRangePicker.d.ts.map +1 -1
  86. package/formiks/FormikMultiCascader.d.ts +5 -0
  87. package/formiks/FormikMultiCascader.d.ts.map +1 -0
  88. package/formiks/FormikToggle.d.ts +4 -0
  89. package/formiks/FormikToggle.d.ts.map +1 -0
  90. package/hooks/usePressEscapeEffect.d.ts +2 -0
  91. package/hooks/usePressEscapeEffect.d.ts.map +1 -0
  92. package/index.d.ts +20 -8
  93. package/index.d.ts.map +1 -1
  94. package/index.js +16448 -15615
  95. package/index.js.map +1 -1
  96. package/package.json +2 -2
  97. package/types/definitions.d.ts +17 -3
  98. package/types/definitions.d.ts.map +1 -1
  99. package/types/internals.d.ts +34 -4
  100. package/types/internals.d.ts.map +1 -1
  101. package/utils/assert.d.ts +18 -0
  102. package/utils/assert.d.ts.map +1 -0
  103. package/utils/ensure.d.ts +7 -0
  104. package/utils/ensure.d.ts.map +1 -0
  105. package/utils/getRsuiteDataItemValueFromOptionValue.d.ts +6 -0
  106. package/utils/getRsuiteDataItemValueFromOptionValue.d.ts.map +1 -0
  107. package/utils/getRsuiteDataItemValuesFromOptionValues.d.ts +7 -0
  108. package/utils/getRsuiteDataItemValuesFromOptionValues.d.ts.map +1 -0
  109. package/utils/getRsuiteDataItemsFromOptions.d.ts +7 -0
  110. package/utils/getRsuiteDataItemsFromOptions.d.ts.map +1 -0
  111. package/utils/getSelectedOptionValueFromSelectedRsuiteDataItemValue.d.ts +7 -0
  112. package/utils/getSelectedOptionValueFromSelectedRsuiteDataItemValue.d.ts.map +1 -0
  113. package/utils/getSelectedOptionValuesFromSelectedRsuiteDataItemValues.d.ts +7 -0
  114. package/utils/getSelectedOptionValuesFromSelectedRsuiteDataItemValues.d.ts.map +1 -0
  115. package/fields/Toggle.d.ts +0 -13
  116. package/fields/Toggle.d.ts.map +0 -1
  117. package/utils/getRsuiteDataFromOptions.d.ts +0 -4
  118. package/utils/getRsuiteDataFromOptions.d.ts.map +0 -1
  119. package/utils/getRsuiteValueFromOptionValue.d.ts +0 -3
  120. package/utils/getRsuiteValueFromOptionValue.d.ts.map +0 -1
  121. package/utils/getRsuiteValuesFromOptionValues.d.ts +0 -3
  122. package/utils/getRsuiteValuesFromOptionValues.d.ts.map +0 -1
package/cypress/index.js CHANGED
@@ -45,7 +45,7 @@ function findElementBytext(selector, text, { fallbackSelector, index = 0, inElem
45
45
  return foundElement;
46
46
  }
47
47
 
48
- const RETRIES$2 = 5;
48
+ const RETRIES$1 = 5;
49
49
  function findButton(label, preSelector, { index, prevSubjectElement }) {
50
50
  const buttonElement = findElementBytext(`${preSelector}button`, label, {
51
51
  index,
@@ -71,7 +71,7 @@ function findButton(label, preSelector, { index, prevSubjectElement }) {
71
71
  }
72
72
  return undefined;
73
73
  }
74
- function clickButton(prevSubjectElements, label, { index = 0, withinSelector } = {}, leftRetries = RETRIES$2) {
74
+ function clickButton(prevSubjectElements, label, { index = 0, withinSelector } = {}, leftRetries = RETRIES$1) {
75
75
  const prevSubjectElement = prevSubjectElements ? prevSubjectElements[0] : undefined;
76
76
  if (prevSubjectElements && !prevSubjectElements[0]) {
77
77
  throw new Error('`prevSubjectElements[0]` is undefined.');
@@ -86,7 +86,7 @@ function clickButton(prevSubjectElements, label, { index = 0, withinSelector } =
86
86
  }
87
87
  if (leftRetries > 0) {
88
88
  return cy.wait(250).then(()=>{
89
- cy.log(`Retrying (${RETRIES$2 - leftRetries + 1} / ${RETRIES$2})...`);
89
+ cy.log(`Retrying (${RETRIES$1 - leftRetries + 1} / ${RETRIES$1})...`);
90
90
  return clickButton(prevSubjectElements, label, {
91
91
  index,
92
92
  withinSelector
@@ -110,598 +110,85 @@ function clickLink(linkText) {
110
110
  });
111
111
  }
112
112
 
113
- function _isPlaceholder(a) {
114
- return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true;
115
- }
116
-
117
- /**
118
- * Optimized internal one-arity curry function.
119
- *
120
- * @private
121
- * @category Function
122
- * @param {Function} fn The function to curry.
123
- * @return {Function} The curried function.
124
- */
125
-
126
- function _curry1(fn) {
127
- return function f1(a) {
128
- if (arguments.length === 0 || _isPlaceholder(a)) {
129
- return f1;
130
- } else {
131
- return fn.apply(this, arguments);
132
- }
133
- };
134
- }
135
-
136
- /**
137
- * Optimized internal two-arity curry function.
138
- *
139
- * @private
140
- * @category Function
141
- * @param {Function} fn The function to curry.
142
- * @return {Function} The curried function.
143
- */
144
-
145
- function _curry2(fn) {
146
- return function f2(a, b) {
147
- switch (arguments.length) {
148
- case 0:
149
- return f2;
150
-
151
- case 1:
152
- return _isPlaceholder(a) ? f2 : _curry1(function (_b) {
153
- return fn(a, _b);
154
- });
155
-
156
- default:
157
- return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function (_a) {
158
- return fn(_a, b);
159
- }) : _isPlaceholder(b) ? _curry1(function (_b) {
160
- return fn(a, _b);
161
- }) : fn(a, b);
162
- }
163
- };
164
- }
165
-
166
- /**
167
- * Tests whether or not an object is an array.
168
- *
169
- * @private
170
- * @param {*} val The object to test.
171
- * @return {Boolean} `true` if `val` is an array, `false` otherwise.
172
- * @example
173
- *
174
- * _isArray([]); //=> true
175
- * _isArray(null); //=> false
176
- * _isArray({}); //=> false
177
- */
178
- var _isArray = Array.isArray || function _isArray(val) {
179
- return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]';
180
- };
181
-
182
- function _arrayFromIterator(iter) {
183
- var list = [];
184
- var next;
185
-
186
- while (!(next = iter.next()).done) {
187
- list.push(next.value);
188
- }
189
-
190
- return list;
191
- }
192
-
193
- function _includesWith(pred, x, list) {
194
- var idx = 0;
195
- var len = list.length;
196
-
197
- while (idx < len) {
198
- if (pred(x, list[idx])) {
199
- return true;
200
- }
201
-
202
- idx += 1;
203
- }
204
-
205
- return false;
206
- }
207
-
208
- function _functionName(f) {
209
- // String(x => x) evaluates to "x => x", so the pattern may not match.
210
- var match = String(f).match(/^function (\w*)/);
211
- return match == null ? '' : match[1];
212
- }
213
-
214
- function _has(prop, obj) {
215
- return Object.prototype.hasOwnProperty.call(obj, prop);
216
- }
217
-
218
- // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
219
- function _objectIs(a, b) {
220
- // SameValue algorithm
221
- if (a === b) {
222
- // Steps 1-5, 7-10
223
- // Steps 6.b-6.e: +0 != -0
224
- return a !== 0 || 1 / a === 1 / b;
225
- } else {
226
- // Step 6.a: NaN == NaN
227
- return a !== a && b !== b;
228
- }
229
- }
230
-
231
- var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
232
-
233
- var toString = Object.prototype.toString;
234
-
235
- var _isArguments =
236
- /*#__PURE__*/
237
- function () {
238
- return toString.call(arguments) === '[object Arguments]' ? function _isArguments(x) {
239
- return toString.call(x) === '[object Arguments]';
240
- } : function _isArguments(x) {
241
- return _has('callee', x);
242
- };
243
- }();
244
-
245
- var hasEnumBug = !
246
- /*#__PURE__*/
247
- {
248
- toString: null
249
- }.propertyIsEnumerable('toString');
250
- var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug
251
-
252
- var hasArgsEnumBug =
253
- /*#__PURE__*/
254
- function () {
255
-
256
- return arguments.propertyIsEnumerable('length');
257
- }();
258
-
259
- var contains = function contains(list, item) {
260
- var idx = 0;
261
-
262
- while (idx < list.length) {
263
- if (list[idx] === item) {
264
- return true;
265
- }
266
-
267
- idx += 1;
268
- }
269
-
270
- return false;
271
- };
272
- /**
273
- * Returns a list containing the names of all the enumerable own properties of
274
- * the supplied object.
275
- * Note that the order of the output array is not guaranteed to be consistent
276
- * across different JS platforms.
277
- *
278
- * @func
279
- * @memberOf R
280
- * @since v0.1.0
281
- * @category Object
282
- * @sig {k: v} -> [k]
283
- * @param {Object} obj The object to extract properties from
284
- * @return {Array} An array of the object's own properties.
285
- * @see R.keysIn, R.values, R.toPairs
286
- * @example
287
- *
288
- * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
289
- */
290
-
291
-
292
- var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ?
293
- /*#__PURE__*/
294
- _curry1(function keys(obj) {
295
- return Object(obj) !== obj ? [] : Object.keys(obj);
296
- }) :
297
- /*#__PURE__*/
298
- _curry1(function keys(obj) {
299
- if (Object(obj) !== obj) {
300
- return [];
301
- }
302
-
303
- var prop, nIdx;
304
- var ks = [];
305
-
306
- var checkArgsLength = hasArgsEnumBug && _isArguments(obj);
307
-
308
- for (prop in obj) {
309
- if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
310
- ks[ks.length] = prop;
311
- }
312
- }
313
-
314
- if (hasEnumBug) {
315
- nIdx = nonEnumerableProps.length - 1;
316
-
317
- while (nIdx >= 0) {
318
- prop = nonEnumerableProps[nIdx];
319
-
320
- if (_has(prop, obj) && !contains(ks, prop)) {
321
- ks[ks.length] = prop;
322
- }
323
-
324
- nIdx -= 1;
325
- }
326
- }
327
-
328
- return ks;
329
- });
330
-
331
- /**
332
- * Gives a single-word string description of the (native) type of a value,
333
- * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
334
- * attempt to distinguish user Object types any further, reporting them all as
335
- * 'Object'.
336
- *
337
- * @func
338
- * @memberOf R
339
- * @since v0.8.0
340
- * @category Type
341
- * @sig * -> String
342
- * @param {*} val The value to test
343
- * @return {String}
344
- * @example
345
- *
346
- * R.type({}); //=> "Object"
347
- * R.type(1); //=> "Number"
348
- * R.type(false); //=> "Boolean"
349
- * R.type('s'); //=> "String"
350
- * R.type(null); //=> "Null"
351
- * R.type([]); //=> "Array"
352
- * R.type(/[A-z]/); //=> "RegExp"
353
- * R.type(() => {}); //=> "Function"
354
- * R.type(async () => {}); //=> "AsyncFunction"
355
- * R.type(undefined); //=> "Undefined"
356
- */
357
-
358
- var type =
359
- /*#__PURE__*/
360
- _curry1(function type(val) {
361
- return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
362
- });
363
-
364
- /**
365
- * private _uniqContentEquals function.
366
- * That function is checking equality of 2 iterator contents with 2 assumptions
367
- * - iterators lengths are the same
368
- * - iterators values are unique
369
- *
370
- * false-positive result will be returned for comparison of, e.g.
371
- * - [1,2,3] and [1,2,3,4]
372
- * - [1,1,1] and [1,2,3]
373
- * */
374
-
375
- function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
376
- var a = _arrayFromIterator(aIterator);
377
-
378
- var b = _arrayFromIterator(bIterator);
379
-
380
- function eq(_a, _b) {
381
- return _equals(_a, _b, stackA.slice(), stackB.slice());
382
- } // if *a* array contains any element that is not included in *b*
383
-
384
-
385
- return !_includesWith(function (b, aItem) {
386
- return !_includesWith(eq, aItem, b);
387
- }, b, a);
388
- }
389
-
390
- function _equals(a, b, stackA, stackB) {
391
- if (_objectIs$1(a, b)) {
392
- return true;
393
- }
394
-
395
- var typeA = type(a);
396
-
397
- if (typeA !== type(b)) {
398
- return false;
399
- }
400
-
401
- if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
402
- return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a);
403
- }
404
-
405
- if (typeof a.equals === 'function' || typeof b.equals === 'function') {
406
- return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a);
407
- }
408
-
409
- switch (typeA) {
410
- case 'Arguments':
411
- case 'Array':
412
- case 'Object':
413
- if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') {
414
- return a === b;
415
- }
416
-
417
- break;
418
-
419
- case 'Boolean':
420
- case 'Number':
421
- case 'String':
422
- if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
423
- return false;
424
- }
425
-
426
- break;
427
-
428
- case 'Date':
429
- if (!_objectIs$1(a.valueOf(), b.valueOf())) {
430
- return false;
431
- }
432
-
433
- break;
434
-
435
- case 'Error':
436
- return a.name === b.name && a.message === b.message;
437
-
438
- case 'RegExp':
439
- if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
440
- return false;
441
- }
442
-
443
- break;
444
- }
445
-
446
- var idx = stackA.length - 1;
447
-
448
- while (idx >= 0) {
449
- if (stackA[idx] === a) {
450
- return stackB[idx] === b;
451
- }
452
-
453
- idx -= 1;
454
- }
455
-
456
- switch (typeA) {
457
- case 'Map':
458
- if (a.size !== b.size) {
459
- return false;
460
- }
461
-
462
- return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
463
-
464
- case 'Set':
465
- if (a.size !== b.size) {
466
- return false;
467
- }
468
-
469
- return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
470
-
471
- case 'Arguments':
472
- case 'Array':
473
- case 'Object':
474
- case 'Boolean':
475
- case 'Number':
476
- case 'String':
477
- case 'Date':
478
- case 'Error':
479
- case 'RegExp':
480
- case 'Int8Array':
481
- case 'Uint8Array':
482
- case 'Uint8ClampedArray':
483
- case 'Int16Array':
484
- case 'Uint16Array':
485
- case 'Int32Array':
486
- case 'Uint32Array':
487
- case 'Float32Array':
488
- case 'Float64Array':
489
- case 'ArrayBuffer':
490
- break;
491
-
492
- default:
493
- // Values of other types are only equal if identical.
494
- return false;
495
- }
496
-
497
- var keysA = keys(a);
498
-
499
- if (keysA.length !== keys(b).length) {
500
- return false;
501
- }
502
-
503
- var extendedStackA = stackA.concat([a]);
504
- var extendedStackB = stackB.concat([b]);
505
- idx = keysA.length - 1;
506
-
507
- while (idx >= 0) {
508
- var key = keysA[idx];
509
-
510
- if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
511
- return false;
512
- }
513
-
514
- idx -= 1;
515
- }
516
-
517
- return true;
518
- }
519
-
520
- /**
521
- * Returns `true` if its arguments are equivalent, `false` otherwise. Handles
522
- * cyclical data structures.
523
- *
524
- * Dispatches symmetrically to the `equals` methods of both arguments, if
525
- * present.
526
- *
527
- * @func
528
- * @memberOf R
529
- * @since v0.15.0
530
- * @category Relation
531
- * @sig a -> b -> Boolean
532
- * @param {*} a
533
- * @param {*} b
534
- * @return {Boolean}
535
- * @example
536
- *
537
- * R.equals(1, 1); //=> true
538
- * R.equals(1, '1'); //=> false
539
- * R.equals([1, 2, 3], [1, 2, 3]); //=> true
540
- *
541
- * const a = {}; a.v = a;
542
- * const b = {}; b.v = b;
543
- * R.equals(a, b); //=> true
544
- */
545
-
546
- var equals =
547
- /*#__PURE__*/
548
- _curry2(function equals(a, b) {
549
- return _equals(a, b, [], []);
550
- });
551
-
552
- function _isObject(x) {
553
- return Object.prototype.toString.call(x) === '[object Object]';
554
- }
555
-
556
- function _isString(x) {
557
- return Object.prototype.toString.call(x) === '[object String]';
558
- }
559
-
560
- /**
561
- * Tests whether or not an object is a typed array.
562
- *
563
- * @private
564
- * @param {*} val The object to test.
565
- * @return {Boolean} `true` if `val` is a typed array, `false` otherwise.
566
- * @example
567
- *
568
- * _isTypedArray(new Uint8Array([])); //=> true
569
- * _isTypedArray(new Float32Array([])); //=> true
570
- * _isTypedArray([]); //=> false
571
- * _isTypedArray(null); //=> false
572
- * _isTypedArray({}); //=> false
573
- */
574
- function _isTypedArray(val) {
575
- var type = Object.prototype.toString.call(val);
576
- return type === '[object Uint8ClampedArray]' || type === '[object Int8Array]' || type === '[object Uint8Array]' || type === '[object Int16Array]' || type === '[object Uint16Array]' || type === '[object Int32Array]' || type === '[object Uint32Array]' || type === '[object Float32Array]' || type === '[object Float64Array]' || type === '[object BigInt64Array]' || type === '[object BigUint64Array]';
113
+ function findElementParentBySelector(element, parentSelector, index = 0) {
114
+ let foundElement;
115
+ let foundElementIndex = 0;
116
+ const potentialParents = Cypress.$(element).parents(parentSelector);
117
+ potentialParents// eslint-disable-next-line func-names
118
+ .each(function() {
119
+ if (foundElementIndex === index) {
120
+ foundElement = this;
121
+ return;
122
+ }
123
+ foundElementIndex += 1;
124
+ });
125
+ return foundElement;
577
126
  }
578
127
 
579
- /**
580
- * Returns the empty value of its argument's type. Ramda defines the empty
581
- * value of Array (`[]`), Object (`{}`), String (`''`),
582
- * TypedArray (`Uint8Array []`, `Float32Array []`, etc), and Arguments. Other
583
- * types are supported if they define `<Type>.empty`,
584
- * `<Type>.prototype.empty` or implement the
585
- * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
586
- *
587
- * Dispatches to the `empty` method of the first argument, if present.
588
- *
589
- * @func
590
- * @memberOf R
591
- * @since v0.3.0
592
- * @category Function
593
- * @sig a -> a
594
- * @param {*} x
595
- * @return {*}
596
- * @example
597
- *
598
- * R.empty(Just(42)); //=> Nothing()
599
- * R.empty([1, 2, 3]); //=> []
600
- * R.empty('unicorns'); //=> ''
601
- * R.empty({x: 1, y: 2}); //=> {}
602
- * R.empty(Uint8Array.from('123')); //=> Uint8Array []
603
- */
604
-
605
- var empty =
606
- /*#__PURE__*/
607
- _curry1(function empty(x) {
608
- return x != null && typeof x['fantasy-land/empty'] === 'function' ? x['fantasy-land/empty']() : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function' ? x.constructor['fantasy-land/empty']() : x != null && typeof x.empty === 'function' ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === 'function' ? x.constructor.empty() : _isArray(x) ? [] : _isString(x) ? '' : _isObject(x) ? {} : _isArguments(x) ? function () {
609
- return arguments;
610
- }() : _isTypedArray(x) ? x.constructor.from('') : void 0 // else
611
- ;
612
- });
613
-
614
- /**
615
- * Returns `true` if the given value is its type's empty value; `false`
616
- * otherwise.
617
- *
618
- * @func
619
- * @memberOf R
620
- * @since v0.1.0
621
- * @category Logic
622
- * @sig a -> Boolean
623
- * @param {*} x
624
- * @return {Boolean}
625
- * @see R.empty
626
- * @example
627
- *
628
- * R.isEmpty([1, 2, 3]); //=> false
629
- * R.isEmpty([]); //=> true
630
- * R.isEmpty(''); //=> true
631
- * R.isEmpty(null); //=> false
632
- * R.isEmpty({}); //=> true
633
- * R.isEmpty({length: 0}); //=> false
634
- * R.isEmpty(Uint8Array.from('')); //=> true
635
- */
636
-
637
- var isEmpty =
638
- /*#__PURE__*/
639
- _curry1(function isEmpty(x) {
640
- return x != null && equals(x, empty(x));
641
- });
642
-
643
- var isEmpty$1 = isEmpty;
644
-
645
- function checkCheckbox(checkboxInputElement, value) {
128
+ function checkCheckbox(fieldElement, value, _label) {
129
+ cy.wrap(fieldElement).scrollIntoView({
130
+ offset: {
131
+ left: 0,
132
+ top: -100
133
+ }
134
+ });
646
135
  if (value) {
647
- cy.wrap(checkboxInputElement).scrollIntoView().check({
136
+ cy.wrap(fieldElement).find('input[type="checkbox"]').check({
648
137
  force: true
649
- });
138
+ }).wait(250);
650
139
  } else {
651
- cy.wrap(checkboxInputElement).scrollIntoView().uncheck({
140
+ cy.wrap(fieldElement).find('input[type="checkbox"]').uncheck({
652
141
  force: true
653
- });
142
+ }).wait(250);
654
143
  }
655
144
  }
656
145
 
657
- const RETRIES$1 = 5;
658
- function checkMultiCheckboxOptions(fieldsetElement, values, leftRetries = RETRIES$1) {
659
- cy.wrap(fieldsetElement).scrollIntoView();
146
+ function checkMultiCheckboxOptions(fieldsetElement, values, _label) {
147
+ cy.wrap(fieldsetElement).scrollIntoView({
148
+ offset: {
149
+ left: 0,
150
+ top: -100
151
+ }
152
+ });
660
153
  cy.wrap(fieldsetElement).find('input[type="checkbox"]').uncheck({
661
154
  force: true
662
155
  }).wait(250);
663
- if (fieldsetElement.querySelector('[aria-checked="true"]') && leftRetries > 0) {
664
- cy.wait(250).then(()=>{
665
- cy.log(`Retrying (${RETRIES$1 - leftRetries + 1} / ${RETRIES$1})...`);
666
- checkMultiCheckboxOptions(fieldsetElement, values, leftRetries - 1);
667
- });
156
+ // If `values` is undefined, we don't need to check anything
157
+ if (!values) {
668
158
  return;
669
159
  }
670
- if (values) {
671
- values.forEach((value)=>{
672
- cy.wrap(fieldsetElement).find('label').contains(value).find('input[type="checkbox"]').check({
673
- force: true
674
- });
160
+ values.forEach((value)=>{
161
+ cy.wrap(fieldsetElement).find('label').contains(value).find('input[type="checkbox"]').check({
162
+ force: true
675
163
  });
676
- }
164
+ });
165
+ cy.wait(250);
677
166
  }
678
167
 
679
- function checkMultiRadioOption(fieldsetElement, value) {
680
- cy.wrap(fieldsetElement).find('label').contains(value).find('input[type="radio"]').scrollIntoView().check({
681
- force: true
682
- });
168
+ function checkMultiRadioOption(fieldsetElement, value, _label) {
169
+ cy.wrap(fieldsetElement).scrollIntoView({
170
+ offset: {
171
+ left: 0,
172
+ top: -100
173
+ }
174
+ }).find('label').contains(value).forceClick().wait(250);
683
175
  return fieldsetElement;
684
176
  }
685
177
 
686
- function fillDatePicker(fieldsetElement, dateOrDateWithTimeTuple) {
178
+ function throwError(message) {
179
+ throw new Error(`[monitor-ui > Cypress] ${message}`);
180
+ }
181
+
182
+ function fillDatePicker(fieldsetElement, dateOrDateWithTimeTuple, _label) {
687
183
  const inputElements = fieldsetElement.querySelectorAll('input');
688
184
  if (inputElements.length !== 4 && inputElements.length !== 6) {
689
- throw new Error(`Expected to find 4 or 6 inputs within in DatePicker but found ${inputElements.length}.`);
185
+ throwError(`Expected to find 4 or 6 inputs within in DatePicker but found ${inputElements.length}.`);
690
186
  }
691
- const hasTimeInput = inputElements.length !== 4;
692
- const fieldsetElementOffsetLeft = fieldsetElement.offsetLeft ? fieldsetElement.offsetLeft : (()=>{
693
- if (!fieldsetElement.offsetParent) {
694
- throw new Error('`fieldsetElement.offsetParent` is undefined.');
695
- }
696
- return fieldsetElement.offsetParent.offsetLeft;
697
- })();
698
- const fieldsetElementOffsetTop = fieldsetElement.offsetTop !== 0 ? fieldsetElement.offsetTop : (()=>{
699
- if (!fieldsetElement.offsetParent) {
700
- throw new Error('`fieldsetElement.offsetParent` is undefined.');
701
- }
702
- return fieldsetElement.offsetParent.offsetTop;
703
- })();
187
+ const hasTimeInputs = inputElements.length === 6;
188
+ // Empty the inputs if `dateOrDateWithTimeTuple` is undefined
704
189
  if (!dateOrDateWithTimeTuple) {
190
+ // -------------------------------------------------------------------------
191
+ // Date without time
705
192
  cy.wrap(fieldsetElement).find('[aria-label="Jour"]').clear({
706
193
  force: true
707
194
  });
@@ -711,7 +198,7 @@ function fillDatePicker(fieldsetElement, dateOrDateWithTimeTuple) {
711
198
  cy.wrap(fieldsetElement).find('[aria-label="Année"]').clear({
712
199
  force: true
713
200
  });
714
- if (hasTimeInput) {
201
+ if (hasTimeInputs) {
715
202
  cy.wrap(fieldsetElement).find('[aria-label="Heure"]').clear({
716
203
  force: true
717
204
  });
@@ -719,40 +206,31 @@ function fillDatePicker(fieldsetElement, dateOrDateWithTimeTuple) {
719
206
  force: true
720
207
  });
721
208
  }
722
- cy.clickOutside(fieldsetElementOffsetLeft, fieldsetElementOffsetTop - 1);
723
- cy.wait(250);
724
- return;
725
- }
726
- const [year, month, day, hour, minute] = dateOrDateWithTimeTuple;
727
- cy.wrap(fieldsetElement).find('[aria-label="Jour"]').type(String(day).padStart(2, '0'));
728
- cy.wrap(fieldsetElement).find('[aria-label="Mois"]').type(String(month).padStart(2, '0'));
729
- cy.wrap(fieldsetElement).find('[aria-label="Année"]').type(String(year));
730
- if (hasTimeInput) {
731
- cy.wrap(fieldsetElement).find('[aria-label="Heure"]').type(String(hour).padStart(2, '0'));
732
- cy.wrap(fieldsetElement).find('[aria-label="Minute"]').type(String(minute).padStart(2, '0'));
209
+ } else {
210
+ const [year, month, day] = dateOrDateWithTimeTuple;
211
+ cy.wrap(fieldsetElement).find('[aria-label="Jour"]').type(String(day).padStart(2, '0'));
212
+ cy.wrap(fieldsetElement).find('[aria-label="Mois"]').type(String(month).padStart(2, '0'));
213
+ cy.wrap(fieldsetElement).find('[aria-label="Année"]').type(String(year));
214
+ if (hasTimeInputs) {
215
+ const [hour, minute] = dateOrDateWithTimeTuple.slice(3);
216
+ cy.wrap(fieldsetElement).find('[aria-label="Heure"]').type(String(hour).padStart(2, '0'));
217
+ cy.wrap(fieldsetElement).find('[aria-label="Minute"]').type(String(minute).padStart(2, '0'));
218
+ }
733
219
  }
734
- cy.clickOutside(fieldsetElementOffsetLeft, fieldsetElementOffsetTop - 1);
735
220
  cy.wait(250);
221
+ // Close the calendar & ranged time picker popup by pressing the escape key
222
+ cy.get('body').type('{esc}');
223
+ cy.wrap(fieldsetElement).find('.Field-DatePicker__CalendarPicker').should('not.be.visible');
224
+ cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangedTimePicker').should('not.exist');
736
225
  }
737
226
 
738
- function fillDateRangePicker(fieldsetElement, dateOrDateWithTimeTupleRange) {
227
+ function fillDateRangePicker(fieldsetElement, dateOrDateWithTimeTupleRange, _label) {
739
228
  const inputElements = fieldsetElement.querySelectorAll('input');
740
229
  if (inputElements.length !== 7 && inputElements.length !== 11) {
741
- throw new Error(`Expected to find 7 or 11 inputs within in DatePicker but found ${inputElements.length}.`);
230
+ throwError(`Expected to find 7 or 11 inputs within in DatePicker but found ${inputElements.length}.`);
742
231
  }
743
232
  const hasTimeInput = inputElements.length !== 7;
744
- const fieldsetElementOffsetLeft = fieldsetElement.offsetLeft ? fieldsetElement.offsetLeft : (()=>{
745
- if (!fieldsetElement.offsetParent) {
746
- throw new Error('`fieldsetElement.offsetParent` is undefined.');
747
- }
748
- return fieldsetElement.offsetParent.offsetLeft;
749
- })();
750
- const fieldsetElementOffsetTop = fieldsetElement.offsetTop !== 0 ? fieldsetElement.offsetTop : (()=>{
751
- if (!fieldsetElement.offsetParent) {
752
- throw new Error('`fieldsetElement.offsetParent` is undefined.');
753
- }
754
- return fieldsetElement.offsetParent.offsetTop;
755
- })();
233
+ // Empty the inputs if `dateOrDateWithTimeTupleRange` is undefined
756
234
  if (!dateOrDateWithTimeTupleRange) {
757
235
  cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').clear({
758
236
  force: true
@@ -788,348 +266,405 @@ function fillDateRangePicker(fieldsetElement, dateOrDateWithTimeTupleRange) {
788
266
  force: true
789
267
  });
790
268
  }
791
- cy.clickOutside(fieldsetElementOffsetLeft, fieldsetElementOffsetTop - 1);
792
- cy.wait(250);
793
- return;
794
- }
795
- const [startDateOrDateWithTimeTuple, endDateOrDateWithTimeTuple] = dateOrDateWithTimeTupleRange;
796
- const [startYear, startMonth, startDay, startHour, startMinute] = startDateOrDateWithTimeTuple;
797
- const [endYear, endMonth, endDay, endHour, endMinute] = endDateOrDateWithTimeTuple;
798
- cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').type(String(startDay).padStart(2, '0'));
799
- cy.wrap(fieldsetElement).find('[aria-label="Mois de début"]').type(String(startMonth).padStart(2, '0'));
800
- cy.wrap(fieldsetElement).find('[aria-label="Année de début"]').type(String(startYear));
801
- if (hasTimeInput) {
802
- cy.wrap(fieldsetElement).find('[aria-label="Heure de début"]').type(String(startHour).padStart(2, '0'));
803
- cy.wrap(fieldsetElement).find('[aria-label="Minute de début"]').type(String(startMinute).padStart(2, '0'));
804
- }
805
- cy.wrap(fieldsetElement).find('[aria-label="Jour de fin"]').type(String(endDay).padStart(2, '0'));
806
- cy.wrap(fieldsetElement).find('[aria-label="Mois de fin"]').type(String(endMonth).padStart(2, '0'));
807
- cy.wrap(fieldsetElement).find('[aria-label="Année de fin"]').type(String(endYear));
808
- if (hasTimeInput) {
809
- cy.wrap(fieldsetElement).find('[aria-label="Heure de fin"]').type(String(endHour).padStart(2, '0'));
810
- cy.wrap(fieldsetElement).find('[aria-label="Minute de fin"]').type(String(endMinute).padStart(2, '0'));
269
+ } else {
270
+ const [startDateOrDateWithTimeTuple, endDateOrDateWithTimeTuple] = dateOrDateWithTimeTupleRange;
271
+ const [startYear, startMonth, startDay, startHour, startMinute] = startDateOrDateWithTimeTuple;
272
+ const [endYear, endMonth, endDay, endHour, endMinute] = endDateOrDateWithTimeTuple;
273
+ cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').type(String(startDay).padStart(2, '0'));
274
+ cy.wrap(fieldsetElement).find('[aria-label="Mois de début"]').type(String(startMonth).padStart(2, '0'));
275
+ cy.wrap(fieldsetElement).find('[aria-label="Année de début"]').type(String(startYear));
276
+ if (hasTimeInput) {
277
+ cy.wrap(fieldsetElement).find('[aria-label="Heure de début"]').type(String(startHour).padStart(2, '0'));
278
+ cy.wrap(fieldsetElement).find('[aria-label="Minute de début"]').type(String(startMinute).padStart(2, '0'));
279
+ }
280
+ cy.wrap(fieldsetElement).find('[aria-label="Jour de fin"]').type(String(endDay).padStart(2, '0'));
281
+ cy.wrap(fieldsetElement).find('[aria-label="Mois de fin"]').type(String(endMonth).padStart(2, '0'));
282
+ cy.wrap(fieldsetElement).find('[aria-label="Année de fin"]').type(String(endYear));
283
+ if (hasTimeInput) {
284
+ cy.wrap(fieldsetElement).find('[aria-label="Heure de fin"]').type(String(endHour).padStart(2, '0'));
285
+ cy.wrap(fieldsetElement).find('[aria-label="Minute de fin"]').type(String(endMinute).padStart(2, '0'));
286
+ }
811
287
  }
812
- cy.clickOutside(fieldsetElementOffsetLeft, fieldsetElementOffsetTop - 1);
813
288
  cy.wait(250);
289
+ // Close the range calendar & ranged time picker popup by pressing the escape key
290
+ cy.get('body').type('{esc}');
291
+ cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangeCalendarPicker').should('not.be.visible');
292
+ cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangedTimePicker').should('not.exist');
814
293
  }
815
294
 
816
- function fillTextarea(textareaElement, value) {
817
- cy.wrap(textareaElement).scrollIntoView().clear({
818
- force: true
295
+ function fillNumberInput(fieldElement, value, _label) {
296
+ cy.wrap(fieldElement).scrollIntoView({
297
+ offset: {
298
+ left: 0,
299
+ top: -100
300
+ }
819
301
  });
820
- if (value) {
821
- cy.wrap(textareaElement).scrollIntoView().type(value, {
822
- delay: 1,
823
- force: true
824
- });
302
+ cy.wrap(fieldElement).find('input[type="number"]').clear({
303
+ force: true
304
+ }).wait(250);
305
+ // If `value` is undefined, we don't need to input anything
306
+ if (!value) {
307
+ return;
825
308
  }
309
+ cy.wrap(fieldElement).find('input[type="number"]').type(String(value), {
310
+ force: true
311
+ }).wait(250);
826
312
  }
827
313
 
828
- function fillTextInput(textInputElement, value) {
829
- cy.wrap(textInputElement).scrollIntoView().clear({
830
- force: true
314
+ function fillTextarea(fieldElement, value, _label) {
315
+ cy.wrap(fieldElement).scrollIntoView({
316
+ offset: {
317
+ left: 0,
318
+ top: -100
319
+ }
831
320
  });
832
- if (value) {
833
- cy.wrap(textInputElement).scrollIntoView().type(value, {
834
- force: true
835
- });
321
+ cy.wrap(fieldElement).find('textarea').clear({
322
+ force: true
323
+ }).wait(250);
324
+ // If `value` is undefined, we don't need to input anything
325
+ if (!value) {
326
+ return;
836
327
  }
328
+ cy.wrap(fieldElement).find('textarea').type(value, {
329
+ force: true
330
+ }).wait(250);
837
331
  }
838
332
 
839
- function pickCheckPickerOptions(cypressCheckPickerInputElement, values) {
840
- cypressCheckPickerInputElement.parents('.Field-CheckPicker').then(([fieldElement])=>{
841
- if (!fieldElement) {
842
- throw new Error('`fieldElement` is undefined.');
843
- }
844
- const fieldElementOffsetLeft = fieldElement.offsetLeft ? fieldElement.offsetLeft : (()=>{
845
- if (!fieldElement.offsetParent) {
846
- throw new Error('`fieldElement.offsetParent` is undefined.');
847
- }
848
- return fieldElement.offsetParent.offsetLeft;
849
- })();
850
- const fieldElementOffsetTop = fieldElement.offsetTop !== 0 ? fieldElement.offsetTop : (()=>{
851
- if (!fieldElement.offsetParent) {
852
- throw new Error('`fieldElement.offsetParent` is undefined.');
853
- }
854
- return fieldElement.offsetParent.offsetTop;
855
- })();
856
- cy.wrap(fieldElement).scrollIntoView();
857
- const maybeCleanButton = fieldElement.querySelector('.rs-picker-toggle-clean');
858
- if (maybeCleanButton) {
859
- cy.wrap(fieldElement).find('.rs-picker-toggle-clean').forceClick().wait(250);
860
- }
861
- if (!values) {
862
- return;
333
+ function fillTextInput(fieldElement, value, _label) {
334
+ cy.wrap(fieldElement).scrollIntoView({
335
+ offset: {
336
+ left: 0,
337
+ top: -100
863
338
  }
864
- cy.wrap(fieldElement).find('.rs-picker-toggle').forceClick();
865
- cy.get('.rs-picker-check-menu').then(([CheckPickerMenuElement])=>{
866
- if (!CheckPickerMenuElement) {
867
- throw new Error('`CheckPickerMenuElement` is undefined.');
868
- }
869
- const maybeSearchInput = CheckPickerMenuElement.querySelector('.rs-picker-search-bar-input');
870
- values.forEach((value)=>{
871
- if (maybeSearchInput) {
872
- cy.get('.rs-picker-check-menu').find('.rs-picker-search-bar-input').type(value);
873
- }
874
- cy.get('.rs-picker-check-menu').find('[role="option"]').contains(value).scrollIntoView().forceClick();
875
- });
876
- // TODO Investigate that (this should be -1).
877
- cy.clickOutside(fieldElementOffsetLeft, fieldElementOffsetTop - 16);
878
- cy.wait(250);
879
- });
880
339
  });
340
+ cy.wrap(fieldElement).find('input[type="text"]').clear({
341
+ force: true
342
+ }).wait(250);
343
+ // If `value` is undefined, we don't need to input anything
344
+ if (!value) {
345
+ return;
346
+ }
347
+ cy.wrap(fieldElement).find('input[type="text"]').type(value, {
348
+ force: true
349
+ }).wait(250);
881
350
  }
882
351
 
883
- function pickMultiSelectOptions(cypressMultiSelectInputElement, values) {
884
- cypressMultiSelectInputElement.parents('.Field-MultiSelect').then(([fieldElement])=>{
885
- if (!fieldElement) {
886
- throw new Error('`fieldElement` is undefined.');
352
+ function pickCheckPickerOptions(fieldElement, values, label) {
353
+ cy.wrap(fieldElement).scrollIntoView({
354
+ offset: {
355
+ left: 0,
356
+ top: -100
887
357
  }
888
- const fieldElementOffsetLeft = fieldElement.offsetLeft ? fieldElement.offsetLeft : (()=>{
889
- if (!fieldElement.offsetParent) {
890
- throw new Error('`fieldElement.offsetParent` is undefined.');
891
- }
892
- return fieldElement.offsetParent.offsetLeft;
893
- })();
894
- const fieldElementOffsetTop = fieldElement.offsetTop !== 0 ? fieldElement.offsetTop : (()=>{
895
- if (!fieldElement.offsetParent) {
896
- throw new Error('`fieldElement.offsetParent` is undefined.');
897
- }
898
- return fieldElement.offsetParent.offsetTop;
899
- })();
900
- cy.wrap(fieldElement).scrollIntoView();
901
- const maybeCleanButton = fieldElement.querySelector('.rs-picker-toggle-clean');
902
- if (maybeCleanButton) {
903
- cy.wrap(fieldElement).find('.rs-picker-toggle-clean').forceClick().wait(250);
904
- }
905
- if (!values) {
906
- return;
358
+ });
359
+ // Clear the field if there is a clear button
360
+ const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
361
+ if (maybeClearButton) {
362
+ cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').click({
363
+ force: true
364
+ }).wait(250);
365
+ }
366
+ // If `values` is undefined, we don't need to select anything
367
+ if (!values) {
368
+ return;
369
+ }
370
+ cy.wrap(fieldElement).find('.rs-picker-toggle').forceClick();
371
+ // Wait for the picker to open
372
+ cy.wrap(fieldElement).find('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
373
+ if (!rsuitePickerPopupElement) {
374
+ throwError(`Could not find '.rs-picker-popup' in in field with label "${label}". Did the picker open?`);
907
375
  }
908
- cy.wrap(fieldElement).find('.rs-picker-toggle').forceClick();
909
- cy.get('.rs-picker-check-menu').then(([multiSelectMenuElement])=>{
910
- if (!multiSelectMenuElement) {
911
- throw new Error('`multiSelectMenuElement` is undefined.');
376
+ // Search for the value if there is a search input
377
+ const maybeSearchInput = rsuitePickerPopupElement.querySelector('input[role="searchbox"]');
378
+ values.forEach((value)=>{
379
+ if (maybeSearchInput) {
380
+ cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').type(value).wait(250);
912
381
  }
913
- const maybeSearchInput = multiSelectMenuElement.querySelector('.rs-picker-search-bar-input');
914
- values.forEach((value)=>{
915
- if (maybeSearchInput) {
916
- cy.get('.rs-picker-check-menu').find('.rs-picker-search-bar-input').type(value);
917
- }
918
- cy.get('.rs-picker-check-menu').find('.rs-checkbox-checker').contains(value).scrollIntoView().forceClick();
919
- });
920
- // TODO Investigate that (this should be -1).
921
- cy.clickOutside(fieldElementOffsetLeft, fieldElementOffsetTop - 16);
922
- cy.wait(250);
382
+ cy.wrap(rsuitePickerPopupElement).find('[role="option"]').contains(value).scrollIntoView().forceClick();
923
383
  });
384
+ // Close the picker popup by pressing the escape key
385
+ cy.get('body').type('{esc}');
386
+ cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist');
924
387
  });
925
388
  }
926
389
 
927
- function pickSelectOption(cypressSelectInputElement, value) {
928
- cypressSelectInputElement.parents('.Field-Select').scrollIntoView().then(([fieldElement])=>{
929
- if (!fieldElement) {
930
- throw new Error('`fieldElement` is undefined.');
390
+ function pickMultiSelectOptions(fieldElement, values, label) {
391
+ cy.wrap(fieldElement).scrollIntoView({
392
+ offset: {
393
+ left: 0,
394
+ top: -100
931
395
  }
932
- cy.wrap(fieldElement).scrollIntoView();
933
- const maybeCleanButton = fieldElement.querySelector('.rs-picker-toggle-clean');
934
- if (maybeCleanButton) {
935
- cy.wrap(fieldElement).find('.rs-picker-toggle-clean').scrollIntoView().forceClick().wait(250);
936
- }
937
- if (!value) {
938
- return;
396
+ });
397
+ // Clear the field if there is a clear button
398
+ const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
399
+ if (maybeClearButton) {
400
+ cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').click({
401
+ force: true
402
+ }).wait(250);
403
+ }
404
+ // If `values` is undefined, we don't need to select anything
405
+ if (!values) {
406
+ return;
407
+ }
408
+ cy.wrap(fieldElement).find('.rs-picker-toggle').forceClick();
409
+ // Wait for the picker to open
410
+ cy.wrap(fieldElement).get('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
411
+ if (!rsuitePickerPopupElement) {
412
+ throwError(`Could not find '.rs-picker-popup' in in field with label "${label}". Did the picker open?`);
939
413
  }
940
- cy.wrap(fieldElement).find('.rs-picker-toggle').forceClick();
941
- cy.get('.rs-picker-select-menu').then(([selectMenuElement])=>{
942
- if (!selectMenuElement) {
943
- throw new Error('`selectMenuElement` is undefined.');
944
- }
945
- const maybeSearchInput = selectMenuElement.querySelector('.rs-picker-search-bar-input');
414
+ const maybeSearchInput = rsuitePickerPopupElement.querySelector('input[role="searchbox"]');
415
+ values.forEach((value)=>{
416
+ // Search for the value if there is a search input
946
417
  if (maybeSearchInput) {
947
- cy.wrap(selectMenuElement).find('.rs-picker-search-bar-input').type(value);
418
+ cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').type(value).wait(250);
948
419
  }
949
- cy.wrap(selectMenuElement).get('.rs-picker-select-menu-item').contains(value).scrollIntoView().click({
950
- force: true
951
- });
420
+ cy.wrap(rsuitePickerPopupElement).find('[role="option"]').contains(value).scrollIntoView().forceClick();
952
421
  });
422
+ // Close the picker popup by pressing the escape key
423
+ cy.get('body').type('{esc}');
424
+ cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist');
953
425
  });
954
426
  }
955
427
 
956
- // I have no idea why I have to add this dirty hack of setting an external variable
957
- // instead of using a cleaner FP `.filter()`
958
- // but real experience made me think it greatly improves results stability.
959
- function findElementBySelector(selector, { fallbackSelector, index = 0, inElement } = {}) {
960
- if (inElement) {
961
- let foundElement;
962
- let foundElementIndex = 0;
963
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
964
- Cypress.$(inElement).find(selector)// eslint-disable-next-line func-names
965
- .each(function() {
966
- if (!foundElement) {
967
- if (foundElementIndex < index) {
968
- foundElementIndex += 1;
969
- return;
970
- }
971
- foundElement = this;
972
- }
973
- });
974
- if (!foundElement && fallbackSelector) {
975
- cy.log(`⚠️ Using fallback selector: "${fallbackSelector}"`);
976
- const foundElementByFallbackSelector = Cypress.$(inElement).find(fallbackSelector);
977
- return foundElementByFallbackSelector;
428
+ function pickSearchOption(fieldElement, value, _label) {
429
+ cy.wrap(fieldElement).scrollIntoView({
430
+ offset: {
431
+ left: 0,
432
+ top: -100
978
433
  }
979
- return foundElement;
434
+ });
435
+ // Clear the field if there is a clear button
436
+ const maybeClearButton = fieldElement.querySelector('.Field-Search__ClearButton');
437
+ if (maybeClearButton) {
438
+ cy.wrap(fieldElement).find('.Field-Search__ClearButton').click({
439
+ force: true
440
+ }).wait(250);
980
441
  }
981
- let foundElement;
982
- let foundElementIndex = 0;
983
- // eslint-disable-next-line func-names, @typescript-eslint/no-unused-expressions
984
- Cypress.$(selector).each(function() {
985
- if (!foundElement) {
986
- if (foundElementIndex < index) {
987
- foundElementIndex += 1;
988
- return;
989
- }
990
- foundElement = this;
442
+ // If the value is undefined, we don't need to select anything
443
+ if (!value) {
444
+ return;
445
+ }
446
+ // Search for the value
447
+ cy.wrap(fieldElement).find('input[role="combobox"]').type(value);
448
+ // Wait for the picker to open
449
+ cy.wrap(fieldElement).get('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
450
+ // Select the first picker option
451
+ cy.wrap(rsuitePickerPopupElement).find('[role="option"]').first().scrollIntoView().forceClick().wait(250);
452
+ });
453
+ }
454
+
455
+ function pickSelectOption(fieldElement, value, label) {
456
+ cy.wrap(fieldElement).scrollIntoView({
457
+ offset: {
458
+ left: 0,
459
+ top: -100
991
460
  }
992
461
  });
993
- if (!foundElement && fallbackSelector) {
994
- // eslint-disable-next-line no-console
995
- console.warn(`Using fallback selector: "${fallbackSelector}".`);
996
- const foundElementByFallbackSelector = Cypress.$(fallbackSelector);
997
- return foundElementByFallbackSelector;
462
+ // Clear the field if there is a clear button
463
+ const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
464
+ if (maybeClearButton) {
465
+ cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').click({
466
+ force: true
467
+ }).wait(250);
998
468
  }
999
- return foundElement;
469
+ // If the value is undefined, we don't need to select anything
470
+ if (!value) {
471
+ return;
472
+ }
473
+ // Open the picker
474
+ cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-caret-icon').forceClick().wait(250);
475
+ // Wait for the picker to open
476
+ cy.wrap(fieldElement).get('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
477
+ if (!rsuitePickerPopupElement) {
478
+ throwError(`Could not find '.rs-picker-popup' in in field with label "${label}". Did the picker open?`);
479
+ }
480
+ // Search for the value if there is a search input
481
+ const maybeSearchInput = rsuitePickerPopupElement.querySelector('input[role="searchbox"]');
482
+ if (maybeSearchInput) {
483
+ cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').type(value).wait(250);
484
+ }
485
+ cy.wrap(rsuitePickerPopupElement).find('[role="option"]').contains(value).scrollIntoView().forceClick().wait(250);
486
+ });
1000
487
  }
1001
488
 
1002
- function waitFor(inMs) {
1003
- return new Promise((resolve)=>{
1004
- setTimeout(resolve, inMs);
1005
- });
489
+ const throwAssertionError = (expectedType, component)=>throwError(`\`value\` should be of type \`${expectedType}\` in \`cy.fill(label, value)\` when used on a <${component} />.`);
490
+ function assertBooleanOrUndefined(value, component) {
491
+ if (value === undefined || typeof value === 'boolean') {
492
+ return;
493
+ }
494
+ throwAssertionError('boolean | undefined', component);
495
+ }
496
+ function assertDateTupleOrDateWithTimeTupleOrUndefined(value, component) {
497
+ if (value === undefined) {
498
+ return;
499
+ }
500
+ if (Array.isArray(value) && (value.length === 3 || value.length === 5) && value.every((valueItem)=>typeof valueItem === 'number')) {
501
+ return;
502
+ }
503
+ throwAssertionError('DateTuple | DateWithTimeTuple | undefined', component);
504
+ }
505
+ function assertDateRangeTupleOrDateWithTimeRangeTupleOrUndefined(value, component) {
506
+ if (value === undefined) {
507
+ return;
508
+ }
509
+ if (Array.isArray(value) && value.length === 2 && (Array.isArray(value[0]) && value[0].length === 3 && value[1].length === 3 || Array.isArray(value[0]) && value[0].length === 5 && value[1].length === 5) && value.every((valueItem)=>Array.isArray(valueItem) && valueItem.every((valueItemItem)=>typeof valueItemItem === 'number'))) {
510
+ return;
511
+ }
512
+ throwAssertionError('DateRangeTuple | DateWithTimeRangeTuple | undefined', component);
513
+ }
514
+ function assertNumberOrUndefined(value, component) {
515
+ if (value === undefined || typeof value === 'number') {
516
+ return;
517
+ }
518
+ throwAssertionError('number | undefined', component);
519
+ }
520
+ function assertString(value, component) {
521
+ if (typeof value === 'string') {
522
+ return;
523
+ }
524
+ throwAssertionError('string', component);
525
+ }
526
+ function assertStringOrUndefined(value, component) {
527
+ if (value === undefined || typeof value === 'string') {
528
+ return;
529
+ }
530
+ throwAssertionError('string | undefined', component);
531
+ }
532
+ function assertStringArrayOrUndefined(value, component) {
533
+ if (value === undefined) {
534
+ return;
535
+ }
536
+ if (Array.isArray(value) && value.every((valueItem)=>typeof valueItem === 'string')) {
537
+ return;
538
+ }
539
+ throwAssertionError('string[] | undefined', component);
1006
540
  }
1007
541
 
1008
542
  const RETRIES = 5;
1009
543
  function fill(label, value, leftRetries = RETRIES) {
1010
544
  try {
1011
- // -------------------------------------------------------------------------
1012
- // If this is a `<label />` element
545
+ // =========================================================================
546
+ // If it's a field labelled by a `<label />` element
1013
547
  const labelElement = findElementBytext('label', label);
1014
548
  if (labelElement) {
1015
- // -------------------------------------------------------------------------
1016
- // If the label has a `for` attribute
1017
- if (!isEmpty$1(labelElement.htmlFor)) {
1018
- const htmlforElement = findElementBySelector(`[id="${labelElement.htmlFor}"]`);
1019
- if (!htmlforElement) {
1020
- throw new Error(`Could not find the element with [id="${labelElement.htmlFor}"] targetted by label "${label}" (via its \`for\` attribute).`);
1021
- }
1022
- const cypressHtmlforElement = cy.get(`[id="${labelElement.htmlFor}"]`);
1023
- cypressHtmlforElement.then(()=>{
1024
- if (htmlforElement.classList.contains('rs-picker-toggle-textbox')) {
1025
- const rsuitePickerElement = htmlforElement.parentElement && htmlforElement.parentElement.parentElement && htmlforElement.parentElement.parentElement.parentElement ? htmlforElement.parentElement.parentElement.parentElement.parentElement : undefined;
1026
- if (!rsuitePickerElement) {
1027
- throw new Error('This should never happen.');
1028
- }
1029
- switch(true){
1030
- // Select
1031
- case rsuitePickerElement.classList.contains('rs-picker-select'):
1032
- pickSelectOption(cypressHtmlforElement, value !== undefined ? String(value) : value);
1033
- break;
1034
- // Multi Select
1035
- case rsuitePickerElement.classList.contains('rs-picker-tag'):
1036
- pickMultiSelectOptions(cypressHtmlforElement, Array.isArray(value) && value.length > 0 ? value : undefined);
1037
- break;
1038
- // Check Picker
1039
- case rsuitePickerElement.classList.contains('rs-picker-check'):
1040
- pickCheckPickerOptions(cypressHtmlforElement, Array.isArray(value) && value.length > 0 ? value : undefined);
1041
- break;
1042
- default:
1043
- throw new Error(`\`cy.fill()\` can't handle Rsuite picker with class "${rsuitePickerElement.className}" elements.`);
1044
- }
1045
- return;
1046
- }
1047
- switch(htmlforElement.tagName){
1048
- // Text/Number Input
1049
- case 'INPUT':
1050
- fillTextInput(htmlforElement, value !== undefined ? String(value) : value);
1051
- break;
1052
- // Textarea
1053
- case 'TEXTAREA':
1054
- fillTextarea(htmlforElement, value !== undefined ? String(value) : value);
1055
- break;
1056
- default:
1057
- throw new Error(`\`cy.fill()\` doesn't handle "${htmlforElement.tagName}" elements.`);
1058
- }
1059
- });
1060
- return;
1061
- }
1062
- // -------------------------------------------------------------------------
1063
- // If the label doesn't have a `for` attribute
1064
- // Checkbox Input
1065
- const checkboxInputElement = labelElement.querySelector('input[type="checkbox"]');
1066
- if (checkboxInputElement) {
1067
- checkCheckbox(checkboxInputElement, Boolean(value));
1068
- return;
1069
- }
1070
- // Text Input
1071
- const textInputElement = labelElement.querySelector('input[type="text"]');
1072
- if (textInputElement) {
1073
- fillTextInput(textInputElement, String(value));
1074
- return;
549
+ const fieldElement = findElementParentBySelector(labelElement, '.Element-Field');
550
+ if (!fieldElement) {
551
+ throwError(`Could not find '.Element-Field' in field with label "${label}".`);
1075
552
  }
1076
- // Textarea
1077
- const textareaElement = labelElement.querySelector('textarea');
1078
- if (textareaElement) {
1079
- fillTextarea(textareaElement, String(value));
1080
- return;
553
+ switch(true){
554
+ // ---------------------------------------------------------------------
555
+ // Checkbox
556
+ case fieldElement.classList.contains('Field-Checkbox'):
557
+ assertBooleanOrUndefined(value, 'Checkbox');
558
+ checkCheckbox(fieldElement, value, label);
559
+ return;
560
+ // ---------------------------------------------------------------------
561
+ // CheckPicker
562
+ case fieldElement.classList.contains('Field-CheckPicker'):
563
+ assertStringArrayOrUndefined(value, 'CheckPicker');
564
+ pickCheckPickerOptions(fieldElement, value, label);
565
+ return;
566
+ // ---------------------------------------------------------------------
567
+ // MultiSelect
568
+ case fieldElement.classList.contains('Field-MultiSelect'):
569
+ assertStringArrayOrUndefined(value, 'MultiSelect');
570
+ pickMultiSelectOptions(fieldElement, value, label);
571
+ return;
572
+ // ---------------------------------------------------------------------
573
+ // Search
574
+ case fieldElement.classList.contains('Field-Search'):
575
+ assertStringOrUndefined(value, 'Search');
576
+ pickSearchOption(fieldElement, value, label);
577
+ return;
578
+ // ---------------------------------------------------------------------
579
+ // Select
580
+ case fieldElement.classList.contains('Field-Select'):
581
+ assertStringOrUndefined(value, 'Select');
582
+ pickSelectOption(fieldElement, value, label);
583
+ return;
584
+ // ---------------------------------------------------------------------
585
+ // NumberInput
586
+ case fieldElement.classList.contains('Field-NumberInput'):
587
+ assertNumberOrUndefined(value, 'TextInput');
588
+ fillNumberInput(fieldElement, value, label);
589
+ return;
590
+ // ---------------------------------------------------------------------
591
+ // Textarea
592
+ case fieldElement.classList.contains('Field-Textarea'):
593
+ assertStringOrUndefined(value, 'Textarea');
594
+ fillTextarea(fieldElement, value, label);
595
+ return;
596
+ // ---------------------------------------------------------------------
597
+ // TextInput
598
+ case fieldElement.classList.contains('Field-TextInput'):
599
+ assertStringOrUndefined(value, 'TextInput');
600
+ fillTextInput(fieldElement, value, label);
601
+ return;
602
+ default:
603
+ throwError(`\`cy.fill()\` can't handle field with \`<label>\` "${label}".`);
1081
604
  }
1082
- throw new Error(`Could find neither a checkbox, an input nor a textarea with the label "${label}".`);
1083
605
  }
1084
- // -------------------------------------------------------------------------
1085
- // If this is a `<legend />` element
606
+ // =========================================================================
607
+ // If it's a field labelled by a `<legend />` element
1086
608
  const legendElement = findElementBytext('legend', label);
1087
609
  if (legendElement) {
1088
- const cypressLegendElement = cy.get('legend').contains(label);
1089
- cypressLegendElement.then(async ()=>{
1090
- await waitFor(500);
1091
- const fieldsetElement = legendElement.parentElement;
1092
- if (!fieldsetElement || fieldsetElement.tagName !== 'FIELDSET') {
1093
- throw new Error(`Could not find parent fieldset of legend element with text "${label}".`);
1094
- }
1095
- if (fieldsetElement.classList.contains('Field-DatePicker')) {
1096
- if ((!Array.isArray(value) || value.length !== 3 && value.length !== 5 || typeof value[0] !== 'number') && value !== undefined) {
1097
- throw new Error('`value` should be of type `[number, number, number]`, `[number, number, number, number, number]` or `undefined`.');
1098
- }
1099
- fillDatePicker(fieldsetElement, value);
610
+ const fieldsetElement = findElementParentBySelector(legendElement, '.Element-Fieldset');
611
+ if (!fieldsetElement) {
612
+ throwError(`Could not find '.Element-Fieldset' in field with \`<legend />\` "${label}".`);
613
+ }
614
+ switch(true){
615
+ // ---------------------------------------------------------------------
616
+ // DatePicker
617
+ case fieldsetElement.classList.contains('Field-DatePicker'):
618
+ assertDateTupleOrDateWithTimeTupleOrUndefined(value, 'DatePicker');
619
+ fillDatePicker(fieldsetElement, value, label);
1100
620
  return;
1101
- }
1102
- if (fieldsetElement.classList.contains('Field-DateRangePicker')) {
1103
- if ((!Array.isArray(value) || value.length !== 2 || !Array.isArray(value[0]) || value[0].length !== 3 && value[0].length !== 5 || value[1].length !== 3 && value[1].length !== 5) && value !== undefined) {
1104
- throw new Error('`value` should be of type `[[number, number, number], [number, number, number]]` or ``[[number, number, number, number, number], [number, number, number, number, number]]`` or `undefined`.');
1105
- }
1106
- fillDateRangePicker(fieldsetElement, value);
621
+ // ---------------------------------------------------------------------
622
+ // DateRangePicker
623
+ case fieldsetElement.classList.contains('Field-DateRangePicker'):
624
+ assertDateRangeTupleOrDateWithTimeRangeTupleOrUndefined(value, 'DateRangePicker');
625
+ fillDateRangePicker(fieldsetElement, value, label);
1107
626
  return;
1108
- }
1109
- const isMultiCheckbox = Boolean(fieldsetElement.querySelector('input[type="checkbox"]'));
1110
- const isMultiRadio = Boolean(fieldsetElement.querySelector('input[type="radio"]'));
1111
- if (isMultiCheckbox) {
1112
- checkMultiCheckboxOptions(fieldsetElement, Array.isArray(value) && value.length > 0 ? value : undefined);
627
+ // ---------------------------------------------------------------------
628
+ // MultiCheckbox
629
+ case fieldsetElement.classList.contains('Field-MultiCheckbox'):
630
+ assertStringArrayOrUndefined(value, 'MultiCheckbox');
631
+ checkMultiCheckboxOptions(fieldsetElement, value, label);
1113
632
  return;
1114
- }
1115
- if (isMultiRadio) {
1116
- checkMultiRadioOption(fieldsetElement, String(value));
633
+ // ---------------------------------------------------------------------
634
+ // MultiRadio
635
+ case fieldsetElement.classList.contains('Field-MultiRadio'):
636
+ assertString(value, 'MultiRadio');
637
+ checkMultiRadioOption(fieldsetElement, value, label);
1117
638
  return;
1118
- }
1119
- throw new Error(`\`cy.fill()\` can't handle the field with legend "${label}".`);
1120
- });
1121
- return;
639
+ default:
640
+ throwError(`\`cy.fill()\` can't handle the input element in field with \`<legend>\` "${label}".`);
641
+ }
1122
642
  }
1123
- throw new Error(`Could not find label or legend element with text "${label}".`);
643
+ throwError(`Could not find a field labelled by a \`<label />\` or \`<legend />\` "${label}".`);
1124
644
  } catch (err) {
1125
645
  if (leftRetries > 0) {
1126
646
  cy.wait(250).then(()=>{
1127
- cy.log(`Retrying (${RETRIES - leftRetries + 1} / ${RETRIES})...`);
647
+ cy.log(`[monitor-ui > Cypress] Retrying (${RETRIES - leftRetries + 1} / ${RETRIES})...`);
1128
648
  fill(label, value, leftRetries - 1);
1129
649
  });
1130
650
  return;
1131
651
  }
1132
- throw new Error(`Could not find label or legend element with text "${label}" after ${RETRIES} attempts.`);
652
+ const normalizedError = err instanceof Error ? err : new Error(String(err));
653
+ Cypress.log({
654
+ consoleProps: ()=>({
655
+ err,
656
+ label,
657
+ value
658
+ }),
659
+ displayName: 'ERROR',
660
+ message: String(normalizedError.message),
661
+ name: 'fill'
662
+ }).error(normalizedError);
663
+ throwError([
664
+ `Could not find or fill field with label or legend "${label}" after ${RETRIES} attempts.`,
665
+ `This error was thrown: “${normalizedError.message}”`,
666
+ `Please check the Cypress "- ERROR" log above for more details.`
667
+ ].join('\n'));
1133
668
  }
1134
669
  }
1135
670
 
@@ -1137,6 +672,13 @@ function forceClick([subject]) {
1137
672
  if (!subject) {
1138
673
  throw new Error(`Could not find subject.`);
1139
674
  }
675
+ Cypress.log({
676
+ consoleProps: ()=>({
677
+ 'Applied to': subject,
678
+ Elements: 1
679
+ }),
680
+ name: 'forceClick'
681
+ });
1140
682
  try {
1141
683
  return subject.click({
1142
684
  force: true