@mtes-mct/monitor-ui 12.1.2 → 12.2.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.
- package/CHANGELOG.md +26 -0
- package/README.md +15 -8
- package/cypress/global.d.ts +5 -1
- package/cypress/index.js +140 -114
- package/cypress/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## [12.1.3](https://github.com/MTES-MCT/monitor-ui/compare/v12.1.2...v12.1.3) (2024-02-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Buid System & Dependencies
|
|
5
|
+
|
|
6
|
+
* **dev-deps:** bump @commitlint/config-conventional ([45fcba7](https://github.com/MTES-MCT/monitor-ui/commit/45fcba7f342dc70c4e29b3cd3d3cb2b0b02cc69a))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Documentation
|
|
10
|
+
|
|
11
|
+
* **readme:** add Cypress badge ([f580fb9](https://github.com/MTES-MCT/monitor-ui/commit/f580fb93db6c38d38a6260a22697780ab22c5757))
|
|
12
|
+
* **readme:** add documentation badge ([5057133](https://github.com/MTES-MCT/monitor-ui/commit/5057133e7431edcbdd182ff1bbc6dc82aef7a991))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **cypress:** fix forceClick() ability to be properly chained with other commands ([ffc733c](https://github.com/MTES-MCT/monitor-ui/commit/ffc733c22999f47a65408bb45a6728df26828839))
|
|
18
|
+
* **cypress:** use forced click instead of click in fill() on MultiSelect ([b14f63a](https://github.com/MTES-MCT/monitor-ui/commit/b14f63a890ce355ed66d3b64e22f65d2936c40cb))
|
|
19
|
+
|
|
20
|
+
## [12.1.2](https://github.com/MTES-MCT/monitor-ui/compare/v12.1.1...v12.1.2) (2024-02-28)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **cypress:** target right input during fill() search for MultiSelect ([1692c0b](https://github.com/MTES-MCT/monitor-ui/commit/1692c0bce324eeb172c58d77e0bb268d918226c8))
|
|
26
|
+
|
|
1
27
|
## [12.1.1](https://github.com/MTES-MCT/monitor-ui/compare/v12.1.0...v12.1.1) (2024-02-28)
|
|
2
28
|
|
|
3
29
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Monitor UI
|
|
2
2
|
|
|
3
|
-
[![License][img-license]][lnk-license] [![
|
|
3
|
+
[![License][img-license]][lnk-license] [![NPM Version][img-npm]][lnk-npm]
|
|
4
|
+
[![Unit Tests][img-unit-tests]][lnk-unit-tests] [![E2E Tests][img-e2e-tests]][lnk-e2e-tests]
|
|
5
|
+
[![Documentation][img-documentation]][lnk-documentation]
|
|
4
6
|
|
|
5
7
|
> Common React components, hooks, utilities and CSS stylesheets for [MonitorFish][lnk-github-monitorfish],
|
|
6
8
|
> [MonitorEnv][lnk-github-monitorenv] and [RapportNav][lnk-github-rapportnav].
|
|
@@ -48,7 +50,7 @@ export function App() {
|
|
|
48
50
|
|
|
49
51
|
## Documentation
|
|
50
52
|
|
|
51
|
-
Here is [the Storybook][lnk-
|
|
53
|
+
Here is [the Storybook documentation][lnk-documentation].
|
|
52
54
|
|
|
53
55
|
## Contributing
|
|
54
56
|
|
|
@@ -56,14 +58,19 @@ Please read the [contributing document](CONTRIBUTING.md) for setup and contribut
|
|
|
56
58
|
|
|
57
59
|
---
|
|
58
60
|
|
|
59
|
-
[img-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
[img-
|
|
63
|
-
[
|
|
61
|
+
[img-documentation]: https://img.shields.io/badge/StoryBook-Docs-007ec6?logo=storybook&style=for-the-badge
|
|
62
|
+
[img-e2e-tests]:
|
|
63
|
+
https://img.shields.io/endpoint?url=https://cloud.cypress.io/badge/simple/qnpjm2/main&label=E2E&logo=cypress&style=for-the-badge
|
|
64
|
+
[img-license]: https://img.shields.io/github/license/MTES-MCT/monitor-ui?style=for-the-badge
|
|
65
|
+
[img-npm]: https://img.shields.io/npm/v/@mtes-mct/monitor-ui?style=for-the-badge
|
|
66
|
+
[img-unit-tests]:
|
|
67
|
+
https://img.shields.io/github/actions/workflow/status/MTES-MCT/monitor-ui/check.yml?branch=main&label=Unit&style=for-the-badge
|
|
68
|
+
[lnk-documentation]: https://mtes-mct.github.io/monitor-ui/?path=/docs/introduction--documentation
|
|
69
|
+
[lnk-e2e-tests]: https://cloud.cypress.io/projects/qnpjm2/runs
|
|
70
|
+
[lnk-e2e-tests]: https://cloud.cypress.io/projects/qnpjm2/runs
|
|
64
71
|
[lnk-github-monitorenv]: https://github.com/MTES-MCT/monitorenv
|
|
65
72
|
[lnk-github-monitorfish]: https://github.com/MTES-MCT/monitorfish
|
|
66
73
|
[lnk-github-rapportnav]: https://github.com/MTES-MCT/rapportnav2
|
|
67
74
|
[lnk-license]: https://github.com/MTES-MCT/monitor-ui/blob/main/LICENSE
|
|
68
75
|
[lnk-npm]: https://www.npmjs.com/package/@mtes-mct/monitor-ui
|
|
69
|
-
[lnk-
|
|
76
|
+
[lnk-unit-tests]: https://github.com/MTES-MCT/monitor-ui/actions?query=branch%3Amain++
|
package/cypress/global.d.ts
CHANGED
|
@@ -46,7 +46,11 @@ declare namespace Cypress {
|
|
|
46
46
|
*/
|
|
47
47
|
fill(label: string, value: any, retries?: number): Chainable<Element>
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
forceCheck(options?: Partial<Cypress.CheckOptions>): Chainable<JQuery<HTMLElement>>
|
|
50
|
+
forceClear(options?: Partial<Cypress.ClearOptions>): Chainable<JQuery<HTMLElement>>
|
|
51
|
+
forceClick(options?: Partial<Cypress.ClickOptions>): Chainable<JQuery<HTMLElement>>
|
|
52
|
+
forceType(text: string, options?: Partial<Cypress.TypeOption>): Chainable<JQuery<HTMLElement>>
|
|
53
|
+
forceUncheck(options?: Partial<Cypress.CheckOptions>): Chainable<JQuery<HTMLElement>>
|
|
50
54
|
|
|
51
55
|
/**
|
|
52
56
|
* @example
|
package/cypress/index.js
CHANGED
|
@@ -146,13 +146,9 @@ function checkCheckbox(fieldElement, value, _label) {
|
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
if (value) {
|
|
149
|
-
cy.wrap(fieldElement).find('input[type="checkbox"]').
|
|
150
|
-
force: true
|
|
151
|
-
}).wait(250);
|
|
149
|
+
cy.wrap(fieldElement).find('input[type="checkbox"]').forceCheck().wait(250);
|
|
152
150
|
} else {
|
|
153
|
-
cy.wrap(fieldElement).find('input[type="checkbox"]').
|
|
154
|
-
force: true
|
|
155
|
-
}).wait(250);
|
|
151
|
+
cy.wrap(fieldElement).find('input[type="checkbox"]').forceUncheck().wait(250);
|
|
156
152
|
}
|
|
157
153
|
}
|
|
158
154
|
|
|
@@ -178,9 +174,7 @@ function checkMultiCheckboxOptions(fieldsetElement, values, _label) {
|
|
|
178
174
|
return;
|
|
179
175
|
}
|
|
180
176
|
values.forEach((value)=>{
|
|
181
|
-
cy.wrap(fieldsetElement).find('label').contains(value).find('input[type="checkbox"]').
|
|
182
|
-
force: true
|
|
183
|
-
});
|
|
177
|
+
cy.wrap(fieldsetElement).find('label').contains(value).find('input[type="checkbox"]').forceCheck();
|
|
184
178
|
});
|
|
185
179
|
cy.wait(250);
|
|
186
180
|
}
|
|
@@ -222,37 +216,27 @@ function fillDatePicker(fieldsetElement, dateOrDateWithTimeTuple, _label) {
|
|
|
222
216
|
if (!dateOrDateWithTimeTuple) {
|
|
223
217
|
// -------------------------------------------------------------------------
|
|
224
218
|
// Date without time
|
|
225
|
-
cy.wrap(fieldsetElement).find('[aria-label="Jour"]').
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
cy.wrap(fieldsetElement).find('[aria-label="Mois"]').clear({
|
|
229
|
-
force: true
|
|
230
|
-
});
|
|
231
|
-
cy.wrap(fieldsetElement).find('[aria-label="Année"]').clear({
|
|
232
|
-
force: true
|
|
233
|
-
});
|
|
219
|
+
cy.wrap(fieldsetElement).find('[aria-label="Jour"]').forceClear();
|
|
220
|
+
cy.wrap(fieldsetElement).find('[aria-label="Mois"]').forceClear();
|
|
221
|
+
cy.wrap(fieldsetElement).find('[aria-label="Année"]').forceClear();
|
|
234
222
|
if (hasTimeInputs) {
|
|
235
|
-
cy.wrap(fieldsetElement).find('[aria-label="Heure"]').
|
|
236
|
-
|
|
237
|
-
});
|
|
238
|
-
cy.wrap(fieldsetElement).find('[aria-label="Minute"]').clear({
|
|
239
|
-
force: true
|
|
240
|
-
});
|
|
223
|
+
cy.wrap(fieldsetElement).find('[aria-label="Heure"]').forceClear();
|
|
224
|
+
cy.wrap(fieldsetElement).find('[aria-label="Minute"]').forceClear();
|
|
241
225
|
}
|
|
242
226
|
} else {
|
|
243
227
|
const [year, month, day] = dateOrDateWithTimeTuple;
|
|
244
|
-
cy.wrap(fieldsetElement).find('[aria-label="Jour"]').
|
|
245
|
-
cy.wrap(fieldsetElement).find('[aria-label="Mois"]').
|
|
246
|
-
cy.wrap(fieldsetElement).find('[aria-label="Année"]').
|
|
228
|
+
cy.wrap(fieldsetElement).find('[aria-label="Jour"]').forceType(String(day).padStart(2, '0'));
|
|
229
|
+
cy.wrap(fieldsetElement).find('[aria-label="Mois"]').forceType(String(month).padStart(2, '0'));
|
|
230
|
+
cy.wrap(fieldsetElement).find('[aria-label="Année"]').forceType(String(year));
|
|
247
231
|
if (hasTimeInputs) {
|
|
248
232
|
const [hour, minute] = dateOrDateWithTimeTuple.slice(3);
|
|
249
|
-
cy.wrap(fieldsetElement).find('[aria-label="Heure"]').
|
|
250
|
-
cy.wrap(fieldsetElement).find('[aria-label="Minute"]').
|
|
233
|
+
cy.wrap(fieldsetElement).find('[aria-label="Heure"]').forceType(String(hour).padStart(2, '0'));
|
|
234
|
+
cy.wrap(fieldsetElement).find('[aria-label="Minute"]').forceType(String(minute).padStart(2, '0'));
|
|
251
235
|
}
|
|
252
236
|
}
|
|
253
237
|
cy.wait(250);
|
|
254
238
|
// Close the calendar & ranged time picker popup by pressing the escape key
|
|
255
|
-
cy.get('body').
|
|
239
|
+
cy.get('body').forceType('{esc}');
|
|
256
240
|
// TODO Create a util to handle the `fieldsetElement` re-creation cases.
|
|
257
241
|
// We to use a `wait` as a temporary fix to handle `fieldsetElement` re-creation cases.
|
|
258
242
|
cy.wait(250);
|
|
@@ -275,62 +259,42 @@ function fillDateRangePicker(fieldsetElement, dateOrDateWithTimeTupleRange, _lab
|
|
|
275
259
|
const hasTimeInput = inputElements.length !== 7;
|
|
276
260
|
// Empty the inputs if `dateOrDateWithTimeTupleRange` is undefined
|
|
277
261
|
if (!dateOrDateWithTimeTupleRange) {
|
|
278
|
-
cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
cy.wrap(fieldsetElement).find('[aria-label="Mois de début"]').clear({
|
|
282
|
-
force: true
|
|
283
|
-
});
|
|
284
|
-
cy.wrap(fieldsetElement).find('[aria-label="Année de début"]').clear({
|
|
285
|
-
force: true
|
|
286
|
-
});
|
|
262
|
+
cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').forceClear();
|
|
263
|
+
cy.wrap(fieldsetElement).find('[aria-label="Mois de début"]').forceClear();
|
|
264
|
+
cy.wrap(fieldsetElement).find('[aria-label="Année de début"]').forceClear();
|
|
287
265
|
if (hasTimeInput) {
|
|
288
|
-
cy.wrap(fieldsetElement).find('[aria-label="Heure de début"]').
|
|
289
|
-
|
|
290
|
-
});
|
|
291
|
-
cy.wrap(fieldsetElement).find('[aria-label="Minute de début"]').clear({
|
|
292
|
-
force: true
|
|
293
|
-
});
|
|
266
|
+
cy.wrap(fieldsetElement).find('[aria-label="Heure de début"]').forceClear();
|
|
267
|
+
cy.wrap(fieldsetElement).find('[aria-label="Minute de début"]').forceClear();
|
|
294
268
|
}
|
|
295
|
-
cy.wrap(fieldsetElement).find('[aria-label="Jour de fin"]').
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
cy.wrap(fieldsetElement).find('[aria-label="Mois de fin"]').clear({
|
|
299
|
-
force: true
|
|
300
|
-
});
|
|
301
|
-
cy.wrap(fieldsetElement).find('[aria-label="Année de fin"]').clear({
|
|
302
|
-
force: true
|
|
303
|
-
});
|
|
269
|
+
cy.wrap(fieldsetElement).find('[aria-label="Jour de fin"]').forceClear();
|
|
270
|
+
cy.wrap(fieldsetElement).find('[aria-label="Mois de fin"]').forceClear();
|
|
271
|
+
cy.wrap(fieldsetElement).find('[aria-label="Année de fin"]').forceClear();
|
|
304
272
|
if (hasTimeInput) {
|
|
305
|
-
cy.wrap(fieldsetElement).find('[aria-label="Heure de fin"]').
|
|
306
|
-
|
|
307
|
-
});
|
|
308
|
-
cy.wrap(fieldsetElement).find('[aria-label="Minute de fin"]').clear({
|
|
309
|
-
force: true
|
|
310
|
-
});
|
|
273
|
+
cy.wrap(fieldsetElement).find('[aria-label="Heure de fin"]').forceClear();
|
|
274
|
+
cy.wrap(fieldsetElement).find('[aria-label="Minute de fin"]').forceClear();
|
|
311
275
|
}
|
|
312
276
|
} else {
|
|
313
277
|
const [startDateOrDateWithTimeTuple, endDateOrDateWithTimeTuple] = dateOrDateWithTimeTupleRange;
|
|
314
278
|
const [startYear, startMonth, startDay, startHour, startMinute] = startDateOrDateWithTimeTuple;
|
|
315
279
|
const [endYear, endMonth, endDay, endHour, endMinute] = endDateOrDateWithTimeTuple;
|
|
316
|
-
cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').
|
|
317
|
-
cy.wrap(fieldsetElement).find('[aria-label="Mois de début"]').
|
|
318
|
-
cy.wrap(fieldsetElement).find('[aria-label="Année de début"]').
|
|
280
|
+
cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').forceType(String(startDay).padStart(2, '0'));
|
|
281
|
+
cy.wrap(fieldsetElement).find('[aria-label="Mois de début"]').forceType(String(startMonth).padStart(2, '0'));
|
|
282
|
+
cy.wrap(fieldsetElement).find('[aria-label="Année de début"]').forceType(String(startYear));
|
|
319
283
|
if (hasTimeInput) {
|
|
320
|
-
cy.wrap(fieldsetElement).find('[aria-label="Heure de début"]').
|
|
321
|
-
cy.wrap(fieldsetElement).find('[aria-label="Minute de début"]').
|
|
284
|
+
cy.wrap(fieldsetElement).find('[aria-label="Heure de début"]').forceType(String(startHour).padStart(2, '0'));
|
|
285
|
+
cy.wrap(fieldsetElement).find('[aria-label="Minute de début"]').forceType(String(startMinute).padStart(2, '0'));
|
|
322
286
|
}
|
|
323
|
-
cy.wrap(fieldsetElement).find('[aria-label="Jour de fin"]').
|
|
324
|
-
cy.wrap(fieldsetElement).find('[aria-label="Mois de fin"]').
|
|
325
|
-
cy.wrap(fieldsetElement).find('[aria-label="Année de fin"]').
|
|
287
|
+
cy.wrap(fieldsetElement).find('[aria-label="Jour de fin"]').forceType(String(endDay).padStart(2, '0'));
|
|
288
|
+
cy.wrap(fieldsetElement).find('[aria-label="Mois de fin"]').forceType(String(endMonth).padStart(2, '0'));
|
|
289
|
+
cy.wrap(fieldsetElement).find('[aria-label="Année de fin"]').forceType(String(endYear));
|
|
326
290
|
if (hasTimeInput) {
|
|
327
|
-
cy.wrap(fieldsetElement).find('[aria-label="Heure de fin"]').
|
|
328
|
-
cy.wrap(fieldsetElement).find('[aria-label="Minute de fin"]').
|
|
291
|
+
cy.wrap(fieldsetElement).find('[aria-label="Heure de fin"]').forceType(String(endHour).padStart(2, '0'));
|
|
292
|
+
cy.wrap(fieldsetElement).find('[aria-label="Minute de fin"]').forceType(String(endMinute).padStart(2, '0'));
|
|
329
293
|
}
|
|
330
294
|
}
|
|
331
295
|
cy.wait(250);
|
|
332
296
|
// Close the range calendar & ranged time picker popup by pressing the escape key
|
|
333
|
-
cy.get('body').
|
|
297
|
+
cy.get('body').forceType('{esc}');
|
|
334
298
|
// TODO Create a util to handle the `fieldsetElement` re-creation cases.
|
|
335
299
|
// We to use a `wait` as a temporary fix to handle `fieldsetElement` re-creation cases.
|
|
336
300
|
cy.wait(250);
|
|
@@ -352,16 +316,12 @@ function fillNumberInput(fieldElement, value, _label) {
|
|
|
352
316
|
top: -100
|
|
353
317
|
}
|
|
354
318
|
});
|
|
355
|
-
cy.wrap(fieldElement).find('input[type="number"]').
|
|
356
|
-
force: true
|
|
357
|
-
}).wait(250);
|
|
319
|
+
cy.wrap(fieldElement).find('input[type="number"]').forceClear().wait(250);
|
|
358
320
|
// If `value` is undefined, we don't need to input anything
|
|
359
321
|
if (!value) {
|
|
360
322
|
return;
|
|
361
323
|
}
|
|
362
|
-
cy.wrap(fieldElement).find('input[type="number"]').
|
|
363
|
-
force: true
|
|
364
|
-
}).wait(250);
|
|
324
|
+
cy.wrap(fieldElement).find('input[type="number"]').forceType(String(value)).wait(250);
|
|
365
325
|
}
|
|
366
326
|
|
|
367
327
|
function fillTextarea(fieldElement, value, _label) {
|
|
@@ -378,16 +338,12 @@ function fillTextarea(fieldElement, value, _label) {
|
|
|
378
338
|
top: -100
|
|
379
339
|
}
|
|
380
340
|
});
|
|
381
|
-
cy.wrap(fieldElement).find('textarea').
|
|
382
|
-
force: true
|
|
383
|
-
}).wait(250);
|
|
341
|
+
cy.wrap(fieldElement).find('textarea').forceClear().wait(250);
|
|
384
342
|
// If `value` is undefined, we don't need to input anything
|
|
385
343
|
if (!value) {
|
|
386
344
|
return;
|
|
387
345
|
}
|
|
388
|
-
cy.wrap(fieldElement).find('textarea').
|
|
389
|
-
force: true
|
|
390
|
-
}).wait(250);
|
|
346
|
+
cy.wrap(fieldElement).find('textarea').forceType(value).wait(250);
|
|
391
347
|
}
|
|
392
348
|
|
|
393
349
|
function fillTextInput(fieldElement, value, _label) {
|
|
@@ -404,16 +360,12 @@ function fillTextInput(fieldElement, value, _label) {
|
|
|
404
360
|
top: -100
|
|
405
361
|
}
|
|
406
362
|
});
|
|
407
|
-
cy.wrap(fieldElement).find('input[type="text"]').
|
|
408
|
-
force: true
|
|
409
|
-
}).wait(250);
|
|
363
|
+
cy.wrap(fieldElement).find('input[type="text"]').forceClear().wait(250);
|
|
410
364
|
// If `value` is undefined, we don't need to input anything
|
|
411
365
|
if (!value) {
|
|
412
366
|
return;
|
|
413
367
|
}
|
|
414
|
-
cy.wrap(fieldElement).find('input[type="text"]').
|
|
415
|
-
force: true
|
|
416
|
-
}).wait(250);
|
|
368
|
+
cy.wrap(fieldElement).find('input[type="text"]').forceType(value).wait(250);
|
|
417
369
|
}
|
|
418
370
|
|
|
419
371
|
function pickCheckPickerOptions(fieldElement, values, label) {
|
|
@@ -433,9 +385,7 @@ function pickCheckPickerOptions(fieldElement, values, label) {
|
|
|
433
385
|
// Clear the field if there is a clear button
|
|
434
386
|
const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
|
|
435
387
|
if (maybeClearButton) {
|
|
436
|
-
cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').
|
|
437
|
-
force: true
|
|
438
|
-
}).wait(250);
|
|
388
|
+
cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').forceClick().wait(250);
|
|
439
389
|
}
|
|
440
390
|
// If `values` is undefined, we don't need to select anything
|
|
441
391
|
if (!values) {
|
|
@@ -451,12 +401,12 @@ function pickCheckPickerOptions(fieldElement, values, label) {
|
|
|
451
401
|
const maybeSearchInput = rsuitePickerPopupElement.querySelector('input[role="searchbox"]');
|
|
452
402
|
values.forEach((value)=>{
|
|
453
403
|
if (maybeSearchInput) {
|
|
454
|
-
cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').
|
|
404
|
+
cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').forceType(value).wait(250);
|
|
455
405
|
}
|
|
456
406
|
cy.wrap(rsuitePickerPopupElement).find('[role="option"]').contains(value).scrollIntoView().forceClick();
|
|
457
407
|
});
|
|
458
408
|
// Close the picker popup by pressing the escape key
|
|
459
|
-
cy.get('body').
|
|
409
|
+
cy.get('body').forceType('{esc}');
|
|
460
410
|
// TODO Create a util to handle the `fieldElement` re-creation cases.
|
|
461
411
|
// We to use a `wait` as a temporary fix to handle `fieldElement` re-creation cases.
|
|
462
412
|
cy.wait(250);
|
|
@@ -481,7 +431,7 @@ function pickMultiSelectOptions(fieldElement, values, label) {
|
|
|
481
431
|
// Clear the field if there is a clear button
|
|
482
432
|
const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
|
|
483
433
|
if (maybeClearButton) {
|
|
484
|
-
cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').
|
|
434
|
+
cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').forceClick({
|
|
485
435
|
force: true
|
|
486
436
|
}).wait(250);
|
|
487
437
|
}
|
|
@@ -496,11 +446,11 @@ function pickMultiSelectOptions(fieldElement, values, label) {
|
|
|
496
446
|
throwError(`Could not find '.rs-picker-popup' in in field with label "${label}". Did the picker open?`);
|
|
497
447
|
}
|
|
498
448
|
values.forEach((value)=>{
|
|
499
|
-
cy.wrap(fieldElement).find('.rs-picker-toggle').
|
|
449
|
+
cy.wrap(fieldElement).find('.rs-picker-toggle').forceClick().wait(250).forceType(value).wait(250);
|
|
500
450
|
cy.wrap(rsuitePickerPopupElement).find('[role="option"]').contains(value).scrollIntoView().forceClick();
|
|
501
451
|
});
|
|
502
452
|
// Close the picker popup by pressing the escape key
|
|
503
|
-
cy.get('body').
|
|
453
|
+
cy.get('body').forceType('{esc}');
|
|
504
454
|
// TODO Create a util to handle the `fieldElement` re-creation cases.
|
|
505
455
|
// We to use a `wait` as a temporary fix to handle `fieldElement` re-creation cases.
|
|
506
456
|
cy.wait(250);
|
|
@@ -525,16 +475,14 @@ function pickSearchOption(fieldElement, value, _label) {
|
|
|
525
475
|
// Clear the field if there is a clear button
|
|
526
476
|
const maybeClearButton = fieldElement.querySelector('.Field-Search__ClearButton');
|
|
527
477
|
if (maybeClearButton) {
|
|
528
|
-
cy.wrap(fieldElement).find('.Field-Search__ClearButton').
|
|
529
|
-
force: true
|
|
530
|
-
}).wait(250);
|
|
478
|
+
cy.wrap(fieldElement).find('.Field-Search__ClearButton').forceClick().wait(250);
|
|
531
479
|
}
|
|
532
480
|
// If the value is undefined, we don't need to select anything
|
|
533
481
|
if (!value) {
|
|
534
482
|
return;
|
|
535
483
|
}
|
|
536
484
|
// Search for the value
|
|
537
|
-
cy.wrap(fieldElement).find('input[role="combobox"]').
|
|
485
|
+
cy.wrap(fieldElement).find('input[role="combobox"]').forceType(value);
|
|
538
486
|
// Wait for the picker to open
|
|
539
487
|
cy.wrap(fieldElement).get('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
|
|
540
488
|
// Select the first picker option
|
|
@@ -559,9 +507,7 @@ function pickSelectOption(fieldElement, value, label) {
|
|
|
559
507
|
// Clear the field if there is a clear button
|
|
560
508
|
const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
|
|
561
509
|
if (maybeClearButton) {
|
|
562
|
-
cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').
|
|
563
|
-
force: true
|
|
564
|
-
}).wait(250);
|
|
510
|
+
cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').forceClick().wait(250);
|
|
565
511
|
}
|
|
566
512
|
// If the value is undefined, we don't need to select anything
|
|
567
513
|
if (!value) {
|
|
@@ -577,7 +523,7 @@ function pickSelectOption(fieldElement, value, label) {
|
|
|
577
523
|
// Search for the value if there is a search input
|
|
578
524
|
const maybeSearchInput = rsuitePickerPopupElement.querySelector('input[role="searchbox"]');
|
|
579
525
|
if (maybeSearchInput) {
|
|
580
|
-
cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').
|
|
526
|
+
cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').forceType(value).wait(250);
|
|
581
527
|
}
|
|
582
528
|
cy.wrap(rsuitePickerPopupElement).find('[role="option"]').contains(value).scrollIntoView().forceClick().wait(250);
|
|
583
529
|
});
|
|
@@ -772,10 +718,43 @@ function fill(label, value, leftRetries = RETRIES) {
|
|
|
772
718
|
}
|
|
773
719
|
}
|
|
774
720
|
|
|
775
|
-
function
|
|
721
|
+
function forceCheck(subject, options = {}) {
|
|
722
|
+
Cypress.log({
|
|
723
|
+
consoleProps: ()=>({
|
|
724
|
+
'Applied to': subject,
|
|
725
|
+
Elements: 1
|
|
726
|
+
}),
|
|
727
|
+
name: 'forceCheck'
|
|
728
|
+
});
|
|
729
|
+
if (!subject) {
|
|
730
|
+
throw new Error(`Could not find subject.`);
|
|
731
|
+
}
|
|
732
|
+
const wrappedSubject = cy.wrap(subject);
|
|
733
|
+
return wrappedSubject.check({
|
|
734
|
+
...options,
|
|
735
|
+
force: true
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function forceClear(subject, options = {}) {
|
|
740
|
+
Cypress.log({
|
|
741
|
+
consoleProps: ()=>({
|
|
742
|
+
'Applied to': subject,
|
|
743
|
+
Elements: 1
|
|
744
|
+
}),
|
|
745
|
+
name: 'forceClear'
|
|
746
|
+
});
|
|
776
747
|
if (!subject) {
|
|
777
748
|
throw new Error(`Could not find subject.`);
|
|
778
749
|
}
|
|
750
|
+
const wrappedSubject = cy.wrap(subject);
|
|
751
|
+
return wrappedSubject.clear({
|
|
752
|
+
...options,
|
|
753
|
+
force: true
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
function forceClick(subject, options = {}) {
|
|
779
758
|
Cypress.log({
|
|
780
759
|
consoleProps: ()=>({
|
|
781
760
|
'Applied to': subject,
|
|
@@ -783,15 +762,50 @@ function forceClick([subject]) {
|
|
|
783
762
|
}),
|
|
784
763
|
name: 'forceClick'
|
|
785
764
|
});
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
force: true
|
|
789
|
-
});
|
|
790
|
-
} catch (_) {
|
|
791
|
-
return cy.wrap(subject).click({
|
|
792
|
-
force: true
|
|
793
|
-
});
|
|
765
|
+
if (!subject) {
|
|
766
|
+
throw new Error(`Could not find subject.`);
|
|
794
767
|
}
|
|
768
|
+
const wrappedSubject = cy.wrap(subject);
|
|
769
|
+
return wrappedSubject.click({
|
|
770
|
+
...options,
|
|
771
|
+
force: true
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function forceType(subject, text, options = {}) {
|
|
776
|
+
Cypress.log({
|
|
777
|
+
consoleProps: ()=>({
|
|
778
|
+
'Applied to': subject,
|
|
779
|
+
Elements: 1
|
|
780
|
+
}),
|
|
781
|
+
name: 'forceType'
|
|
782
|
+
});
|
|
783
|
+
if (!subject) {
|
|
784
|
+
throw new Error(`Could not find subject.`);
|
|
785
|
+
}
|
|
786
|
+
const wrappedSubject = cy.wrap(subject);
|
|
787
|
+
return wrappedSubject.type(text, {
|
|
788
|
+
...options,
|
|
789
|
+
force: true
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function forceUncheck(subject, options = {}) {
|
|
794
|
+
Cypress.log({
|
|
795
|
+
consoleProps: ()=>({
|
|
796
|
+
'Applied to': subject,
|
|
797
|
+
Elements: 1
|
|
798
|
+
}),
|
|
799
|
+
name: 'forceUncheck'
|
|
800
|
+
});
|
|
801
|
+
if (!subject) {
|
|
802
|
+
throw new Error(`Could not find subject.`);
|
|
803
|
+
}
|
|
804
|
+
const wrappedSubject = cy.wrap(subject);
|
|
805
|
+
return wrappedSubject.uncheck({
|
|
806
|
+
...options,
|
|
807
|
+
force: true
|
|
808
|
+
});
|
|
795
809
|
}
|
|
796
810
|
|
|
797
811
|
function getDataCy(dataCy) {
|
|
@@ -840,9 +854,21 @@ const registerMonitorUiCustomCommands = ()=>{
|
|
|
840
854
|
Cypress.Commands.add('waitForLastRequest', waitForLastRequest);
|
|
841
855
|
Cypress.Commands.add('clickOutside', clickOutside);
|
|
842
856
|
Cypress.Commands.add('fill', fill);
|
|
857
|
+
Cypress.Commands.add('forceCheck', {
|
|
858
|
+
prevSubject: true
|
|
859
|
+
}, forceCheck);
|
|
860
|
+
Cypress.Commands.add('forceClear', {
|
|
861
|
+
prevSubject: true
|
|
862
|
+
}, forceClear);
|
|
843
863
|
Cypress.Commands.add('forceClick', {
|
|
844
864
|
prevSubject: true
|
|
845
865
|
}, forceClick);
|
|
866
|
+
Cypress.Commands.add('forceType', {
|
|
867
|
+
prevSubject: true
|
|
868
|
+
}, forceType);
|
|
869
|
+
Cypress.Commands.add('forceUncheck', {
|
|
870
|
+
prevSubject: true
|
|
871
|
+
}, forceUncheck);
|
|
846
872
|
Cypress.Commands.add('getDataCy', getDataCy);
|
|
847
873
|
Cypress.Commands.add('getTableRowById', {
|
|
848
874
|
prevSubject: 'optional'
|
package/cypress/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
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.
|
|
4
|
+
"version": "12.2.0",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|