@mtes-mct/monitor-ui 24.34.0 → 24.34.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/README.md CHANGED
@@ -94,15 +94,15 @@ Please read the [contributing document](CONTRIBUTING.md) for setup and contribut
94
94
  [img-coverage]: https://img.shields.io/codecov/c/github/MTES-MCT/monitor-ui?flag=unit&style=for-the-badge
95
95
  [img-documentation]: https://img.shields.io/badge/StoryBook-Docs-007ec6?logo=storybook&style=for-the-badge
96
96
  [img-e2e-tests]:
97
- https://img.shields.io/endpoint?url=https://cloud.cypress.io/badge/simple/qnpjm2/main&label=E2E&logo=cypress&style=for-the-badge
97
+ https://img.shields.io/endpoint?url=https://cloud.cypress.io/badge/simple/juvjsi/main&label=E2E&logo=cypress&style=for-the-badge
98
98
  [img-license]: https://img.shields.io/github/license/MTES-MCT/monitor-ui?style=for-the-badge
99
99
  [img-npm]: https://img.shields.io/npm/v/@mtes-mct/monitor-ui?style=for-the-badge
100
100
  [img-unit-tests]:
101
101
  https://img.shields.io/github/actions/workflow/status/MTES-MCT/monitor-ui/check.yml?branch=main&label=Unit&style=for-the-badge
102
102
  [lnk-coverage]: https://app.codecov.io/gh/MTES-MCT/monitor-ui
103
103
  [lnk-documentation]: https://mtes-mct.github.io/monitor-ui/?path=/docs/introduction--documentation
104
- [lnk-e2e-tests]: https://cloud.cypress.io/projects/qnpjm2/runs
105
- [lnk-e2e-tests]: https://cloud.cypress.io/projects/qnpjm2/runs
104
+ [lnk-e2e-tests]: https://cloud.cypress.io/projects/juvjsi/runs
105
+ [lnk-e2e-tests]: https://cloud.cypress.io/projects/juvjsi/runs
106
106
  [lnk-github-monitorenv]: https://github.com/MTES-MCT/monitorenv
107
107
  [lnk-github-monitorfish]: https://github.com/MTES-MCT/monitorfish
108
108
  [lnk-github-rapportnav]: https://github.com/MTES-MCT/rapportnav2
