@mtes-mct/monitor-ui 24.33.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/cypress/index.js CHANGED
@@ -1,1145 +1,535 @@
1
- // I have no idea why I have to add this dirty hack of setting an external variable
2
- // instead of using a cleaner FP `.filter()`
3
- // but real experience made me think it greatly improves results stability.
4
- function findElementByText(selector, text, { fallbackSelector, index = 0, inElement } = {}) {
5
- const trimmedText = text.trim();
6
- if (inElement) {
7
- let foundElement;
8
- let foundElementIndex = 0;
9
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
10
- Cypress.$(inElement).find(selector)// eslint-disable-next-line func-names
11
- .each(function() {
12
- if (!foundElement && Cypress.$(this).text().trim() === trimmedText) {
13
- if (foundElementIndex < index) {
14
- foundElementIndex += 1;
15
- return;
16
- }
17
- foundElement = this;
18
- }
19
- });
20
- if (!foundElement && fallbackSelector) {
21
- cy.log(`⚠️ Using fallback selector: "${fallbackSelector}"`);
22
- const foundElementByFallbackSelector = Cypress.$(inElement).find(fallbackSelector);
23
- return foundElementByFallbackSelector;
24
- }
25
- return foundElement;
26
- }
27
- let foundElement;
28
- let foundElementIndex = 0;
29
- // eslint-disable-next-line func-names, @typescript-eslint/no-unused-expressions
30
- Cypress.$(selector).each(function() {
31
- if (!foundElement && Cypress.$(this).text().trim() === trimmedText) {
32
- if (foundElementIndex < index) {
33
- foundElementIndex += 1;
34
- return;
35
- }
36
- foundElement = this;
37
- }
38
- });
39
- if (!foundElement && fallbackSelector) {
40
- // eslint-disable-next-line no-console
41
- console.warn(`Using fallback selector: "${fallbackSelector}".`);
42
- const foundElementByFallbackSelector = Cypress.$(fallbackSelector);
43
- return foundElementByFallbackSelector;
44
- }
45
- return foundElement;
46
- }
47
-
48
- const RETRIES = 5;
49
- function findButton(label, preSelector, { index, prevSubjectElement }) {
50
- const buttonElement = findElementByText(`${preSelector}button`, label, {
51
- index,
52
- inElement: prevSubjectElement
53
- });
54
- if (buttonElement) {
55
- return buttonElement;
56
- }
57
- const buttonElementByAriaLabel = prevSubjectElement ? prevSubjectElement.querySelectorAll(`${preSelector}button[aria-label="${label}"]`)[index] : Cypress.$(`${preSelector}button[aria-label="${label}"]`).get(index);
58
- if (buttonElementByAriaLabel) {
59
- return buttonElementByAriaLabel;
60
- }
61
- const buttonElementByTitle = prevSubjectElement ? prevSubjectElement.querySelectorAll(`${preSelector}button[title="${label}"]`)[index] : Cypress.$(`${preSelector}button[title="${label}"]`).get(index);
62
- if (buttonElementByTitle) {
63
- return buttonElementByTitle;
64
- }
65
- const buttonRoleElement = findElementByText(`${preSelector}[role="button"]`, label, {
66
- index,
67
- inElement: prevSubjectElement
68
- });
69
- if (buttonRoleElement) {
70
- return buttonRoleElement;
71
- }
72
- const buttonRoleElementByAriaLabel = prevSubjectElement ? prevSubjectElement.querySelectorAll(`${preSelector}[role="button"][aria-label="${label}"]`)[index] : Cypress.$(`${preSelector}[role="button"][aria-label="${label}"]`).get(index);
73
- if (buttonRoleElementByAriaLabel) {
74
- return buttonRoleElementByAriaLabel;
75
- }
76
- const buttonRoleElementByTitle = prevSubjectElement ? prevSubjectElement.querySelectorAll(`${preSelector}[role="button"][title="${label}"]`)[index] : Cypress.$(`${preSelector}[role="button"][title="${label}"]`).get(index);
77
- if (buttonRoleElementByTitle) {
78
- return buttonRoleElementByTitle;
79
- }
80
- const menuItemRoleElement = findElementByText(`${preSelector}[role="menuitem"]`, label, {
81
- index,
82
- inElement: prevSubjectElement
83
- });
84
- if (menuItemRoleElement) {
85
- return menuItemRoleElement;
86
- }
87
- return undefined;
88
- }
89
- function clickButton(prevSubjectElements, label, { index = 0, withinSelector, withoutScroll = false } = {}, leftRetries = RETRIES) {
90
- const prevSubjectElement = prevSubjectElements ? prevSubjectElements[0] : undefined;
91
- if (prevSubjectElements && !prevSubjectElements[0]) {
92
- throw new Error('`prevSubjectElements[0]` is undefined.');
93
- }
94
- const preSelector = withinSelector ? `${withinSelector} ` : '';
95
- const maybeButton = findButton(label, preSelector, {
96
- index,
97
- prevSubjectElement
98
- });
99
- if (maybeButton) {
100
- return (withoutScroll ? cy.wrap(maybeButton).forceClick() : cy.wrap(maybeButton).scrollIntoView().forceClick()).wait(250);
101
- }
102
- if (leftRetries > 0) {
103
- return cy.wait(250).then(()=>{
104
- cy.log(`Retrying (${RETRIES - leftRetries + 1} / ${RETRIES})...`);
105
- return clickButton(prevSubjectElements, label, {
106
- index,
107
- withinSelector,
108
- withoutScroll
109
- }, leftRetries - 1);
110
- });
111
- }
112
- throw new Error(`Unable to find button with label "${label}".`);
113
- }
114
-
115
- function clickLink(linkText) {
116
- return cy.get('a').contains(linkText).click();
117
- }
118
-
119
- /**
120
- * @description
121
- * Useful to close modals.
122
- */ function clickOutside(xPosition = 0, yPosition = 0) {
123
- cy.log(`Click outside at position: ${xPosition}, ${yPosition}`);
124
- cy.get('body').click(xPosition, yPosition, {
125
- force: true
126
- });
127
- }
128
-
129
- const MAX_PARENT_INDEX = 100;
130
- function findElementParentBySelector(element, parentSelector, index = 0) {
131
- let currentParentElement = element;
132
- let lastFoundParentIndex = 0;
133
- let parentIndex = -1;
134
- while(parentIndex < MAX_PARENT_INDEX){
135
- parentIndex += 1;
136
- currentParentElement = currentParentElement.parentElement;
137
- if (!currentParentElement) {
138
- return undefined;
139
- }
140
- if (currentParentElement.matches(parentSelector)) {
141
- if (lastFoundParentIndex === index) {
142
- return currentParentElement;
143
- }
144
- lastFoundParentIndex += 1;
145
- }
146
- }
147
- return undefined;
148
- }
149
-
150
- function checkCheckbox(fieldElement, value, _label, force) {
151
- Cypress.log({
152
- consoleProps: ()=>({
153
- 'Applied to': fieldElement,
154
- Elements: 1
155
- }),
156
- name: 'checkCheckbox'
157
- });
158
- cy.wrap(fieldElement).scrollIntoView({
159
- offset: {
160
- left: 0,
161
- top: -100
162
- }
163
- });
164
- if (value) {
165
- cy.wrap(fieldElement).find('input[type="checkbox"]').check({
166
- force
167
- }).wait(250);
168
- } else {
169
- cy.wrap(fieldElement).find('input[type="checkbox"]').uncheck({
170
- force
171
- }).wait(250);
172
- }
173
- }
174
-
175
- function checkMultiCheckboxOptions(fieldsetElement, values, _label, force) {
176
- Cypress.log({
177
- consoleProps: ()=>({
178
- 'Applied to': fieldsetElement,
179
- Elements: 1
180
- }),
181
- name: 'checkMultiCheckboxOptions'
182
- });
183
- cy.wrap(fieldsetElement).scrollIntoView({
184
- offset: {
185
- left: 0,
186
- top: -100
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;
187
14
  }
188
- });
189
- cy.wrap(fieldsetElement).find('input[type="checkbox"]').uncheck({
190
- force
191
- }).wait(250);
192
- // If `values` is undefined, we don't need to check anything
193
- if (!values) {
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;
194
24
  return;
195
- }
196
- values.forEach((value)=>{
197
- cy.wrap(fieldsetElement).contains('.rs-checkbox-label', value).closest('.rs-checkbox').find('input[type="checkbox"]').check({
198
- force
199
- });
200
- });
201
- cy.wait(250);
202
- }
203
-
204
- function checkMultiRadioOption(fieldsetElement, value, _label, force) {
205
- Cypress.log({
206
- consoleProps: ()=>({
207
- 'Applied to': fieldsetElement,
208
- Elements: 1
209
- }),
210
- name: 'checkMultiRadioOption'
211
- });
212
- cy.wrap(fieldsetElement).scrollIntoView({
213
- offset: {
214
- left: 0,
215
- top: -100
216
- }
217
- }).find('label').contains(value).click({
218
- force
219
- }).wait(250);
220
- }
221
-
222
- const DEFAULT_OPTIONS = {
223
- delay: 10,
224
- force: true,
225
- index: 0,
226
- retries: 5
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
227
124
  };
