@mtes-mct/monitor-ui 12.0.3 → 12.1.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## [12.1.0](https://github.com/MTES-MCT/monitor-ui/compare/v12.0.3...v12.1.0) (2024-02-27)
2
+
3
+
4
+ ### Features
5
+
6
+ * **cypress:** add logs in fill() and all its subcommands ([f9b320f](https://github.com/MTES-MCT/monitor-ui/commit/f9b320fc335745bb562da34f00b98ef78bf5ef74))
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cypress:** replace picker popup closure check with a wait in fill() ([9b4108b](https://github.com/MTES-MCT/monitor-ui/commit/9b4108be9479fb25d99902ca451dc329192bdb18))
12
+
13
+
14
+ ### Buid System & Dependencies
15
+
16
+ * **vite:** disable CSS minification for storybook build ([c98d7c9](https://github.com/MTES-MCT/monitor-ui/commit/c98d7c99c053f4084bec5c044a8ff1050e2029aa))
17
+
18
+ ## [12.0.3](https://github.com/MTES-MCT/monitor-ui/compare/v12.0.2...v12.0.3) (2024-02-27)
19
+
20
+
21
+ ### Styles
22
+
23
+ * **fields:** fix MultiCheckbox options margin when isInline ([d98f1a5](https://github.com/MTES-MCT/monitor-ui/commit/d98f1a549ac2b7ffb0b82c67435c39f0a6fd9ea8))
24
+
1
25
  ## [12.0.2](https://github.com/MTES-MCT/monitor-ui/compare/v12.0.1...v12.0.2) (2024-02-27)
2
26
 
3
27
 
package/cypress/index.js CHANGED
@@ -110,22 +110,35 @@ function clickLink(linkText) {
110
110
  });
111
111
  }
112
112
 
113
+ const MAX_PARENT_INDEX = 100;
113
114
  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;
115
+ let currentParentElement = element;
116
+ let lastFoundParentIndex = 0;
117
+ let parentIndex = -1;
118
+ while(parentIndex < MAX_PARENT_INDEX){
119
+ parentIndex += 1;
120
+ currentParentElement = currentParentElement.parentElement;
121
+ if (!currentParentElement) {
122
+ return undefined;
122
123
  }
123
- foundElementIndex += 1;
124
- });
125
- return foundElement;
124
+ if (currentParentElement.matches(parentSelector)) {
125
+ if (lastFoundParentIndex === index) {
126
+ return currentParentElement;
127
+ }
128
+ lastFoundParentIndex += 1;
129
+ }
130
+ }
131
+ return undefined;
126
132
  }
127
133
 
128
134
  function checkCheckbox(fieldElement, value, _label) {
135
+ Cypress.log({
136
+ consoleProps: ()=>({
137
+ 'Applied to': fieldElement,
138
+ Elements: 1
139
+ }),
140
+ name: 'checkCheckbox'
141
+ });
129
142
  cy.wrap(fieldElement).scrollIntoView({
130
143
  offset: {
131
144
  left: 0,
@@ -144,6 +157,13 @@ function checkCheckbox(fieldElement, value, _label) {
144
157
  }
145
158
 
146
159
  function checkMultiCheckboxOptions(fieldsetElement, values, _label) {
160
+ Cypress.log({
161
+ consoleProps: ()=>({
162
+ 'Applied to': fieldsetElement,
163
+ Elements: 1
164
+ }),
165
+ name: 'checkMultiCheckboxOptions'
166
+ });
147
167
  cy.wrap(fieldsetElement).scrollIntoView({
148
168
  offset: {
149
169
  left: 0,
@@ -166,13 +186,19 @@ function checkMultiCheckboxOptions(fieldsetElement, values, _label) {
166
186
  }
167
187
 
168
188
  function checkMultiRadioOption(fieldsetElement, value, _label) {
189
+ Cypress.log({
190
+ consoleProps: ()=>({
191
+ 'Applied to': fieldsetElement,
192
+ Elements: 1
193
+ }),
194
+ name: 'checkMultiRadioOption'
195
+ });
169
196
  cy.wrap(fieldsetElement).scrollIntoView({
170
197
  offset: {
171
198
  left: 0,
172
199
  top: -100
173
200
  }
174
201
  }).find('label').contains(value).forceClick().wait(250);
175
- return fieldsetElement;
176
202
  }
177
203
 
178
204
  function throwError(message) {
@@ -180,6 +206,13 @@ function throwError(message) {
180
206
  }
181
207
 
182
208
  function fillDatePicker(fieldsetElement, dateOrDateWithTimeTuple, _label) {
209
+ Cypress.log({
210
+ consoleProps: ()=>({
211
+ 'Applied to': fieldsetElement,
212
+ Elements: 1
213
+ }),
214
+ name: 'fillDatePicker'
215
+ });
183
216
  const inputElements = fieldsetElement.querySelectorAll('input');
184
217
  if (inputElements.length !== 4 && inputElements.length !== 6) {
185
218
  throwError(`Expected to find 4 or 6 inputs within in DatePicker but found ${inputElements.length}.`);
@@ -220,11 +253,21 @@ function fillDatePicker(fieldsetElement, dateOrDateWithTimeTuple, _label) {
220
253
  cy.wait(250);
221
254
  // Close the calendar & ranged time picker popup by pressing the escape key
222
255
  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');
256
+ // TODO Create a util to handle the `fieldsetElement` re-creation cases.
257
+ // We to use a `wait` as a temporary fix to handle `fieldsetElement` re-creation cases.
258
+ cy.wait(250);
259
+ // cy.wrap(fieldsetElement).find('.Field-DatePicker__CalendarPicker').should('not.be.visible')
260
+ // cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangedTimePicker').should('not.exist')
225
261
  }
226
262
 
227
263
  function fillDateRangePicker(fieldsetElement, dateOrDateWithTimeTupleRange, _label) {
264
+ Cypress.log({
265
+ consoleProps: ()=>({
266
+ 'Applied to': fieldsetElement,
267
+ Elements: 1
268
+ }),
269
+ name: 'fillDateRangePicker'
270
+ });
228
271
  const inputElements = fieldsetElement.querySelectorAll('input');
229
272
  if (inputElements.length !== 7 && inputElements.length !== 11) {
230
273
  throwError(`Expected to find 7 or 11 inputs within in DatePicker but found ${inputElements.length}.`);
@@ -288,11 +331,21 @@ function fillDateRangePicker(fieldsetElement, dateOrDateWithTimeTupleRange, _lab
288
331
  cy.wait(250);
289
332
  // Close the range calendar & ranged time picker popup by pressing the escape key
290
333
  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');
334
+ // TODO Create a util to handle the `fieldsetElement` re-creation cases.
335
+ // We to use a `wait` as a temporary fix to handle `fieldsetElement` re-creation cases.
336
+ cy.wait(250);
337
+ // cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangeCalendarPicker').should('not.be.visible')
338
+ // cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangedTimePicker').should('not.exist')
293
339
  }
294
340
 
295
341
  function fillNumberInput(fieldElement, value, _label) {
342
+ Cypress.log({
343
+ consoleProps: ()=>({
344
+ 'Applied to': fieldElement,
345
+ Elements: 1
346
+ }),
347
+ name: 'fillNumberInput'
348
+ });
296
349
  cy.wrap(fieldElement).scrollIntoView({
297
350
  offset: {
298
351
  left: 0,
@@ -312,6 +365,13 @@ function fillNumberInput(fieldElement, value, _label) {
312
365
  }
313
366
 
314
367
  function fillTextarea(fieldElement, value, _label) {
368
+ Cypress.log({
369
+ consoleProps: ()=>({
370
+ 'Applied to': fieldElement,
371
+ Elements: 1
372
+ }),
373
+ name: 'fillTextarea'
374
+ });
315
375
  cy.wrap(fieldElement).scrollIntoView({
316
376
  offset: {
317
377
  left: 0,
@@ -331,6 +391,13 @@ function fillTextarea(fieldElement, value, _label) {
331
391
  }
332
392
 
333
393
  function fillTextInput(fieldElement, value, _label) {
394
+ Cypress.log({
395
+ consoleProps: ()=>({
396
+ 'Applied to': fieldElement,
397
+ Elements: 1
398
+ }),
399
+ name: 'fillTextInput'
400
+ });
334
401
  cy.wrap(fieldElement).scrollIntoView({
335
402
  offset: {
336
403
  left: 0,
@@ -350,6 +417,13 @@ function fillTextInput(fieldElement, value, _label) {
350
417
  }
351
418
 
352
419
  function pickCheckPickerOptions(fieldElement, values, label) {
420
+ Cypress.log({
421
+ consoleProps: ()=>({
422
+ 'Applied to': fieldElement,
423
+ Elements: 1
424
+ }),
425
+ name: 'pickCheckPickerOptions'
426
+ });
353
427
  cy.wrap(fieldElement).scrollIntoView({
354
428
  offset: {
355
429
  left: 0,
@@ -383,11 +457,21 @@ function pickCheckPickerOptions(fieldElement, values, label) {
383
457
  });
384
458
  // Close the picker popup by pressing the escape key
385
459
  cy.get('body').type('{esc}');
386
- cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist');
460
+ // TODO Create a util to handle the `fieldElement` re-creation cases.
461
+ // We to use a `wait` as a temporary fix to handle `fieldElement` re-creation cases.
462
+ cy.wait(250);
463
+ // cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist')
387
464
  });
388
465
  }
389
466
 
390
467
  function pickMultiSelectOptions(fieldElement, values, label) {
468
+ Cypress.log({
469
+ consoleProps: ()=>({
470
+ 'Applied to': fieldElement,
471
+ Elements: 1
472
+ }),
473
+ name: 'pickMultiSelectOptions'
474
+ });
391
475
  cy.wrap(fieldElement).scrollIntoView({
392
476
  offset: {
393
477
  left: 0,
@@ -421,11 +505,21 @@ function pickMultiSelectOptions(fieldElement, values, label) {
421
505
  });
422
506
  // Close the picker popup by pressing the escape key
423
507
  cy.get('body').type('{esc}');
424
- cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist');
508
+ // TODO Create a util to handle the `fieldElement` re-creation cases.
509
+ // We to use a `wait` as a temporary fix to handle `fieldElement` re-creation cases.
510
+ cy.wait(250);
511
+ // cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist')
425
512
  });
426
513
  }
427
514
 
428
515
  function pickSearchOption(fieldElement, value, _label) {
516
+ Cypress.log({
517
+ consoleProps: ()=>({
518
+ 'Applied to': fieldElement,
519
+ Elements: 1
520
+ }),
521
+ name: 'pickSearchOption'
522
+ });
429
523
  cy.wrap(fieldElement).scrollIntoView({
430
524
  offset: {
431
525
  left: 0,
@@ -453,6 +547,13 @@ function pickSearchOption(fieldElement, value, _label) {
453
547
  }
454
548
 
455
549
  function pickSelectOption(fieldElement, value, label) {
550
+ Cypress.log({
551
+ consoleProps: ()=>({
552
+ 'Applied to': fieldElement,
553
+ Elements: 1
554
+ }),
555
+ name: 'pickSelectOption'
556
+ });
456
557
  cy.wrap(fieldElement).scrollIntoView({
457
558
  offset: {
458
559
  left: 0,
@@ -541,6 +642,13 @@ function assertStringArrayOrUndefined(value, component) {
541
642
 
542
643
  const RETRIES = 5;
543
644
  function fill(label, value, leftRetries = RETRIES) {
645
+ Cypress.log({
646
+ consoleProps: ()=>({
647
+ 'Left Retries': leftRetries
648
+ }),
649
+ message: `Filling field with label/legend "${label}" with value "${JSON.stringify(value)}".`,
650
+ name: 'fill'
651
+ });
544
652
  try {
545
653
  // =========================================================================
546
654
  // If it's a field labelled by a `<label />` element
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtes-mct/monitor-ui",
3
3
  "description": "Common React components, hooks, utilities and CSS stylesheets for MonitorFish, MonitorEnv and RapportNav.",
4
- "version": "12.0.3",
4
+ "version": "12.1.1",
5
5
  "license": "AGPL-3.0",
6
6
  "type": "module",
7
7
  "engines": {