@@ -0,0 +1,122 @@
1
+ /// <reference types="cypress" />
2
+
3
+ declare namespace Cypress {
4
+ interface Chainable {
5
+ /**
6
+ * Clicks on a button with the given text content / aria-label attribute / title attribute.
7
+ *
8
+ * @description
9
+ * `label` must match the exact button's text content / aria-label attribute / title attribute.
10
+ */
11
+ clickButton(
12
+ label: string,
13
+ options?: Partial<{
14
+ index: number
15
+ withinSelector: string
16
+ withoutScroll: boolean
17
+ }>
18
+ ): Chainable<JQuery<HTMLButtonElement>>
19
+
20
+ clickLink(linkText: string): Chainable<JQuery<HTMLAnchorElement>>
21
+
22
+ /**
23
+ * @description
24
+ * Useful to close modals.
25
+ */
26
+ clickOutside(xPosition?: number, yPosition?: number): void
27
+
28
+ /**
29
+ * @description
30
+ * You can set the `retries` option to a number greater than 5 (default) to retry the action in case of failure.
31
+ * You can also set the `force` option to `true` to force the action without waiting for the element to be visible.
32
+ *
33
+ * ⚠️ In order to ensure backward compatibility, the `force` option is set to `true` by default.
34
+ * This will be changed to `false` in the next major version.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * cy.fill('My TextInput / Textarea', 'Hello World')
39
+ * cy.fill('My NumberInput', 42)
40
+ * cy.fill('My Checkbox', true) // or `false` to uncheck
41
+ * cy.fill('My MultiRadio / Select', 'First Option')
42
+ * cy.fill('My CheckPicker / MultiCheckbox / MultiSelect', ['First Option', 'Second Option'])
43
+ * cy.fill('My DatePicker', [2020, 12, 31])
44
+ * cy.fill('My DatePicker', [2020, 12, 31, 23, 59])
45
+ * cy.fill('My DateRangePicker', [[2020, 12, 31], [2021, 1, 1]])
46
+ * cy.fill('My DateRangePicker', [[2020, 12, 31, 23, 59], [2021, 1, 1, 23, 59]])
47
+ *
48
+ * // Clear any field except the `<MultiRadio />` which can't be cleared
49
+ * cy.fill('My Field', undefined)
50
+ * ```
51
+ */
52
+ fill(label: string, value: any, options?: Partial<FillOptions>): void
53
+
54
+ forceCheck(options?: Partial<CheckOptions>): Chainable<JQuery<HTMLElement>>
55
+ forceClear(options?: Partial<ClearOptions>): Chainable<JQuery<HTMLElement>>
56
+ forceClick(options?: Partial<ClickOptions>): Chainable<JQuery<HTMLElement>>
57
+ forceType(text: string, options?: Partial<TypeOption>): Chainable<JQuery<HTMLElement>>
58
+ forceUncheck(options?: Partial<CheckOptions>): Chainable<JQuery<HTMLElement>>
59
+
60
+ /**
61
+ * @example
62
+ * ```ts
63
+ * cy.getDataCy('my-list').should('have.length', 42)
64
+ * ```
65
+ */
66
+ getDataCy(dataCy: string): Chainable<JQuery<HTMLElement>>
67
+
68
+ /**
69
+ * @description Only works with `<SimpleTable />` tables.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * cy.getTableRowById(42)
74
+ * cy.getDataCy('my-list').getTableRowByText(42).clickButton('Edit')
75
+ * ```
76
+ */
77
+ getTableRowById(id: number | string): Chainable<JQuery<HTMLElement>>
78
+
79
+ /**
80
+ * @description Only works with `<SimpleTable />` tables.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * cy.getTableRowByText('First Row Name')
85
+ * cy.getDataCy('my-list').getTableRowByText('First Row Name').clickButton('Edit')
86
+ * ```
87
+ */
88
+ getTableRowByText(text: string): Chainable<JQuery<HTMLElement>>
89
+
90
+ /**
91
+ * @description Assert the request payload when a form is auto-saving and the requests number is not determinist
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * cy.waitForLastRequest('@updateMissionAction',
96
+ * {
97
+ * body: {
98
+ * property: 'VALUE',
99
+ * }
100
+ * }, 5, response => {
101
+ * console.log('After response', response)
102
+ * })
103
+ * .its('response.statusCode')
104
+ * .should('eq', 201)
105
+ * })
106
+ * ```
107
+ */
108
+ waitForLastRequest(alias: string, partialRequest, maxRequests: number, level?, callback?: (response) => void)
109
+ }
110
+
111
+ type DateTuple = [number, number, number]
112
+ type DateWithTimeTuple = [number, number, number, number, number]
113
+
114
+ type DateRangeTuple = [DateTuple, DateTuple]
115
+ type DateWithTimeRangeTuple = [DateWithTimeTuple, DateWithTimeTuple]
116
+
117
+ interface FillOptions extends Forceable {
118
+ delay: number
119
+ index: number
120
+ retries: number
121
+ }
122
+ }
@@ -0,0 +1,535 @@
1
+ function h(t, n, {
2
+ fallbackSelector: i,
3
+ index: r = 0,
4
+ inElement: c
5
+ } = {}) {
6
+ const o = n.trim();
7
+ if (c) {
8
+ let a, y = 0;
9
+ return Cypress.$(c).find(t).each(function() {
10
+ if (!a && Cypress.$(this).text().trim() === o) {
11
+ if (y < r) {
12
+ y += 1;
13
+ return;
14
+ }
15
+ a = this;
16
+ }
17
+ }), !a && i ? (cy.log(`⚠️ Using fallback selector: "${i}"`), Cypress.$(c).find(i)) : a;
18
+ }
19
+ let e, s = 0;
20
+ return Cypress.$(t).each(function() {
21
+ if (!e && Cypress.$(this).text().trim() === o) {
22
+ if (s < r) {
23
+ s += 1;
24
+ return;
25
+ }
26
+ e = this;
27
+ }
28
+ }), !e && i ? (console.warn(`Using fallback selector: "${i}".`), Cypress.$(i)) : e;
29
+ }
30
+ const b = 5;
31
+ function O(t, n, {
32
+ index: i,
33
+ prevSubjectElement: r
34
+ }) {
35
+ const c = h(`${n}button`, t, {
36
+ index: i,
37
+ inElement: r
38
+ });
39
+ if (c)
40
+ return c;
41
+ const o = r ? r.querySelectorAll(`${n}button[aria-label="${t}"]`)[i] : Cypress.$(`${n}button[aria-label="${t}"]`).get(i);
42
+ if (o)
43
+ return o;
44
+ const e = r ? r.querySelectorAll(`${n}button[title="${t}"]`)[i] : Cypress.$(`${n}button[title="${t}"]`).get(i);
45
+ if (e)
46
+ return e;
47
+ const s = h(`${n}[role="button"]`, t, {
48
+ index: i,
49
+ inElement: r
50
+ });
51
+ if (s)
52
+ return s;
53
+ const a = r ? r.querySelectorAll(`${n}[role="button"][aria-label="${t}"]`)[i] : Cypress.$(`${n}[role="button"][aria-label="${t}"]`).get(i);
54
+ if (a)
55
+ return a;
56
+ const y = r ? r.querySelectorAll(`${n}[role="button"][title="${t}"]`)[i] : Cypress.$(`${n}[role="button"][title="${t}"]`).get(i);
57
+ if (y)
58
+ return y;
59
+ const l = h(`${n}[role="menuitem"]`, t, {
60
+ index: i,
61
+ inElement: r
62
+ });
63
+ if (l)
64
+ return l;
65
+ }
66
+ function $(t, n, {
67
+ index: i = 0,
68
+ withinSelector: r,
69
+ withoutScroll: c = !1
70
+ } = {}, o = b) {
71
+ const e = t ? t[0] : void 0;
72
+ if (t && !t[0])
73
+ throw new Error("`prevSubjectElements[0]` is undefined.");
74
+ const s = r ? `${r} ` : "", a = O(n, s, {
75
+ index: i,
76
+ prevSubjectElement: e
77
+ });
78
+ if (a)
79
+ return (c ? cy.wrap(a).forceClick() : cy.wrap(a).scrollIntoView().forceClick()).wait(250);
80
+ if (o > 0)
81
+ return cy.wait(250).then(() => (cy.log(`Retrying (${b - o + 1} / ${b})...`), $(t, n, { index: i, withinSelector: r, withoutScroll: c }, o - 1)));
82
+ throw new Error(`Unable to find button with label "${n}".`);
83
+ }
84
+ function R(t) {
85
+ return cy.get("a").contains(t).click();
86
+ }
87
+ function D(t = 0, n = 0) {
88
+ cy.log(`Click outside at position: ${t}, ${n}`), cy.get("body").click(t, n, { force: !0 });
89
+ }
90
+ function L(t, n, i, r) {
91
+ Cypress.log({
92
+ consoleProps: () => ({
93
+ "Applied to": t,
94
+ Elements: 1
95
+ }),
96
+ name: "checkCheckbox"
97
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), n ? cy.wrap(t).find('input[type="checkbox"]').check({ force: r }).wait(250) : cy.wrap(t).find('input[type="checkbox"]').uncheck({ force: r }).wait(250);
98
+ }
99
+ function P(t, n, i, r) {
100
+ Cypress.log({
101
+ consoleProps: () => ({
102
+ "Applied to": t,
103
+ Elements: 1
104
+ }),
105
+ name: "checkMultiCheckboxOptions"
106
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), cy.wrap(t).find('input[type="checkbox"]').uncheck({ force: r }).wait(250), n && (n.forEach((c) => {
107
+ cy.wrap(t).contains(".rs-checkbox-label", c).closest(".rs-checkbox").find('input[type="checkbox"]').check({ force: r });
108
+ }), cy.wait(250));
109
+ }
110
+ function q(t, n, i, r) {
111
+ Cypress.log({
112
+ consoleProps: () => ({
113
+ "Applied to": t,
114
+ Elements: 1
115
+ }),
116
+ name: "checkMultiRadioOption"
117
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }).find("label").contains(n).click({ force: r }).wait(250);
118
+ }
119
+ const _ = {
120
+ delay: 10,
121
+ force: !0,
122
+ index: 0,
123
+ retries: 5
124
+ };
125
+ function p(t) {
126
+ throw new Error(`[monitor-ui > Cypress] ${t}`);
127
+ }
128
+ function V(t, n, i, r, c) {
129
+ Cypress.log({
130
+ consoleProps: () => ({
131
+ "Applied to": t,
132
+ Elements: 1
133
+ }),
134
+ name: "fillDatePicker"
135
+ });
136
+ const o = t.querySelectorAll("input");
137
+ o.length !== 4 && o.length !== 6 && p(`Expected to find 4 or 6 inputs within in DatePicker but found ${o.length}.`);
138
+ const e = o.length === 6;
139
+ if (!n)
140
+ cy.wrap(t).find('[aria-label="Jour"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Mois"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Année"]').clear({ force: r }), e && (cy.wrap(t).find('[aria-label="Heure"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Minute"]').clear({ force: r }));
141
+ else {
142
+ const [s, a, y] = n;
143
+ if (cy.wrap(t).find('[aria-label="Jour"]').type(String(y).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Mois"]').type(String(a).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Année"]').type(String(s), { delay: c, force: r }), e) {
144
+ const [l, k] = n.slice(3);
145
+ cy.wrap(t).find('[aria-label="Heure"]').type(String(l).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Minute"]').type(String(k).padStart(2, "0"), { delay: c, force: r });
146
+ }
147
+ }
148
+ cy.wait(250), cy.get("body").type("{esc}", { delay: c, force: r }), cy.wait(250);
149
+ }
150
+ function U(t, n, i, r, c) {
151
+ Cypress.log({
152
+ consoleProps: () => ({
153
+ "Applied to": t,
154
+ Elements: 1
155
+ }),
156
+ name: "fillDateRangePicker"
157
+ });
158
+ const o = t.querySelectorAll("input");
159
+ o.length !== 7 && o.length !== 11 && p(`Expected to find 7 or 11 inputs within in DatePicker but found ${o.length}.`);
160
+ const e = o.length !== 7;
161
+ if (!n)
162
+ cy.wrap(t).find('[aria-label="Jour de début"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Mois de début"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Année de début"]').clear({ force: r }), e && (cy.wrap(t).find('[aria-label="Heure de début"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Minute de début"]').clear({ force: r })), cy.wrap(t).find('[aria-label="Jour de fin"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Mois de fin"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Année de fin"]').clear({ force: r }), e && (cy.wrap(t).find('[aria-label="Heure de fin"]').clear({ force: r }), cy.wrap(t).find('[aria-label="Minute de fin"]').clear({ force: r }));
163
+ else {
164
+ const [s, a] = n, [y, l, k, A, I] = s, [T, x, M, F, B] = a;
165
+ cy.wrap(t).find('[aria-label="Jour de début"]').type(String(k).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Mois de début"]').type(String(l).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Année de début"]').type(String(y), { force: r }), e && (cy.wrap(t).find('[aria-label="Heure de début"]').type(String(A).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Minute de début"]').type(String(I).padStart(2, "0"), { force: r })), cy.wrap(t).find('[aria-label="Jour de fin"]').type(String(M).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Mois de fin"]').type(String(x).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Année de fin"]').type(String(T), { force: r }), e && (cy.wrap(t).find('[aria-label="Heure de fin"]').type(String(F).padStart(2, "0"), { delay: c, force: r }), cy.wrap(t).find('[aria-label="Minute de fin"]').type(String(B).padStart(2, "0"), { delay: c, force: r }));
166
+ }
167
+ cy.wait(250), cy.get("body").type("{esc}", { delay: c, force: r }), cy.wait(250);
168
+ }
169
+ function N(t, n, i, r, c) {
170
+ Cypress.log({
171
+ consoleProps: () => ({
172
+ "Applied to": t,
173
+ Elements: 1
174
+ }),
175
+ name: "fillNumberInput"
176
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), cy.wrap(t).find('input[type="number"]').clear({ force: r }).wait(250), n && cy.wrap(t).find('input[type="number"]').type(String(n), { delay: c, force: r }).wait(250);
177
+ }
178
+ function H(t, n, i, r, c) {
179
+ Cypress.log({
180
+ consoleProps: () => ({
181
+ "Applied to": t,
182
+ Elements: 1
183
+ }),
184
+ name: "fillTextarea"
185
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), cy.wrap(t).find("textarea").clear({ force: r }).wait(250), n && cy.wrap(t).find("textarea").type(n, { delay: c, force: r }).wait(250);
186
+ }
187
+ function g(t, n, i, r, c) {
188
+ Cypress.log({
189
+ consoleProps: () => ({
190
+ "Applied to": t,
191
+ Elements: 1
192
+ }),
193
+ name: "fillTextInput"
194
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), cy.wrap(t).find("input").clear({ force: r }).wait(250), n && cy.wrap(t).find("input").type(n, { delay: c, force: r }).wait(250);
195
+ }
196
+ function C(t, n, i, r, c, o = "option") {
197
+ Cypress.log({
198
+ consoleProps: () => ({
199
+ "Applied to": t,
200
+ Elements: 1
201
+ }),
202
+ name: "pickCheckPickerOptions"
203
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), t.querySelector(".rs-stack > .rs-stack-item > .rs-picker-clean") && cy.wrap(t).find(".rs-stack > .rs-stack-item > .rs-picker-clean").click({ force: r }).wait(250), n && (cy.wrap(t).find(".rs-picker-toggle").click({ force: r }), cy.wrap(t).find(".rs-picker-popup").then(([s]) => {
204
+ s || p(`Could not find '.rs-picker-popup' in in field with label "${i}". Did the picker open?`);
205
+ const a = s.querySelector('input[role="searchbox"]');
206
+ n.forEach((y) => {
207
+ a && cy.wrap(s).find('input[role="searchbox"]').clear().type(y, { delay: c, force: r }).wait(250), cy.wrap(s).find(`[role="${o}"]`).contains(y).first().scrollIntoView().click({ force: r });
208
+ }), cy.get("body").type("{esc}", { delay: c, force: r }), cy.wait(250);
209
+ }));
210
+ }
211
+ function J(t, n, i, r, c) {
212
+ Cypress.log({
213
+ consoleProps: () => ({
214
+ "Applied to": t,
215
+ Elements: 1
216
+ }),
217
+ name: "pickMultiCascaderOptions"
218
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), t.querySelector(".rs-stack > .rs-stack-item > .rs-picker-clean") && cy.wrap(t).find(".rs-stack > .rs-stack-item > .rs-picker-clean").click({ force: r }).wait(250), n && (cy.wrap(t).find(".rs-picker-toggle").click({ force: r }), cy.wrap(t).find(".rs-picker-popup").then(([e]) => {
219
+ e || p(`Could not find '.rs-picker-popup' in in field with label "${i}". Did the picker open?`), e.querySelector('input[role="searchbox"]') || p(
220
+ p(
221
+ `\`cy.fill()\` can't handle the MultiCascader with \`<label>\` "${i}" because it's not \`searchable\`.`
222
+ )
223
+ ), n.forEach((a) => {
224
+ cy.wrap(e).find('input[role="searchbox"]').clear().type(a, { delay: c, force: r }).wait(250), cy.wrap(e).find('[role="treeitem"]').contains(a).first().scrollIntoView().click({ force: r });
225
+ }), cy.get("body").type("{esc}", { delay: c, force: r }), cy.wait(250);
226
+ }));
227
+ }
228
+ function W(t, n, i, r, c) {
229
+ Cypress.log({
230
+ consoleProps: () => ({
231
+ "Applied to": t,
232
+ Elements: 1
233
+ }),
234
+ name: "pickMultiSelectOptions"
235
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), t.querySelector(".rs-stack > .rs-stack-item > .rs-picker-clean") && cy.wrap(t).find(".rs-stack > .rs-stack-item > .rs-picker-clean").click({ force: r }).wait(250), n && (cy.wrap(t).find(".rs-picker-toggle").click({ force: r }), cy.wrap(t).get(".rs-picker-popup").then(([e]) => {
236
+ e || p(`Could not find '.rs-picker-popup' in in field with label "${i}". Did the picker open?`), n.forEach((s) => {
237
+ t.querySelector(".rs-picker-search-input > input") && cy.wrap(t).find(".rs-picker-search-input > input").type(s, { delay: c, force: r }).wait(250), cy.wrap(e).find('[role="option"]').contains(s).first().scrollIntoView().click({ force: r });
238
+ }), cy.get("body").type("{esc}", { delay: c, force: r }), cy.wait(250);
239
+ }));
240
+ }
241
+ function X(t, n, i, r, c) {
242
+ Cypress.log({
243
+ consoleProps: () => ({
244
+ "Applied to": t,
245
+ Elements: 1
246
+ }),
247
+ name: "pickSearchOption"
248
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), t.querySelector(".Field-Search__ClearButton") && cy.wrap(t).find(".Field-Search__ClearButton").click({ force: r }).wait(250), n && (cy.wrap(t).find('input[role="combobox"]').type(n, { delay: c, force: r }), cy.wrap(t).get(".rs-picker-popup").then(([e]) => {
249
+ cy.wrap(e).find('[role="option"]').first().scrollIntoView().click({ force: r }).wait(250);
250
+ }));
251
+ }
252
+ function Y(t, n, i, r, c) {
253
+ Cypress.log({
254
+ consoleProps: () => ({
255
+ "Applied to": t,
256
+ Elements: 1
257
+ }),
258
+ name: "pickSelectOption"
259
+ }), cy.wrap(t).scrollIntoView({ offset: { left: 0, top: -100 } }), t.querySelector(".rs-stack > .rs-stack-item > .rs-picker-clean") && cy.wrap(t).find(".rs-stack > .rs-stack-item > .rs-picker-clean").click({ force: r }).wait(250), n && (cy.wrap(t).find(".rs-stack > .rs-stack-item > .rs-picker-caret-icon").click({ force: r }).wait(250), cy.wrap(t).get(".rs-picker-popup").then(([e]) => {
260
+ e || p(`Could not find '.rs-picker-popup' in in field with label "${i}". Did the picker open?`), e.querySelector('input[role="searchbox"]') && cy.wrap(e).find('input[role="searchbox"]').type(n, { delay: c, force: r }).wait(250), cy.wrap(e).find('[role="option"]').contains(n).scrollIntoView().click({ force: r }).wait(250);
261
+ }));
262
+ }
263
+ const d = (t, n) => p(
264
+ `\`value\` should be of type \`${t}\` in \`cy.fill(label, value)\` when used on a <${n} />.`
265
+ );
266
+ function z(t, n) {
267
+ t === void 0 || typeof t == "boolean" || d("boolean | undefined", n);
268
+ }
269
+ function j(t, n) {
270
+ t !== void 0 && (Array.isArray(t) && (t.length === 3 || t.length === 5) && t.every((i) => typeof i == "number") || d("DateTuple | DateWithTimeTuple | undefined", n));
271
+ }
272
+ function G(t, n) {
273
+ t !== void 0 && (Array.isArray(t) && t.length === 2 && (Array.isArray(t[0]) && t[0].length === 3 && t[1].length === 3 || Array.isArray(t[0]) && t[0].length === 5 && t[1].length === 5) && t.every(
274
+ (i) => Array.isArray(i) && i.every((r) => typeof r == "number")
275
+ ) || d("DateRangeTuple | DateWithTimeRangeTuple | undefined", n));
276
+ }
277
+ function K(t, n) {
278
+ t === void 0 || typeof t == "number" || d("number | undefined", n);
279
+ }
280
+ function Q(t, n) {
281
+ typeof t != "string" && d("string", n);
282
+ }
283
+ function u(t, n) {
284
+ t === void 0 || typeof t == "string" || d("string | undefined", n);
285
+ }
286
+ function f(t, n) {
287
+ t !== void 0 && (Array.isArray(t) && t.every((i) => typeof i == "string") || d("string[] | undefined", n));
288
+ }
289
+ const Z = 100;
290
+ function S(t, n, i = 0) {
291
+ let r = t, c = 0, o = -1;
292
+ for (; o < Z; ) {
293
+ if (o += 1, r = r.parentElement, !r)
294
+ return;
295
+ if (r.matches(n)) {
296
+ if (c === i)
297
+ return r;
298
+ c += 1;
299
+ }
300
+ }
301
+ }
302
+ let w;
303
+ function m(t, n, i = {}) {
304
+ const r = { ..._, ...i };
305
+ w || (w = r.retries), Cypress.log({
306
+ consoleProps: () => ({
307
+ "Left Retries": r.retries
308
+ }),
309
+ message: `Filling field with label/legend "${t}" with value "${JSON.stringify(n)}".`,
310
+ name: "fill"
311
+ });
312
+ try {
313
+ const c = h("label", t, { index: r.index });
314
+ if (c) {
315
+ const e = S(c, ".Element-Field");
316
+ switch (e || p(
317
+ `Could not find '.Element-Field' in field with label "${t}" at index "${r.index}".`
318
+ ), !0) {
319
+ // ---------------------------------------------------------------------
320
+ // Checkbox
321
+ case e.classList.contains("Field-Checkbox"):
322
+ z(n, "Checkbox"), L(e, n, t, r.force);
323
+ return;
324
+ // ---------------------------------------------------------------------
325
+ // CheckPicker
326
+ case e.classList.contains("Field-CheckPicker"):
327
+ f(n, "CheckPicker"), C(e, n, t, r.force, r.delay);
328
+ return;
329
+ // ---------------------------------------------------------------------
330
+ // CheckTreePicker
331
+ case e.classList.contains("Field-CheckTreePicker"):
332
+ f(n, "CheckTreePicker"), C(
333
+ e,
334
+ n,
335
+ t,
336
+ r.force,
337
+ r.delay,
338
+ "treeitem"
339
+ );
340
+ return;
341
+ // ---------------------------------------------------------------------
342
+ // MultiCascader
343
+ case e.classList.contains("Field-MultiCascader"):
344
+ f(n, "MultiCascader"), J(e, n, t, r.force, r.delay);
345
+ return;
346
+ // ---------------------------------------------------------------------
347
+ // MultiSelect
348
+ case e.classList.contains("Field-MultiSelect"):
349
+ f(n, "MultiSelect"), W(e, n, t, r.force, r.delay);
350
+ return;
351
+ // ---------------------------------------------------------------------
352
+ // Search
353
+ case e.classList.contains("Field-Search"):
354
+ u(n, "Search"), X(e, n, t, r.force, r.delay);
355
+ return;
356
+ // ---------------------------------------------------------------------
357
+ // Select
358
+ case e.classList.contains("Field-Select"):
359
+ u(n, "Select"), Y(e, n, t, r.force, r.delay);
360
+ return;
361
+ // ---------------------------------------------------------------------
362
+ // NumberInput
363
+ case e.classList.contains("Field-NumberInput"):
364
+ K(n, "TextInput"), N(e, n, t, r.force, r.delay);
365
+ return;
366
+ // ---------------------------------------------------------------------
367
+ // Textarea
368
+ case e.classList.contains("Field-Textarea"):
369
+ u(n, "Textarea"), H(e, n, t, r.force, r.delay);
370
+ return;
371
+ // ---------------------------------------------------------------------
372
+ // TextInput
373
+ case e.classList.contains("Field-TextInput"):
374
+ u(n, "TextInput"), g(e, n, t, r.force, r.delay);
375
+ return;
376
+ // ---------------------------------------------------------------------
377
+ // PhoneInput
378
+ case e.classList.contains("Field-PhoneInput"):
379
+ u(n, "PhoneInput"), g(e, n, t, r.force, r.delay);
380
+ return;
381
+ // ---------------------------------------------------------------------
382
+ // LinkInput
383
+ case e.classList.contains("Field-LinkInput"):
384
+ u(n, "LinkInput"), g(e, n, t, r.force, r.delay);
385
+ return;
386
+ default:
387
+ p(`\`cy.fill()\` can't handle field with \`<label>\` "${t}".`);
388
+ }
389
+ }
390
+ const o = h("legend", t, { index: r.index });
391
+ if (o) {
392
+ const e = S(o, ".Element-Fieldset");
393
+ switch (e || p(
394
+ `Could not find '.Element-Fieldset' in field with \`<legend />\` "${t}" at index "${r.index}".`
395
+ ), !0) {
396
+ // ---------------------------------------------------------------------
397
+ // DatePicker
398
+ case e.classList.contains("Field-DatePicker"):
399
+ j(n, "DatePicker"), V(e, n, t, r.force, r.delay);
400
+ return;
401
+ // ---------------------------------------------------------------------
402
+ // DateRangePicker
403
+ case e.classList.contains("Field-DateRangePicker"):
404
+ G(n, "DateRangePicker"), U(e, n, t, r.force, r.delay);
405
+ return;
406
+ // ---------------------------------------------------------------------
407
+ // MultiCheckbox
408
+ case e.classList.contains("Field-MultiCheckbox"):
409
+ f(n, "MultiCheckbox"), P(e, n, t, r.force);
410
+ return;
411
+ // ---------------------------------------------------------------------
412
+ // MultiRadio
413
+ case e.classList.contains("Field-MultiRadio"):
414
+ Q(n, "MultiRadio"), q(e, n, t, r.force);
415
+ return;
416
+ default:
417
+ p(`\`cy.fill()\` can't handle the input element in field with \`<legend>\` "${t}".`);
418
+ }
419
+ }
420
+ p(`Could not find a field labelled by a \`<label />\` or \`<legend />\` "${t}".`);
421
+ } catch (c) {
422
+ if (r.retries > 0) {
423
+ cy.wait(250).then(() => {
424
+ cy.log(
425
+ `[monitor-ui > Cypress] Retrying (${w - r.retries + 1} / ${w})...`
426
+ ), m(t, n, {
427
+ ...r,
428
+ retries: r.retries - 1
429
+ });
430
+ });
431
+ return;
432
+ }
433
+ const o = c instanceof Error ? c : new Error(String(c));
434
+ Cypress.log({
435
+ consoleProps: () => ({
436
+ err: c,
437
+ label: t,
438
+ value: n
439
+ }),
440
+ displayName: "ERROR",
441
+ message: String(o.message),
442
+ name: "fill"
443
+ }).error(o), p(
444
+ [
445
+ `Could not find or fill field with label or legend "${t}" at index "${r.index}" after ${w} attempts.`,
446
+ `This error was thrown: “${o.message}”`,
447
+ 'Please check the Cypress "- ERROR" log above for more details.'
448
+ ].join(`
449
+ `)
450
+ );
451
+ }
452
+ }
453
+ function E(t, n = {}) {
454
+ if (Cypress.log({
455
+ consoleProps: () => ({
456
+ "Applied to": t,
457
+ Elements: 1
458
+ }),
459
+ name: "forceCheck"
460
+ }), !t)
461
+ throw new Error("Could not find subject.");
462
+ return cy.wrap(t).check({ ...n, force: !0 });
463
+ }
464
+ function v(t, n = {}) {
465
+ if (Cypress.log({
466
+ consoleProps: () => ({
467
+ "Applied to": t,
468
+ Elements: 1
469
+ }),
470
+ name: "forceClear"
471
+ }), !t)
472
+ throw new Error("Could not find subject.");
473
+ return cy.wrap(t).clear({ ...n, force: !0 });
474
+ }
475
+ function tt(t, n = {}) {
476
+ if (Cypress.log({
477
+ consoleProps: () => ({
478
+ "Applied to": t,
479
+ Elements: 1
480
+ }),
481
+ name: "forceClick"
482
+ }), !t)
483
+ throw new Error("Could not find subject.");
484
+ return cy.wrap(t).click({ ...n, force: !0 });
485
+ }
486
+ function rt(t, n, i = {}) {
487
+ if (Cypress.log({
488
+ consoleProps: () => ({
489
+ "Applied to": t,
490
+ Elements: 1
491
+ }),
492
+ name: "forceType"
493
+ }), !t)
494
+ throw new Error("Could not find subject.");
495
+ return cy.wrap(t).type(n, { ...i, force: !0 });
496
+ }
497
+ function nt(t, n = {}) {
498
+ if (Cypress.log({
499
+ consoleProps: () => ({
500
+ "Applied to": t,
501
+ Elements: 1
502
+ }),
503
+ name: "forceUncheck"
504
+ }), !t)
505
+ throw new Error("Could not find subject.");
506
+ return cy.wrap(t).uncheck({ ...n, force: !0 });
507
+ }
508
+ function et(t) {
509
+ return cy.get(`[data-cy="${t}"]`);
510
+ }
511
+ function it(t, n) {
512
+ const i = t ? t[0] : void 0;
513
+ if (t && !t[0])
514
+ throw new Error("`prevSubjectElements[0]` is undefined.");
515
+ return (i ? cy.wrap(i) : cy.get("body")).first().find(`.Table-SimpleTable tr[data-id="${n}"]`);
516
+ }
517
+ function ct(t, n) {
518
+ const i = t ? t[0] : void 0;
519
+ if (t && !t[0])
520
+ throw new Error("`prevSubjectElements[0]` is undefined.");
521
+ return (i ? cy.wrap(i) : cy.get("body")).first().contains(".Table-SimpleTable tr", n);
522
+ }
523
+ function ot(t, n, i, r = 0, c = () => {
524
+ }) {
525
+ if (r === i)
526
+ throw new Error(`${i} requests exceeded`);
527
+ return cy.wait(t).then((o) => Cypress._.isMatch(o.request, n) ? c(o.response) : (cy.log("Intercepted request", JSON.stringify(o.request)), cy.waitForLastRequest(t, n, i, r + 1, c)));
528
+ }
529
+ const at = () => {
530
+ typeof Cypress > "u" || (Cypress.Commands.add("clickButton", { prevSubject: "optional" }, $), Cypress.Commands.add("clickLink", R), Cypress.Commands.add("waitForLastRequest", ot), Cypress.Commands.add("clickOutside", D), Cypress.Commands.add("fill", m), Cypress.Commands.add("forceCheck", { prevSubject: !0 }, E), Cypress.Commands.add("forceClear", { prevSubject: !0 }, v), Cypress.Commands.add("forceClick", { prevSubject: !0 }, tt), Cypress.Commands.add("forceType", { prevSubject: !0 }, rt), Cypress.Commands.add("forceUncheck", { prevSubject: !0 }, nt), Cypress.Commands.add("getDataCy", et), Cypress.Commands.add("getTableRowById", { prevSubject: "optional" }, it), Cypress.Commands.add("getTableRowByText", { prevSubject: "optional" }, ct));
531
+ };
532
+ export {
533
+ at as registerMonitorUiCustomCommands
534
+ };
535
+ //# sourceMappingURL=index.js.map