228
-
229
- function throwError(message) {
230
- throw new Error(`[monitor-ui > Cypress] ${message}`);
231
- }
232
-
233
- function fillDatePicker(fieldsetElement, dateOrDateWithTimeTuple, _label, force, delay) {
234
- Cypress.log({
235
- consoleProps: ()=>({
236
- 'Applied to': fieldsetElement,
237
- Elements: 1
238
- }),
239
- name: 'fillDatePicker'
240
- });
241
- const inputElements = fieldsetElement.querySelectorAll('input');
242
- if (inputElements.length !== 4 && inputElements.length !== 6) {
243
- throwError(`Expected to find 4 or 6 inputs within in DatePicker but found ${inputElements.length}.`);
244
- }
245
- const hasTimeInputs = inputElements.length === 6;
246
- // Empty the inputs if `dateOrDateWithTimeTuple` is undefined
247
- if (!dateOrDateWithTimeTuple) {
248
- // -------------------------------------------------------------------------
249
- // Date without time
250
- cy.wrap(fieldsetElement).find('[aria-label="Jour"]').clear({
251
- force
252
- });
253
- cy.wrap(fieldsetElement).find('[aria-label="Mois"]').clear({
254
- force
255
- });
256
- cy.wrap(fieldsetElement).find('[aria-label="Année"]').clear({
257
- force
258
- });
259
- if (hasTimeInputs) {
260
- cy.wrap(fieldsetElement).find('[aria-label="Heure"]').clear({
261
- force
262
- });
263
- cy.wrap(fieldsetElement).find('[aria-label="Minute"]').clear({
264
- force
265
- });
266
- }
267
- } else {
268
- const [year, month, day] = dateOrDateWithTimeTuple;
269
- cy.wrap(fieldsetElement).find('[aria-label="Jour"]').type(String(day).padStart(2, '0'), {
270
- delay,
271
- force
272
- });
273
- cy.wrap(fieldsetElement).find('[aria-label="Mois"]').type(String(month).padStart(2, '0'), {
274
- delay,
275
- force
276
- });
277
- cy.wrap(fieldsetElement).find('[aria-label="Année"]').type(String(year), {
278
- delay,
279
- force
280
- });
281
- if (hasTimeInputs) {
282
- const [hour, minute] = dateOrDateWithTimeTuple.slice(3);
283
- cy.wrap(fieldsetElement).find('[aria-label="Heure"]').type(String(hour).padStart(2, '0'), {
284
- delay,
285
- force
286
- });
287
- cy.wrap(fieldsetElement).find('[aria-label="Minute"]').type(String(minute).padStart(2, '0'), {
288
- delay,
289
- force
290
- });
291
- }
292
- }
293
- cy.wait(250);
294
- // Close the calendar & ranged time picker popup by pressing the escape key
295
- cy.get('body').type('{esc}', {
296
- delay,
297
- force
298
- });
299
- // TODO Create a util to handle the `fieldsetElement` re-creation cases.
300
- // We to use a `wait` as a temporary fix to handle `fieldsetElement` re-creation cases.
301
- cy.wait(250);
302
- // cy.wrap(fieldsetElement).find('.Field-DatePicker__CalendarPicker').should('not.be.visible')
303
- // cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangedTimePicker').should('not.exist')
304
- }
305
-
306
- function fillDateRangePicker(fieldsetElement, dateOrDateWithTimeTupleRange, _label, force, delay) {
307
- Cypress.log({
308
- consoleProps: ()=>({
309
- 'Applied to': fieldsetElement,
310
- Elements: 1
311
- }),
312
- name: 'fillDateRangePicker'
313
- });
314
- const inputElements = fieldsetElement.querySelectorAll('input');
315
- if (inputElements.length !== 7 && inputElements.length !== 11) {
316
- throwError(`Expected to find 7 or 11 inputs within in DatePicker but found ${inputElements.length}.`);
317
- }
318
- const hasTimeInput = inputElements.length !== 7;
319
- // Empty the inputs if `dateOrDateWithTimeTupleRange` is undefined
320
- if (!dateOrDateWithTimeTupleRange) {
321
- cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').clear({
322
- force
323
- });
324
- cy.wrap(fieldsetElement).find('[aria-label="Mois de début"]').clear({
325
- force
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
326
429
  });
327
- cy.wrap(fieldsetElement).find('[aria-label="Année de début"]').clear({
328
- force
329
- });
330
- if (hasTimeInput) {
331
- cy.wrap(fieldsetElement).find('[aria-label="Heure de début"]').clear({
332
- force
333
- });
334
- cy.wrap(fieldsetElement).find('[aria-label="Minute de début"]').clear({
335
- force
336
- });
337
- }
338
- cy.wrap(fieldsetElement).find('[aria-label="Jour de fin"]').clear({
339
- force
340
- });
341
- cy.wrap(fieldsetElement).find('[aria-label="Mois de fin"]').clear({
342
- force
343
- });
344
- cy.wrap(fieldsetElement).find('[aria-label="Année de fin"]').clear({
345
- force
346
- });
347
- if (hasTimeInput) {
348
- cy.wrap(fieldsetElement).find('[aria-label="Heure de fin"]').clear({
349
- force
350
- });
351
- cy.wrap(fieldsetElement).find('[aria-label="Minute de fin"]').clear({
352
- force
353
- });
354
- }
355
- } else {
356
- const [startDateOrDateWithTimeTuple, endDateOrDateWithTimeTuple] = dateOrDateWithTimeTupleRange;
357
- const [startYear, startMonth, startDay, startHour, startMinute] = startDateOrDateWithTimeTuple;
358
- const [endYear, endMonth, endDay, endHour, endMinute] = endDateOrDateWithTimeTuple;
359
- cy.wrap(fieldsetElement).find('[aria-label="Jour de début"]').type(String(startDay).padStart(2, '0'), {
360
- delay,
361
- force
362
- });
363
- cy.wrap(fieldsetElement).find('[aria-label="Mois de début"]').type(String(startMonth).padStart(2, '0'), {
364
- delay,
365
- force
366
- });
367
- cy.wrap(fieldsetElement).find('[aria-label="Année de début"]').type(String(startYear), {
368
- force
369
- });
370
- if (hasTimeInput) {
371
- cy.wrap(fieldsetElement).find('[aria-label="Heure de début"]').type(String(startHour).padStart(2, '0'), {
372
- delay,
373
- force
374
- });
375
- cy.wrap(fieldsetElement).find('[aria-label="Minute de début"]').type(String(startMinute).padStart(2, '0'), {
376
- force
377
- });
378
- }
379
- cy.wrap(fieldsetElement).find('[aria-label="Jour de fin"]').type(String(endDay).padStart(2, '0'), {
380
- delay,
381
- force
382
- });
383
- cy.wrap(fieldsetElement).find('[aria-label="Mois de fin"]').type(String(endMonth).padStart(2, '0'), {
384
- delay,
385
- force
386
- });
387
- cy.wrap(fieldsetElement).find('[aria-label="Année de fin"]').type(String(endYear), {
388
- force
389
- });
390
- if (hasTimeInput) {
391
- cy.wrap(fieldsetElement).find('[aria-label="Heure de fin"]').type(String(endHour).padStart(2, '0'), {
392
- delay,
393
- force
394
- });
395
- cy.wrap(fieldsetElement).find('[aria-label="Minute de fin"]').type(String(endMinute).padStart(2, '0'), {
396
- delay,
397
- force
398
- });
399
- }
400
- }
401
- cy.wait(250);
402
- // Close the range calendar & ranged time picker popup by pressing the escape key
403
- cy.get('body').type('{esc}', {
404
- delay,
405
- force
406
- });
407
- // TODO Create a util to handle the `fieldsetElement` re-creation cases.
408
- // We to use a `wait` as a temporary fix to handle `fieldsetElement` re-creation cases.
409
- cy.wait(250);
410
- // cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangeCalendarPicker').should('not.be.visible')
411
- // cy.wrap(fieldsetElement).find('.Field-DateRangePicker__RangedTimePicker').should('not.exist')
412
- }
413
-
414
- function fillNumberInput(fieldElement, value, _label, force, delay) {
415
- Cypress.log({
416
- consoleProps: ()=>({
417
- 'Applied to': fieldElement,
418
- Elements: 1
419
- }),
420
- name: 'fillNumberInput'
421
- });
422
- cy.wrap(fieldElement).scrollIntoView({
423
- offset: {
424
- left: 0,
425
- top: -100
426
- }
427
- });
428
- cy.wrap(fieldElement).find('input[type="number"]').clear({
429
- force
430
- }).wait(250);
431
- // If `value` is undefined, we don't need to input anything
432
- if (!value) {
433
- return;
434
- }
435
- cy.wrap(fieldElement).find('input[type="number"]').type(String(value), {
436
- delay,
437
- force
438
- }).wait(250);
439
- }
440
-
441
- function fillTextarea(fieldElement, value, _label, force, delay) {
442
- Cypress.log({
443
- consoleProps: ()=>({
444
- 'Applied to': fieldElement,
445
- Elements: 1
446
- }),
447
- name: 'fillTextarea'
448
- });
449
- cy.wrap(fieldElement).scrollIntoView({
450
- offset: {
451
- left: 0,
452
- top: -100
453
- }
454
- });
455
- cy.wrap(fieldElement).find('textarea').clear({
456
- force
457
- }).wait(250);
458
- // If `value` is undefined, we don't need to input anything
459
- if (!value) {
460
- return;
430
+ });
431
+ return;
461
432
  }
462
- cy.wrap(fieldElement).find('textarea').type(value, {
463
- delay,
464
- force
465
- }).wait(250);
466
- }
467
-
468
- function fillTextInput(fieldElement, value, _label, force, delay) {
433
+ const o = c instanceof Error ? c : new Error(String(c));
469
434
  Cypress.log({
470
- consoleProps: ()=>({
471
- 'Applied to': fieldElement,
472
- Elements: 1
473
- }),
474
- name: 'fillTextInput'
475
- });
476
- cy.wrap(fieldElement).scrollIntoView({
477
- offset: {
478
- left: 0,
479
- top: -100
480
- }
481
- });
482
- cy.wrap(fieldElement).find('input').clear({
483
- force
484
- }).wait(250);
485
- // If `value` is undefined, we don't need to input anything
486
- if (!value) {
487
- return;
488
- }
489
- cy.wrap(fieldElement).find('input').type(value, {
490
- delay,
491
- force
492
- }).wait(250);
493
- }
494
-
495
- function pickCheckPickerOptions(fieldElement, values, label, force, delay, role = 'option') {
496
- Cypress.log({
497
- consoleProps: ()=>({
498
- 'Applied to': fieldElement,
499
- Elements: 1
500
- }),
501
- name: 'pickCheckPickerOptions'
502
- });
503
- cy.wrap(fieldElement).scrollIntoView({
504
- offset: {
505
- left: 0,
506
- top: -100
507
- }
508
- });
509
- // Clear the field if there is a clear button
510
- const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
511
- if (maybeClearButton) {
512
- cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').click({
513
- force
514
- }).wait(250);
515
- }
516
- // If `values` is undefined, we don't need to select anything
517
- if (!values) {
518
- return;
519
- }
520
- cy.wrap(fieldElement).find('.rs-picker-toggle').click({
521
- force
522
- });
523
- // Wait for the picker to open
524
- cy.wrap(fieldElement).find('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
525
- if (!rsuitePickerPopupElement) {
526
- throwError(`Could not find '.rs-picker-popup' in in field with label "${label}". Did the picker open?`);
527
- }
528
- // Search for the value if there is a search input
529
- const maybeSearchInput = rsuitePickerPopupElement.querySelector('input[role="searchbox"]');
530
- values.forEach((value)=>{
531
- if (maybeSearchInput) {
532
- cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').clear().type(value, {
533
- delay,
534
- force
535
- }).wait(250);
536
- }
537
- cy.wrap(rsuitePickerPopupElement).find(`[role="${role}"]`).contains(value).first().scrollIntoView().click({
538
- force
539
- });
540
- });
541
- // Close the picker popup by pressing the escape key
542
- cy.get('body').type('{esc}', {
543
- delay,
544
- force
545
- });
546
- // TODO Create a util to handle the `fieldElement` re-creation cases.
547
- // We to use a `wait` as a temporary fix to handle `fieldElement` re-creation cases.
548
- cy.wait(250);
549
- // cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist')
550
- });
551
- }
552
-
553
- function pickMultiCascaderOptions(fieldElement, values, label, force, delay) {
554
- Cypress.log({
555
- consoleProps: ()=>({
556
- 'Applied to': fieldElement,
557
- Elements: 1
558
- }),
559
- name: 'pickMultiCascaderOptions'
560
- });
561
- cy.wrap(fieldElement).scrollIntoView({
562
- offset: {
563
- left: 0,
564
- top: -100
565
- }
566
- });
567
- // Clear the field if there is a clear button
568
- const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
569
- if (maybeClearButton) {
570
- cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').click({
571
- force
572
- }).wait(250);
573
- }
574
- // If `values` is undefined, we don't need to select anything
575
- if (!values) {
576
- return;
577
- }
578
- cy.wrap(fieldElement).find('.rs-picker-toggle').click({
579
- force
580
- });
581
- // Wait for the picker to open
582
- cy.wrap(fieldElement).find('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
583
- if (!rsuitePickerPopupElement) {
584
- throwError(`Could not find '.rs-picker-popup' in in field with label "${label}". Did the picker open?`);
585
- }
586
- // Search for the value if there is a search input
587
- const maybeSearchInput = rsuitePickerPopupElement.querySelector('input[role="searchbox"]');
588
- if (!maybeSearchInput) {
589
- throwError(throwError(`\`cy.fill()\` can't handle the MultiCascader with \`<label>\` "${label}" because it's not \`searchable\`.`));
590
- }
591
- values.forEach((value)=>{
592
- cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').clear().type(value, {
593
- delay,
594
- force
595
- }).wait(250);
596
- cy.wrap(rsuitePickerPopupElement).find('[role="treeitem"]').contains(value).first().scrollIntoView().click({
597
- force
598
- });
599
- });
600
- // Close the picker popup by pressing the escape key
601
- cy.get('body').type('{esc}', {
602
- delay,
603
- force
604
- });
605
- // TODO Create a util to handle the `fieldElement` re-creation cases.
606
- // We to use a `wait` as a temporary fix to handle `fieldElement` re-creation cases.
607
- cy.wait(250);
608
- // cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist')
609
- });
610
- }
611
-
612
- function pickMultiSelectOptions(fieldElement, values, label, force, delay) {
613
- Cypress.log({
614
- consoleProps: ()=>({
615
- 'Applied to': fieldElement,
616
- Elements: 1
617
- }),
618
- name: 'pickMultiSelectOptions'
619
- });
620
- cy.wrap(fieldElement).scrollIntoView({
621
- offset: {
622
- left: 0,
623
- top: -100
624
- }
625
- });
626
- // Clear the field if there is a clear button
627
- const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
628
- if (maybeClearButton) {
629
- cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').click({
630
- force
631
- }).wait(250);
632
- }
633
- // If `values` is undefined, we don't need to select anything
634
- if (!values) {
635
- return;
636
- }
637
- cy.wrap(fieldElement).find('.rs-picker-toggle').click({
638
- force
639
- });
640
- // Wait for the picker to open
641
- cy.wrap(fieldElement).get('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
642
- if (!rsuitePickerPopupElement) {
643
- throwError(`Could not find '.rs-picker-popup' in in field with label "${label}". Did the picker open?`);
644
- }
645
- values.forEach((value)=>{
646
- // Search for the value if there is a search input
647
- const maybeSearchInput = fieldElement.querySelector('.rs-picker-search-input > input');
648
- if (maybeSearchInput) {
649
- cy.wrap(fieldElement).find('.rs-picker-search-input > input').type(value, {
650
- delay,
651
- force
652
- }).wait(250);
653
- }
654
- cy.wrap(rsuitePickerPopupElement).find('[role="option"]').contains(value).first().scrollIntoView().click({
655
- force
656
- });
657
- });
658
- // Close the picker popup by pressing the escape key
659
- cy.get('body').type('{esc}', {
660
- delay,
661
- force
662
- });
663
- // TODO Create a util to handle the `fieldElement` re-creation cases.
664
- // We to use a `wait` as a temporary fix to handle `fieldElement` re-creation cases.
665
- cy.wait(250);
666
- // cy.wrap(fieldElement).find('.rs-picker-popup').should('not.exist')
667
- });
668
- }
669
-
670
- function pickSearchOption(fieldElement, value, _label, force, delay) {
671
- Cypress.log({
672
- consoleProps: ()=>({
673
- 'Applied to': fieldElement,
674
- Elements: 1
675
- }),
676
- name: 'pickSearchOption'
677
- });
678
- cy.wrap(fieldElement).scrollIntoView({
679
- offset: {
680
- left: 0,
681
- top: -100
682
- }
683
- });
684
- // Clear the field if there is a clear button
685
- const maybeClearButton = fieldElement.querySelector('.Field-Search__ClearButton');
686
- if (maybeClearButton) {
687
- cy.wrap(fieldElement).find('.Field-Search__ClearButton').click({
688
- force
689
- }).wait(250);
690
- }
691
- // If the value is undefined, we don't need to select anything
692
- if (!value) {
693
- return;
694
- }
695
- // Search for the value
696
- cy.wrap(fieldElement).find('input[role="combobox"]').type(value, {
697
- delay,
698
- force
699
- });
700
- // Wait for the picker to open
701
- cy.wrap(fieldElement).get('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
702
- // Select the first picker option
703
- cy.wrap(rsuitePickerPopupElement).find('[role="option"]').first().scrollIntoView().click({
704
- force
705
- }).wait(250);
706
- });
707
- }
708
-
709
- function pickSelectOption(fieldElement, value, label, force, delay) {
710
- Cypress.log({
711
- consoleProps: ()=>({
712
- 'Applied to': fieldElement,
713
- Elements: 1
714
- }),
715
- name: 'pickSelectOption'
716
- });
717
- cy.wrap(fieldElement).scrollIntoView({
718
- offset: {
719
- left: 0,
720
- top: -100
721
- }
722
- });
723
- // Clear the field if there is a clear button
724
- const maybeClearButton = fieldElement.querySelector('.rs-stack > .rs-stack-item > .rs-picker-clean');
725
- if (maybeClearButton) {
726
- cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-clean').click({
727
- force
728
- }).wait(250);
729
- }
730
- // If the value is undefined, we don't need to select anything
731
- if (!value) {
732
- return;
733
- }
734
- // Open the picker
735
- cy.wrap(fieldElement).find('.rs-stack > .rs-stack-item > .rs-picker-caret-icon').click({
736
- force
737
- }).wait(250);
738
- // Wait for the picker to open
739
- cy.wrap(fieldElement).get('.rs-picker-popup').then(([rsuitePickerPopupElement])=>{
740
- if (!rsuitePickerPopupElement) {
741
- throwError(`Could not find '.rs-picker-popup' in in field with label "${label}". Did the picker open?`);
742
- }
743
- // Search for the value if there is a search input
744
- const maybeSearchInput = rsuitePickerPopupElement.querySelector('input[role="searchbox"]');
745
- if (maybeSearchInput) {
746
- cy.wrap(rsuitePickerPopupElement).find('input[role="searchbox"]').type(value, {
747
- delay,
748
- force
749
- }).wait(250);
750
- }
751
- cy.wrap(rsuitePickerPopupElement).find('[role="option"]').contains(value).scrollIntoView().click({
752
- force
753
- }).wait(250);
754
- });
755
- }
756
-
757
- const throwAssertionError = (expectedType, component)=>throwError(`\`value\` should be of type \`${expectedType}\` in \`cy.fill(label, value)\` when used on a <${component} />.`);
758
- function assertBooleanOrUndefined(value, component) {
759
- if (value === undefined || typeof value === 'boolean') {
760
- return;
761
- }
762
- throwAssertionError('boolean | undefined', component);
763
- }
764
- function assertDateTupleOrDateWithTimeTupleOrUndefined(value, component) {
765
- if (value === undefined) {
766
- return;
767
- }
768
- if (Array.isArray(value) && (value.length === 3 || value.length === 5) && value.every((valueItem)=>typeof valueItem === 'number')) {
769
- return;
770
- }
771
- throwAssertionError('DateTuple | DateWithTimeTuple | undefined', component);
772
- }
773
- function assertDateRangeTupleOrDateWithTimeRangeTupleOrUndefined(value, component) {
774
- if (value === undefined) {
775
- return;
776
- }
777
- 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'))) {
778
- return;
779
- }
780
- throwAssertionError('DateRangeTuple | DateWithTimeRangeTuple | undefined', component);
781
- }
782
- function assertNumberOrUndefined(value, component) {
783
- if (value === undefined || typeof value === 'number') {
784
- return;
785
- }
786
- throwAssertionError('number | undefined', component);
787
- }
788
- function assertString(value, component) {
789
- if (typeof value === 'string') {
790
- return;
791
- }
792
- throwAssertionError('string', component);
793
- }
794
- function assertStringOrUndefined(value, component) {
795
- if (value === undefined || typeof value === 'string') {
796
- return;
797
- }
798
- throwAssertionError('string | undefined', component);
799
- }
800
- function assertStringArrayOrUndefined(value, component) {
801
- if (value === undefined) {
802
- return;
803
- }
804
- if (Array.isArray(value) && value.every((valueItem)=>typeof valueItem === 'string')) {
805
- return;
806
- }
807
- throwAssertionError('string[] | undefined', component);
808
- }
809
-
810
- let TOTAL_RETRIES;
811
- function fill(label, value, options = {}) {
812
- const controlledOptions = {
813
- ...DEFAULT_OPTIONS,
814
- ...options
815
- };
816
- if (!TOTAL_RETRIES) {
817
- TOTAL_RETRIES = controlledOptions.retries;
818
- }
819
- Cypress.log({
820
- consoleProps: ()=>({
821
- 'Left Retries': controlledOptions.retries
822
- }),
823
- message: `Filling field with label/legend "${label}" with value "${JSON.stringify(value)}".`,
824
- name: 'fill'
825
- });
826
- try {
827
- // =========================================================================
828
- // If it's a field labelled by a `<label />` element
829
- const labelElement = findElementByText('label', label, {
830
- index: controlledOptions.index
831
- });
832
- if (labelElement) {
833
- const fieldElement = findElementParentBySelector(labelElement, '.Element-Field');
834
- if (!fieldElement) {
835
- throwError(`Could not find '.Element-Field' in field with label "${label}" at index "${controlledOptions.index}".`);
836
- }
837
- switch(true){
838
- // ---------------------------------------------------------------------
839
- // Checkbox
840
- case fieldElement.classList.contains('Field-Checkbox'):
841
- assertBooleanOrUndefined(value, 'Checkbox');
842
- checkCheckbox(fieldElement, value, label, controlledOptions.force);
843
- return;
844
- // ---------------------------------------------------------------------
845
- // CheckPicker
846
- case fieldElement.classList.contains('Field-CheckPicker'):
847
- assertStringArrayOrUndefined(value, 'CheckPicker');
848
- pickCheckPickerOptions(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
849
- return;
850
- // ---------------------------------------------------------------------
851
- // CheckTreePicker
852
- case fieldElement.classList.contains('Field-CheckTreePicker'):
853
- assertStringArrayOrUndefined(value, 'CheckTreePicker');
854
- pickCheckPickerOptions(fieldElement, value, label, controlledOptions.force, controlledOptions.delay, 'treeitem');
855
- return;
856
- // ---------------------------------------------------------------------
857
- // MultiCascader
858
- case fieldElement.classList.contains('Field-MultiCascader'):
859
- assertStringArrayOrUndefined(value, 'MultiCascader');
860
- pickMultiCascaderOptions(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
861
- return;
862
- // ---------------------------------------------------------------------
863
- // MultiSelect
864
- case fieldElement.classList.contains('Field-MultiSelect'):
865
- assertStringArrayOrUndefined(value, 'MultiSelect');
866
- pickMultiSelectOptions(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
867
- return;
868
- // ---------------------------------------------------------------------
869
- // Search
870
- case fieldElement.classList.contains('Field-Search'):
871
- assertStringOrUndefined(value, 'Search');
872
- pickSearchOption(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
873
- return;
874
- // ---------------------------------------------------------------------
875
- // Select
876
- case fieldElement.classList.contains('Field-Select'):
877
- assertStringOrUndefined(value, 'Select');
878
- pickSelectOption(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
879
- return;
880
- // ---------------------------------------------------------------------
881
- // NumberInput
882
- case fieldElement.classList.contains('Field-NumberInput'):
883
- assertNumberOrUndefined(value, 'TextInput');
884
- fillNumberInput(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
885
- return;
886
- // ---------------------------------------------------------------------
887
- // Textarea
888
- case fieldElement.classList.contains('Field-Textarea'):
889
- assertStringOrUndefined(value, 'Textarea');
890
- fillTextarea(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
891
- return;
892
- // ---------------------------------------------------------------------
893
- // TextInput
894
- case fieldElement.classList.contains('Field-TextInput'):
895
- assertStringOrUndefined(value, 'TextInput');
896
- fillTextInput(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
897
- return;
898
- // ---------------------------------------------------------------------
899
- // PhoneInput
900
- case fieldElement.classList.contains('Field-PhoneInput'):
901
- assertStringOrUndefined(value, 'PhoneInput');
902
- fillTextInput(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
903
- return;
904
- // ---------------------------------------------------------------------
905
- // LinkInput
906
- case fieldElement.classList.contains('Field-LinkInput'):
907
- assertStringOrUndefined(value, 'LinkInput');
908
- fillTextInput(fieldElement, value, label, controlledOptions.force, controlledOptions.delay);
909
- return;
910
- default:
911
- throwError(`\`cy.fill()\` can't handle field with \`<label>\` "${label}".`);
912
- }
913
- }
914
- // =========================================================================
915
- // If it's a field labelled by a `<legend />` element
916
- const legendElement = findElementByText('legend', label, {
917
- index: controlledOptions.index
918
- });
919
- if (legendElement) {
920
- const fieldsetElement = findElementParentBySelector(legendElement, '.Element-Fieldset');
921
- if (!fieldsetElement) {
922
- throwError(`Could not find '.Element-Fieldset' in field with \`<legend />\` "${label}" at index "${controlledOptions.index}".`);
923
- }
924
- switch(true){
925
- // ---------------------------------------------------------------------
926
- // DatePicker
927
- case fieldsetElement.classList.contains('Field-DatePicker'):
928
- assertDateTupleOrDateWithTimeTupleOrUndefined(value, 'DatePicker');
929
- fillDatePicker(fieldsetElement, value, label, controlledOptions.force, controlledOptions.delay);
930
- return;
931
- // ---------------------------------------------------------------------
932
- // DateRangePicker
933
- case fieldsetElement.classList.contains('Field-DateRangePicker'):
934
- assertDateRangeTupleOrDateWithTimeRangeTupleOrUndefined(value, 'DateRangePicker');
935
- fillDateRangePicker(fieldsetElement, value, label, controlledOptions.force, controlledOptions.delay);
936
- return;
937
- // ---------------------------------------------------------------------
938
- // MultiCheckbox
939
- case fieldsetElement.classList.contains('Field-MultiCheckbox'):
940
- assertStringArrayOrUndefined(value, 'MultiCheckbox');
941
- checkMultiCheckboxOptions(fieldsetElement, value, label, controlledOptions.force);
942
- return;
943
- // ---------------------------------------------------------------------
944
- // MultiRadio
945
- case fieldsetElement.classList.contains('Field-MultiRadio'):
946
- assertString(value, 'MultiRadio');
947
- checkMultiRadioOption(fieldsetElement, value, label, controlledOptions.force);
948
- return;
949
- default:
950
- throwError(`\`cy.fill()\` can't handle the input element in field with \`<legend>\` "${label}".`);
951
- }
952
- }
953
- throwError(`Could not find a field labelled by a \`<label />\` or \`<legend />\` "${label}".`);
954
- } catch (err) {
955
- if (controlledOptions.retries > 0) {
956
- cy.wait(250).then(()=>{
957
- cy.log(`[monitor-ui > Cypress] Retrying (${TOTAL_RETRIES - controlledOptions.retries + 1} / ${TOTAL_RETRIES})...`);
958
- fill(label, value, {
959
- ...controlledOptions,
960
- retries: controlledOptions.retries - 1
961
- });
962
- });
963
- return;
964
- }
965
- const normalizedError = err instanceof Error ? err : new Error(String(err));
966
- Cypress.log({
967
- consoleProps: ()=>({
968
- err,
969
- label,
970
- value
971
- }),
972
- displayName: 'ERROR',
973
- message: String(normalizedError.message),
974
- name: 'fill'
975
- }).error(normalizedError);
976
- throwError([
977
- `Could not find or fill field with label or legend "${label}" at index "${controlledOptions.index}" after ${TOTAL_RETRIES} attempts.`,
978
- `This error was thrown: “${normalizedError.message}”`,
979
- `Please check the Cypress "- ERROR" log above for more details.`
980
- ].join('\n'));
981
- }
982
- }
983
-
984
- function forceCheck(subject, options = {}) {
985
- Cypress.log({
986
- consoleProps: ()=>({
987
- 'Applied to': subject,
988
- Elements: 1
989
- }),
990
- name: 'forceCheck'
991
- });
992
- if (!subject) {
993
- throw new Error(`Could not find subject.`);
994
- }
995
- const wrappedSubject = cy.wrap(subject);
996
- return wrappedSubject.check({
997
- ...options,
998
- force: true
999
- });
1000
- }
1001
-
1002
- function forceClear(subject, options = {}) {
1003
- Cypress.log({
1004
- consoleProps: ()=>({
1005
- 'Applied to': subject,
1006
- Elements: 1
1007
- }),
1008
- name: 'forceClear'
1009
- });
1010
- if (!subject) {
1011
- throw new Error(`Could not find subject.`);
1012
- }
1013
- const wrappedSubject = cy.wrap(subject);
1014
- return wrappedSubject.clear({
1015
- ...options,
1016
- force: true
1017
- });
1018
- }
1019
-
1020
- function forceClick(subject, options = {}) {
1021
- Cypress.log({
1022
- consoleProps: ()=>({
1023
- 'Applied to': subject,
1024
- Elements: 1
1025
- }),
1026
- name: 'forceClick'
1027
- });
1028
- if (!subject) {
1029
- throw new Error(`Could not find subject.`);
1030
- }
1031
- const wrappedSubject = cy.wrap(subject);
1032
- return wrappedSubject.click({
1033
- ...options,
1034
- force: true
1035
- });
1036
- }
1037
-
1038
- function forceType(subject, text, options = {}) {
1039
- Cypress.log({
1040
- consoleProps: ()=>({
1041
- 'Applied to': subject,
1042
- Elements: 1
1043
- }),
1044
- name: 'forceType'
1045
- });
1046
- if (!subject) {
1047
- throw new Error(`Could not find subject.`);
1048
- }
1049
- const wrappedSubject = cy.wrap(subject);
1050
- return wrappedSubject.type(text, {
1051
- ...options,
1052
- force: true
1053
- });
1054
- }
1055
-
1056
- function forceUncheck(subject, options = {}) {
1057
- Cypress.log({
1058
- consoleProps: ()=>({
1059
- 'Applied to': subject,
1060
- Elements: 1
1061
- }),
1062
- name: 'forceUncheck'
1063
- });
1064
- if (!subject) {
1065
- throw new Error(`Could not find subject.`);
1066
- }
1067
- const wrappedSubject = cy.wrap(subject);
1068
- return wrappedSubject.uncheck({
1069
- ...options,
1070
- force: true
1071
- });
1072
- }
1073
-
1074
- function getDataCy(dataCy) {
1075
- return cy.get(`[data-cy="${dataCy}"]`);
1076
- }
1077
-
1078
- function getTableRowById(prevSubjectElements, id) {
1079
- const prevSubjectElement = prevSubjectElements ? prevSubjectElements[0] : undefined;
1080
- if (prevSubjectElements && !prevSubjectElements[0]) {
1081
- throw new Error('`prevSubjectElements[0]` is undefined.');
1082
- }
1083
- return (prevSubjectElement ? cy.wrap(prevSubjectElement) : cy.get('body')).first().find(`.Table-SimpleTable tr[data-id="${id}"]`);
1084
- }
1085
-
1086
- function getTableRowByText(prevSubjectElements, text) {
1087
- const prevSubjectElement = prevSubjectElements ? prevSubjectElements[0] : undefined;
1088
- if (prevSubjectElements && !prevSubjectElements[0]) {
1089
- throw new Error('`prevSubjectElements[0]` is undefined.');
1090
- }
1091
- return (prevSubjectElement ? cy.wrap(prevSubjectElement) : cy.get('body')).first().contains(`.Table-SimpleTable tr`, text);
1092
- }
1093
-
1094
- function waitForLastRequest(alias, partialRequest, maxRequests, level = 0, callback = ()=>{}) {
1095
- if (level === maxRequests) {
1096
- throw new Error(`${maxRequests} requests exceeded`);
1097
- }
1098
- // @ts-ignore
1099
- return cy.wait(alias).then((interception)=>{
1100
- // @ts-ignore
1101
- const isMatch = Cypress._.isMatch(interception.request, partialRequest);
1102
- if (isMatch) {
1103
- return callback(interception.response);
1104
- }
1105
- // eslint-disable-next-line no-console
1106
- cy.log('Intercepted request', JSON.stringify(interception.request));
1107
- // @ts-ignore
1108
- return cy.waitForLastRequest(alias, partialRequest, maxRequests, level + 1, callback);
1109
- });
1110
- }
1111
-
1112
- const registerMonitorUiCustomCommands = ()=>{
1113
- Cypress.Commands.add('clickButton', {
1114
- prevSubject: 'optional'
1115
- }, clickButton);
1116
- Cypress.Commands.add('clickLink', clickLink);
1117
- Cypress.Commands.add('waitForLastRequest', waitForLastRequest);
1118
- Cypress.Commands.add('clickOutside', clickOutside);
1119
- Cypress.Commands.add('fill', fill);
1120
- Cypress.Commands.add('forceCheck', {
1121
- prevSubject: true
1122
- }, forceCheck);
1123
- Cypress.Commands.add('forceClear', {
1124
- prevSubject: true
1125
- }, forceClear);
1126
- Cypress.Commands.add('forceClick', {
1127
- prevSubject: true
1128
- }, forceClick);
1129
- Cypress.Commands.add('forceType', {
1130
- prevSubject: true
1131
- }, forceType);
1132
- Cypress.Commands.add('forceUncheck', {
1133
- prevSubject: true
1134
- }, forceUncheck);
1135
- Cypress.Commands.add('getDataCy', getDataCy);
1136
- Cypress.Commands.add('getTableRowById', {
1137
- prevSubject: 'optional'
1138
- }, getTableRowById);
1139
- Cypress.Commands.add('getTableRowByText', {
1140
- prevSubject: 'optional'
1141
- }, getTableRowByText);
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
1142
534
  };
1143
- registerMonitorUiCustomCommands();
1144
-
1145
- export { registerMonitorUiCustomCommands };
535
+ //# sourceMappingURL=index.js.map