@mtes-mct/monitor-ui 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/{src/constants.d.ts → constants.d.ts} +8 -0
- package/cypress/commands/clickButton.d.ts +6 -0
- package/cypress/commands/clickOutside.d.ts +5 -0
- package/cypress/commands/fill/checkCheckbox.d.ts +1 -0
- package/cypress/commands/fill/checkMultiCheckboxOptions.d.ts +1 -0
- package/cypress/commands/fill/checkMultiRadioOption.d.ts +1 -0
- package/cypress/commands/fill/fillDateRangePicker.d.ts +1 -0
- package/cypress/commands/fill/fillTextInput.d.ts +1 -0
- package/cypress/commands/fill/fillTextarea.d.ts +1 -0
- package/cypress/commands/fill/index.d.ts +1 -0
- package/cypress/commands/fill/pickMultiSelectOptions.d.ts +3 -0
- package/cypress/commands/fill/pickSelectOption.d.ts +3 -0
- package/cypress/commands/forceClick.d.ts +4 -0
- package/cypress/commands/getDataCy.d.ts +3 -0
- package/cypress/index.d.ts +18 -0
- package/cypress/index.js +939 -0
- package/cypress/index.js.map +1 -0
- package/cypress/utils/findElementBySelector.d.ts +5 -0
- package/cypress/utils/findElementBytext.d.ts +5 -0
- package/cypress/utils/waitFor.d.ts +1 -0
- package/{src/elements → elements}/Tag/index.d.ts +1 -2
- package/{src/fields → fields}/CoordinatesInput/DMDCoordinatesInput.d.ts +1 -1
- package/{src/fields → fields}/CoordinatesInput/DMSCoordinatesInput.d.ts +1 -1
- package/{src/fields → fields}/CoordinatesInput/index.d.ts +1 -1
- package/{src/fields → fields}/DateRangePicker/DateInput.d.ts +2 -0
- package/{src/fields → fields}/DateRangePicker/TimeInput.d.ts +2 -2
- package/{src/fields → fields}/DateRangePicker/utils.d.ts +1 -0
- package/{src/index.d.ts → index.d.ts} +1 -2
- package/index.js +31 -23
- package/index.js.map +1 -1
- package/package.json +4 -16
- package/config/cypress.config.d.ts +0 -2
- package/config/playwright.config.d.ts +0 -3
- package/src/elements/Tag/constants.d.ts +0 -3
- package/src/fields/CoordinatesInput/constants.d.ts +0 -5
- /package/{src/GlobalStyle.d.ts → GlobalStyle.d.ts} +0 -0
- /package/{src/OnlyFontGlobalStyle.d.ts → OnlyFontGlobalStyle.d.ts} +0 -0
- /package/{src/ThemeProvider.d.ts → ThemeProvider.d.ts} +0 -0
- /package/{src/components → components}/Dropdown/Item.d.ts +0 -0
- /package/{src/components → components}/Dropdown/index.d.ts +0 -0
- /package/{src/components → components}/NewWindow/index.d.ts +0 -0
- /package/{src/components → components}/SingleTag.d.ts +0 -0
- /package/{src/elements → elements}/Button.d.ts +0 -0
- /package/{src/elements → elements}/Field.d.ts +0 -0
- /package/{src/elements → elements}/FieldError.d.ts +0 -0
- /package/{src/elements → elements}/Fieldset.d.ts +0 -0
- /package/{src/elements → elements}/IconBox.d.ts +0 -0
- /package/{src/elements → elements}/IconButton.d.ts +0 -0
- /package/{src/elements → elements}/Label.d.ts +0 -0
- /package/{src/elements → elements}/Legend.d.ts +0 -0
- /package/{src/elements → elements}/Tag/Disk.d.ts +0 -0
- /package/{src/elements → elements}/TagGroup.d.ts +0 -0
- /package/{src/fields → fields}/AutoComplete.d.ts +0 -0
- /package/{src/fields → fields}/Checkbox.d.ts +0 -0
- /package/{src/fields → fields}/CoordinatesInput/DDCoordinatesInput.d.ts +0 -0
- /package/{src/fields → fields}/DatePicker/CalendarPicker.d.ts +0 -0
- /package/{src/fields → fields}/DatePicker/index.d.ts +0 -0
- /package/{src/fields → fields}/DateRangePicker/NumberInput.d.ts +0 -0
- /package/{src/fields → fields}/DateRangePicker/RangeCalendarPicker.d.ts +0 -0
- /package/{src/fields → fields}/DateRangePicker/RangedTimePicker.d.ts +0 -0
- /package/{src/fields → fields}/DateRangePicker/constants.d.ts +0 -0
- /package/{src/fields → fields}/DateRangePicker/index.d.ts +0 -0
- /package/{src/fields → fields}/DateRangePicker/types.d.ts +0 -0
- /package/{src/fields → fields}/MultiCheckbox.d.ts +0 -0
- /package/{src/fields → fields}/MultiRadio.d.ts +0 -0
- /package/{src/fields → fields}/MultiSelect.d.ts +0 -0
- /package/{src/fields → fields}/MultiZoneEditor/index.d.ts +0 -0
- /package/{src/fields → fields}/NumberInput.d.ts +0 -0
- /package/{src/fields → fields}/Select.d.ts +0 -0
- /package/{src/fields → fields}/TextInput.d.ts +0 -0
- /package/{src/fields → fields}/Textarea.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikAutoComplete.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikCheckbox.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikCoordinatesInput.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikDatePicker.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikDateRangePicker.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikEffect.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikMultiCheckbox.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikMultiRadio.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikMultiSelect.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikNumberInput.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikSelect.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikTextInput.d.ts +0 -0
- /package/{src/formiks → formiks}/FormikTextarea.d.ts +0 -0
- /package/{src/hooks → hooks}/useClickOutsideEffect.d.ts +0 -0
- /package/{src/hooks → hooks}/useFieldUndefineEffect.d.ts +0 -0
- /package/{src/hooks → hooks}/useForceUpdate.d.ts +0 -0
- /package/{src/hooks → hooks}/useKey.d.ts +0 -0
- /package/{src/hooks → hooks}/usePrevious.d.ts +0 -0
- /package/{src/icons → icons}/ActivityFeed.d.ts +0 -0
- /package/{src/icons → icons}/Alert.d.ts +0 -0
- /package/{src/icons → icons}/Anchor.d.ts +0 -0
- /package/{src/icons → icons}/Archive.d.ts +0 -0
- /package/{src/icons → icons}/Attention.d.ts +0 -0
- /package/{src/icons → icons}/Calendar.d.ts +0 -0
- /package/{src/icons → icons}/Check.d.ts +0 -0
- /package/{src/icons → icons}/Chevron.d.ts +0 -0
- /package/{src/icons → icons}/Clock.d.ts +0 -0
- /package/{src/icons → icons}/Close.d.ts +0 -0
- /package/{src/icons → icons}/Confirm.d.ts +0 -0
- /package/{src/icons → icons}/Control.d.ts +0 -0
- /package/{src/icons → icons}/Delete.d.ts +0 -0
- /package/{src/icons → icons}/Display.d.ts +0 -0
- /package/{src/icons → icons}/DoubleChevron.d.ts +0 -0
- /package/{src/icons → icons}/Download.d.ts +0 -0
- /package/{src/icons → icons}/Drapeau.d.ts +0 -0
- /package/{src/icons → icons}/Duplicate.d.ts +0 -0
- /package/{src/icons → icons}/Edit.d.ts +0 -0
- /package/{src/icons → icons}/EditBis.d.ts +0 -0
- /package/{src/icons → icons}/Favorite.d.ts +0 -0
- /package/{src/icons → icons}/FilledArrow.d.ts +0 -0
- /package/{src/icons → icons}/Filter.d.ts +0 -0
- /package/{src/icons → icons}/FilterBis.d.ts +0 -0
- /package/{src/icons → icons}/Fishery.d.ts +0 -0
- /package/{src/icons → icons}/FishingEngine.d.ts +0 -0
- /package/{src/icons → icons}/FleetSegment.d.ts +0 -0
- /package/{src/icons → icons}/Focus.d.ts +0 -0
- /package/{src/icons → icons}/FocusVessel.d.ts +0 -0
- /package/{src/icons → icons}/FocusZones.d.ts +0 -0
- /package/{src/icons → icons}/Hide.d.ts +0 -0
- /package/{src/icons → icons}/Info.d.ts +0 -0
- /package/{src/icons → icons}/Infringement.d.ts +0 -0
- /package/{src/icons → icons}/Landmark.d.ts +0 -0
- /package/{src/icons → icons}/List.d.ts +0 -0
- /package/{src/icons → icons}/MapLayers.d.ts +0 -0
- /package/{src/icons → icons}/MeasureAngle.d.ts +0 -0
- /package/{src/icons → icons}/MeasureBrokenLine.d.ts +0 -0
- /package/{src/icons → icons}/MeasureCircle.d.ts +0 -0
- /package/{src/icons → icons}/MeasureLine.d.ts +0 -0
- /package/{src/icons → icons}/Minus.d.ts +0 -0
- /package/{src/icons → icons}/More.d.ts +0 -0
- /package/{src/icons → icons}/Note.d.ts +0 -0
- /package/{src/icons → icons}/Observation.d.ts +0 -0
- /package/{src/icons → icons}/Pin.d.ts +0 -0
- /package/{src/icons → icons}/Pinpoint.d.ts +0 -0
- /package/{src/icons → icons}/PinpointHide.d.ts +0 -0
- /package/{src/icons → icons}/Plane.d.ts +0 -0
- /package/{src/icons → icons}/Plus.d.ts +0 -0
- /package/{src/icons → icons}/Reject.d.ts +0 -0
- /package/{src/icons → icons}/Save.d.ts +0 -0
- /package/{src/icons → icons}/Search.d.ts +0 -0
- /package/{src/icons → icons}/SelectCircle.d.ts +0 -0
- /package/{src/icons → icons}/SelectPolygon.d.ts +0 -0
- /package/{src/icons → icons}/SelectRectangle.d.ts +0 -0
- /package/{src/icons → icons}/SelectZone.d.ts +0 -0
- /package/{src/icons → icons}/ShowErsMessages.d.ts +0 -0
- /package/{src/icons → icons}/ShowXml.d.ts +0 -0
- /package/{src/icons → icons}/SortingArrows.d.ts +0 -0
- /package/{src/icons → icons}/Summary.d.ts +0 -0
- /package/{src/icons → icons}/Tag.d.ts +0 -0
- /package/{src/icons → icons}/Target.d.ts +0 -0
- /package/{src/icons → icons}/Unlock.d.ts +0 -0
- /package/{src/icons → icons}/Vessel.d.ts +0 -0
- /package/{src/icons → icons}/ViewOnMap.d.ts +0 -0
- /package/{src/icons → icons}/Vms.d.ts +0 -0
- /package/{src/icons → icons}/index.d.ts +0 -0
- /package/{src/theme.d.ts → theme.d.ts} +0 -0
- /package/{src/types.d.ts → types.d.ts} +0 -0
- /package/{src/utils → utils}/cleanString.d.ts +0 -0
- /package/{src/utils → utils}/coordinates.d.ts +0 -0
- /package/{src/utils → utils}/dayjs.d.ts +0 -0
- /package/{src/utils → utils}/getLocalizedDayjs.d.ts +0 -0
- /package/{src/utils → utils}/getPseudoRandomString.d.ts +0 -0
- /package/{src/utils → utils}/getUtcDayjs.d.ts +0 -0
- /package/{src/utils → utils}/getUtcizedDayjs.d.ts +0 -0
- /package/{src/utils → utils}/isNumeric.d.ts +0 -0
- /package/{src/utils → utils}/noop.d.ts +0 -0
- /package/{src/utils → utils}/normalizeString.d.ts +0 -0
- /package/{src/utils → utils}/sortDates.d.ts +0 -0
- /package/{src/utils → utils}/stopMouseEventPropagation.d.ts +0 -0
package/cypress/index.js
ADDED
|
@@ -0,0 +1,939 @@
|
|
|
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)
|
|
11
|
+
.find(selector)
|
|
12
|
+
// eslint-disable-next-line func-names
|
|
13
|
+
.each(function () {
|
|
14
|
+
if (!foundElement && Cypress.$(this).text().trim() === trimmedText) {
|
|
15
|
+
if (foundElementIndex < index) {
|
|
16
|
+
foundElementIndex += 1;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
foundElement = this;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if (!foundElement && fallbackSelector) {
|
|
23
|
+
cy.log(`⚠️ Using fallback selector: "${fallbackSelector}"`);
|
|
24
|
+
const foundElementByFallbackSelector = Cypress.$(inElement).find(fallbackSelector);
|
|
25
|
+
return foundElementByFallbackSelector;
|
|
26
|
+
}
|
|
27
|
+
return foundElement;
|
|
28
|
+
}
|
|
29
|
+
let foundElement;
|
|
30
|
+
let foundElementIndex = 0;
|
|
31
|
+
// eslint-disable-next-line func-names, @typescript-eslint/no-unused-expressions
|
|
32
|
+
Cypress.$(selector).each(function () {
|
|
33
|
+
if (!foundElement && Cypress.$(this).text().trim() === trimmedText) {
|
|
34
|
+
if (foundElementIndex < index) {
|
|
35
|
+
foundElementIndex += 1;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
foundElement = this;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (!foundElement && fallbackSelector) {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.warn(`Using fallback selector: "${fallbackSelector}".`);
|
|
44
|
+
const foundElementByFallbackSelector = Cypress.$(fallbackSelector);
|
|
45
|
+
return foundElementByFallbackSelector;
|
|
46
|
+
}
|
|
47
|
+
return foundElement;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const RETRIES$1 = 5;
|
|
51
|
+
function clickButton(label, { index = 0, withinSelector } = {}, leftRetries = RETRIES$1) {
|
|
52
|
+
const preSelector = withinSelector ? `${withinSelector} ` : '';
|
|
53
|
+
const iconButtonElement = Cypress.$(`${preSelector}button[aria-label="${label}"]`).get(index);
|
|
54
|
+
const textButtonElement = findElementBytext(`${preSelector}button`, label, { index });
|
|
55
|
+
const menuItemElement = findElementBytext(`${preSelector}[role="menuitem"]`, label, { index });
|
|
56
|
+
if (iconButtonElement) {
|
|
57
|
+
return cy.wrap(iconButtonElement).scrollIntoView().click({ force: true }).wait(250);
|
|
58
|
+
}
|
|
59
|
+
if (menuItemElement) {
|
|
60
|
+
return cy
|
|
61
|
+
.wrap(menuItemElement)
|
|
62
|
+
.scrollIntoView()
|
|
63
|
+
.click({ force: true })
|
|
64
|
+
.wait(250);
|
|
65
|
+
}
|
|
66
|
+
if (textButtonElement) {
|
|
67
|
+
return cy.wrap(textButtonElement).scrollIntoView().click({ force: true }).wait(250);
|
|
68
|
+
}
|
|
69
|
+
if (leftRetries > 0) {
|
|
70
|
+
return cy.wait(250).then(() => {
|
|
71
|
+
cy.log(`Retrying (${RETRIES$1 - leftRetries + 1} / ${RETRIES$1})...`);
|
|
72
|
+
return clickButton(label, { index, withinSelector }, leftRetries - 1);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`Unable to find button with label "${label}".`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @description
|
|
80
|
+
* Useful to close modals.
|
|
81
|
+
*/
|
|
82
|
+
function clickOutside(xPosition = 0, yPosition = 0) {
|
|
83
|
+
cy.log(`Click outside at position: ${xPosition}, ${yPosition}`);
|
|
84
|
+
cy.get('body').click(xPosition, yPosition);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// I have no idea why I have to add this dirty hack of setting an external variable
|
|
88
|
+
// instead of using a cleaner FP `.filter()`
|
|
89
|
+
// but real experience made me think it greatly improves results stability.
|
|
90
|
+
function findElementBySelector(selector, { fallbackSelector, index = 0, inElement } = {}) {
|
|
91
|
+
if (inElement) {
|
|
92
|
+
let foundElement;
|
|
93
|
+
let foundElementIndex = 0;
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
95
|
+
Cypress.$(inElement)
|
|
96
|
+
.find(selector)
|
|
97
|
+
// eslint-disable-next-line func-names
|
|
98
|
+
.each(function () {
|
|
99
|
+
if (!foundElement) {
|
|
100
|
+
if (foundElementIndex < index) {
|
|
101
|
+
foundElementIndex += 1;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
foundElement = this;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (!foundElement && fallbackSelector) {
|
|
108
|
+
cy.log(`⚠️ Using fallback selector: "${fallbackSelector}"`);
|
|
109
|
+
const foundElementByFallbackSelector = Cypress.$(inElement).find(fallbackSelector);
|
|
110
|
+
return foundElementByFallbackSelector;
|
|
111
|
+
}
|
|
112
|
+
return foundElement;
|
|
113
|
+
}
|
|
114
|
+
let foundElement;
|
|
115
|
+
let foundElementIndex = 0;
|
|
116
|
+
// eslint-disable-next-line func-names, @typescript-eslint/no-unused-expressions
|
|
117
|
+
Cypress.$(selector).each(function () {
|
|
118
|
+
if (!foundElement) {
|
|
119
|
+
if (foundElementIndex < index) {
|
|
120
|
+
foundElementIndex += 1;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
foundElement = this;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
if (!foundElement && fallbackSelector) {
|
|
127
|
+
// eslint-disable-next-line no-console
|
|
128
|
+
console.warn(`Using fallback selector: "${fallbackSelector}".`);
|
|
129
|
+
const foundElementByFallbackSelector = Cypress.$(fallbackSelector);
|
|
130
|
+
return foundElementByFallbackSelector;
|
|
131
|
+
}
|
|
132
|
+
return foundElement;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function waitFor(inMs) {
|
|
136
|
+
return new Promise(resolve => {
|
|
137
|
+
setTimeout(resolve, inMs);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function _isPlaceholder(a) {
|
|
142
|
+
return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Optimized internal one-arity curry function.
|
|
147
|
+
*
|
|
148
|
+
* @private
|
|
149
|
+
* @category Function
|
|
150
|
+
* @param {Function} fn The function to curry.
|
|
151
|
+
* @return {Function} The curried function.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
function _curry1(fn) {
|
|
155
|
+
return function f1(a) {
|
|
156
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
|
157
|
+
return f1;
|
|
158
|
+
} else {
|
|
159
|
+
return fn.apply(this, arguments);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Optimized internal two-arity curry function.
|
|
166
|
+
*
|
|
167
|
+
* @private
|
|
168
|
+
* @category Function
|
|
169
|
+
* @param {Function} fn The function to curry.
|
|
170
|
+
* @return {Function} The curried function.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
function _curry2(fn) {
|
|
174
|
+
return function f2(a, b) {
|
|
175
|
+
switch (arguments.length) {
|
|
176
|
+
case 0:
|
|
177
|
+
return f2;
|
|
178
|
+
|
|
179
|
+
case 1:
|
|
180
|
+
return _isPlaceholder(a) ? f2 : _curry1(function (_b) {
|
|
181
|
+
return fn(a, _b);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
default:
|
|
185
|
+
return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function (_a) {
|
|
186
|
+
return fn(_a, b);
|
|
187
|
+
}) : _isPlaceholder(b) ? _curry1(function (_b) {
|
|
188
|
+
return fn(a, _b);
|
|
189
|
+
}) : fn(a, b);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Tests whether or not an object is an array.
|
|
196
|
+
*
|
|
197
|
+
* @private
|
|
198
|
+
* @param {*} val The object to test.
|
|
199
|
+
* @return {Boolean} `true` if `val` is an array, `false` otherwise.
|
|
200
|
+
* @example
|
|
201
|
+
*
|
|
202
|
+
* _isArray([]); //=> true
|
|
203
|
+
* _isArray(null); //=> false
|
|
204
|
+
* _isArray({}); //=> false
|
|
205
|
+
*/
|
|
206
|
+
var _isArray = Array.isArray || function _isArray(val) {
|
|
207
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]';
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
function _isString(x) {
|
|
211
|
+
return Object.prototype.toString.call(x) === '[object String]';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function _has(prop, obj) {
|
|
215
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
var toString = Object.prototype.toString;
|
|
219
|
+
|
|
220
|
+
var _isArguments =
|
|
221
|
+
/*#__PURE__*/
|
|
222
|
+
function () {
|
|
223
|
+
return toString.call(arguments) === '[object Arguments]' ? function _isArguments(x) {
|
|
224
|
+
return toString.call(x) === '[object Arguments]';
|
|
225
|
+
} : function _isArguments(x) {
|
|
226
|
+
return _has('callee', x);
|
|
227
|
+
};
|
|
228
|
+
}();
|
|
229
|
+
|
|
230
|
+
var hasEnumBug = !
|
|
231
|
+
/*#__PURE__*/
|
|
232
|
+
{
|
|
233
|
+
toString: null
|
|
234
|
+
}.propertyIsEnumerable('toString');
|
|
235
|
+
var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug
|
|
236
|
+
|
|
237
|
+
var hasArgsEnumBug =
|
|
238
|
+
/*#__PURE__*/
|
|
239
|
+
function () {
|
|
240
|
+
|
|
241
|
+
return arguments.propertyIsEnumerable('length');
|
|
242
|
+
}();
|
|
243
|
+
|
|
244
|
+
var contains = function contains(list, item) {
|
|
245
|
+
var idx = 0;
|
|
246
|
+
|
|
247
|
+
while (idx < list.length) {
|
|
248
|
+
if (list[idx] === item) {
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
idx += 1;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return false;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Returns a list containing the names of all the enumerable own properties of
|
|
259
|
+
* the supplied object.
|
|
260
|
+
* Note that the order of the output array is not guaranteed to be consistent
|
|
261
|
+
* across different JS platforms.
|
|
262
|
+
*
|
|
263
|
+
* @func
|
|
264
|
+
* @memberOf R
|
|
265
|
+
* @since v0.1.0
|
|
266
|
+
* @category Object
|
|
267
|
+
* @sig {k: v} -> [k]
|
|
268
|
+
* @param {Object} obj The object to extract properties from
|
|
269
|
+
* @return {Array} An array of the object's own properties.
|
|
270
|
+
* @see R.keysIn, R.values, R.toPairs
|
|
271
|
+
* @example
|
|
272
|
+
*
|
|
273
|
+
* R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ?
|
|
278
|
+
/*#__PURE__*/
|
|
279
|
+
_curry1(function keys(obj) {
|
|
280
|
+
return Object(obj) !== obj ? [] : Object.keys(obj);
|
|
281
|
+
}) :
|
|
282
|
+
/*#__PURE__*/
|
|
283
|
+
_curry1(function keys(obj) {
|
|
284
|
+
if (Object(obj) !== obj) {
|
|
285
|
+
return [];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
var prop, nIdx;
|
|
289
|
+
var ks = [];
|
|
290
|
+
|
|
291
|
+
var checkArgsLength = hasArgsEnumBug && _isArguments(obj);
|
|
292
|
+
|
|
293
|
+
for (prop in obj) {
|
|
294
|
+
if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
|
|
295
|
+
ks[ks.length] = prop;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (hasEnumBug) {
|
|
300
|
+
nIdx = nonEnumerableProps.length - 1;
|
|
301
|
+
|
|
302
|
+
while (nIdx >= 0) {
|
|
303
|
+
prop = nonEnumerableProps[nIdx];
|
|
304
|
+
|
|
305
|
+
if (_has(prop, obj) && !contains(ks, prop)) {
|
|
306
|
+
ks[ks.length] = prop;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
nIdx -= 1;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return ks;
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Gives a single-word string description of the (native) type of a value,
|
|
318
|
+
* returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
|
|
319
|
+
* attempt to distinguish user Object types any further, reporting them all as
|
|
320
|
+
* 'Object'.
|
|
321
|
+
*
|
|
322
|
+
* @func
|
|
323
|
+
* @memberOf R
|
|
324
|
+
* @since v0.8.0
|
|
325
|
+
* @category Type
|
|
326
|
+
* @sig (* -> {*}) -> String
|
|
327
|
+
* @param {*} val The value to test
|
|
328
|
+
* @return {String}
|
|
329
|
+
* @example
|
|
330
|
+
*
|
|
331
|
+
* R.type({}); //=> "Object"
|
|
332
|
+
* R.type(1); //=> "Number"
|
|
333
|
+
* R.type(false); //=> "Boolean"
|
|
334
|
+
* R.type('s'); //=> "String"
|
|
335
|
+
* R.type(null); //=> "Null"
|
|
336
|
+
* R.type([]); //=> "Array"
|
|
337
|
+
* R.type(/[A-z]/); //=> "RegExp"
|
|
338
|
+
* R.type(() => {}); //=> "Function"
|
|
339
|
+
* R.type(undefined); //=> "Undefined"
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
var type =
|
|
343
|
+
/*#__PURE__*/
|
|
344
|
+
_curry1(function type(val) {
|
|
345
|
+
return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
function _arrayFromIterator(iter) {
|
|
349
|
+
var list = [];
|
|
350
|
+
var next;
|
|
351
|
+
|
|
352
|
+
while (!(next = iter.next()).done) {
|
|
353
|
+
list.push(next.value);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return list;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function _includesWith(pred, x, list) {
|
|
360
|
+
var idx = 0;
|
|
361
|
+
var len = list.length;
|
|
362
|
+
|
|
363
|
+
while (idx < len) {
|
|
364
|
+
if (pred(x, list[idx])) {
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
idx += 1;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function _functionName(f) {
|
|
375
|
+
// String(x => x) evaluates to "x => x", so the pattern may not match.
|
|
376
|
+
var match = String(f).match(/^function (\w*)/);
|
|
377
|
+
return match == null ? '' : match[1];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
381
|
+
function _objectIs(a, b) {
|
|
382
|
+
// SameValue algorithm
|
|
383
|
+
if (a === b) {
|
|
384
|
+
// Steps 1-5, 7-10
|
|
385
|
+
// Steps 6.b-6.e: +0 != -0
|
|
386
|
+
return a !== 0 || 1 / a === 1 / b;
|
|
387
|
+
} else {
|
|
388
|
+
// Step 6.a: NaN == NaN
|
|
389
|
+
return a !== a && b !== b;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* private _uniqContentEquals function.
|
|
397
|
+
* That function is checking equality of 2 iterator contents with 2 assumptions
|
|
398
|
+
* - iterators lengths are the same
|
|
399
|
+
* - iterators values are unique
|
|
400
|
+
*
|
|
401
|
+
* false-positive result will be returned for comparison of, e.g.
|
|
402
|
+
* - [1,2,3] and [1,2,3,4]
|
|
403
|
+
* - [1,1,1] and [1,2,3]
|
|
404
|
+
* */
|
|
405
|
+
|
|
406
|
+
function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
|
|
407
|
+
var a = _arrayFromIterator(aIterator);
|
|
408
|
+
|
|
409
|
+
var b = _arrayFromIterator(bIterator);
|
|
410
|
+
|
|
411
|
+
function eq(_a, _b) {
|
|
412
|
+
return _equals(_a, _b, stackA.slice(), stackB.slice());
|
|
413
|
+
} // if *a* array contains any element that is not included in *b*
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
return !_includesWith(function (b, aItem) {
|
|
417
|
+
return !_includesWith(eq, aItem, b);
|
|
418
|
+
}, b, a);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function _equals(a, b, stackA, stackB) {
|
|
422
|
+
if (_objectIs$1(a, b)) {
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
var typeA = type(a);
|
|
427
|
+
|
|
428
|
+
if (typeA !== type(b)) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
|
|
433
|
+
return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (typeof a.equals === 'function' || typeof b.equals === 'function') {
|
|
437
|
+
return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
switch (typeA) {
|
|
441
|
+
case 'Arguments':
|
|
442
|
+
case 'Array':
|
|
443
|
+
case 'Object':
|
|
444
|
+
if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') {
|
|
445
|
+
return a === b;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
break;
|
|
449
|
+
|
|
450
|
+
case 'Boolean':
|
|
451
|
+
case 'Number':
|
|
452
|
+
case 'String':
|
|
453
|
+
if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
break;
|
|
458
|
+
|
|
459
|
+
case 'Date':
|
|
460
|
+
if (!_objectIs$1(a.valueOf(), b.valueOf())) {
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
break;
|
|
465
|
+
|
|
466
|
+
case 'Error':
|
|
467
|
+
return a.name === b.name && a.message === b.message;
|
|
468
|
+
|
|
469
|
+
case 'RegExp':
|
|
470
|
+
if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
var idx = stackA.length - 1;
|
|
478
|
+
|
|
479
|
+
while (idx >= 0) {
|
|
480
|
+
if (stackA[idx] === a) {
|
|
481
|
+
return stackB[idx] === b;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
idx -= 1;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
switch (typeA) {
|
|
488
|
+
case 'Map':
|
|
489
|
+
if (a.size !== b.size) {
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
|
|
494
|
+
|
|
495
|
+
case 'Set':
|
|
496
|
+
if (a.size !== b.size) {
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
|
|
501
|
+
|
|
502
|
+
case 'Arguments':
|
|
503
|
+
case 'Array':
|
|
504
|
+
case 'Object':
|
|
505
|
+
case 'Boolean':
|
|
506
|
+
case 'Number':
|
|
507
|
+
case 'String':
|
|
508
|
+
case 'Date':
|
|
509
|
+
case 'Error':
|
|
510
|
+
case 'RegExp':
|
|
511
|
+
case 'Int8Array':
|
|
512
|
+
case 'Uint8Array':
|
|
513
|
+
case 'Uint8ClampedArray':
|
|
514
|
+
case 'Int16Array':
|
|
515
|
+
case 'Uint16Array':
|
|
516
|
+
case 'Int32Array':
|
|
517
|
+
case 'Uint32Array':
|
|
518
|
+
case 'Float32Array':
|
|
519
|
+
case 'Float64Array':
|
|
520
|
+
case 'ArrayBuffer':
|
|
521
|
+
break;
|
|
522
|
+
|
|
523
|
+
default:
|
|
524
|
+
// Values of other types are only equal if identical.
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
var keysA = keys(a);
|
|
529
|
+
|
|
530
|
+
if (keysA.length !== keys(b).length) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
var extendedStackA = stackA.concat([a]);
|
|
535
|
+
var extendedStackB = stackB.concat([b]);
|
|
536
|
+
idx = keysA.length - 1;
|
|
537
|
+
|
|
538
|
+
while (idx >= 0) {
|
|
539
|
+
var key = keysA[idx];
|
|
540
|
+
|
|
541
|
+
if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
idx -= 1;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Returns `true` if its arguments are equivalent, `false` otherwise. Handles
|
|
553
|
+
* cyclical data structures.
|
|
554
|
+
*
|
|
555
|
+
* Dispatches symmetrically to the `equals` methods of both arguments, if
|
|
556
|
+
* present.
|
|
557
|
+
*
|
|
558
|
+
* @func
|
|
559
|
+
* @memberOf R
|
|
560
|
+
* @since v0.15.0
|
|
561
|
+
* @category Relation
|
|
562
|
+
* @sig a -> b -> Boolean
|
|
563
|
+
* @param {*} a
|
|
564
|
+
* @param {*} b
|
|
565
|
+
* @return {Boolean}
|
|
566
|
+
* @example
|
|
567
|
+
*
|
|
568
|
+
* R.equals(1, 1); //=> true
|
|
569
|
+
* R.equals(1, '1'); //=> false
|
|
570
|
+
* R.equals([1, 2, 3], [1, 2, 3]); //=> true
|
|
571
|
+
*
|
|
572
|
+
* const a = {}; a.v = a;
|
|
573
|
+
* const b = {}; b.v = b;
|
|
574
|
+
* R.equals(a, b); //=> true
|
|
575
|
+
*/
|
|
576
|
+
|
|
577
|
+
var equals =
|
|
578
|
+
/*#__PURE__*/
|
|
579
|
+
_curry2(function equals(a, b) {
|
|
580
|
+
return _equals(a, b, [], []);
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
function _isObject(x) {
|
|
584
|
+
return Object.prototype.toString.call(x) === '[object Object]';
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Tests whether or not an object is a typed array.
|
|
589
|
+
*
|
|
590
|
+
* @private
|
|
591
|
+
* @param {*} val The object to test.
|
|
592
|
+
* @return {Boolean} `true` if `val` is a typed array, `false` otherwise.
|
|
593
|
+
* @example
|
|
594
|
+
*
|
|
595
|
+
* _isTypedArray(new Uint8Array([])); //=> true
|
|
596
|
+
* _isTypedArray(new Float32Array([])); //=> true
|
|
597
|
+
* _isTypedArray([]); //=> false
|
|
598
|
+
* _isTypedArray(null); //=> false
|
|
599
|
+
* _isTypedArray({}); //=> false
|
|
600
|
+
*/
|
|
601
|
+
function _isTypedArray(val) {
|
|
602
|
+
var type = Object.prototype.toString.call(val);
|
|
603
|
+
return type === '[object Uint8ClampedArray]' || type === '[object Int8Array]' || type === '[object Uint8Array]' || type === '[object Int16Array]' || type === '[object Uint16Array]' || type === '[object Int32Array]' || type === '[object Uint32Array]' || type === '[object Float32Array]' || type === '[object Float64Array]' || type === '[object BigInt64Array]' || type === '[object BigUint64Array]';
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Returns the empty value of its argument's type. Ramda defines the empty
|
|
608
|
+
* value of Array (`[]`), Object (`{}`), String (`''`),
|
|
609
|
+
* TypedArray (`Uint8Array []`, `Float32Array []`, etc), and Arguments. Other
|
|
610
|
+
* types are supported if they define `<Type>.empty`,
|
|
611
|
+
* `<Type>.prototype.empty` or implement the
|
|
612
|
+
* [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
|
|
613
|
+
*
|
|
614
|
+
* Dispatches to the `empty` method of the first argument, if present.
|
|
615
|
+
*
|
|
616
|
+
* @func
|
|
617
|
+
* @memberOf R
|
|
618
|
+
* @since v0.3.0
|
|
619
|
+
* @category Function
|
|
620
|
+
* @sig a -> a
|
|
621
|
+
* @param {*} x
|
|
622
|
+
* @return {*}
|
|
623
|
+
* @example
|
|
624
|
+
*
|
|
625
|
+
* R.empty(Just(42)); //=> Nothing()
|
|
626
|
+
* R.empty([1, 2, 3]); //=> []
|
|
627
|
+
* R.empty('unicorns'); //=> ''
|
|
628
|
+
* R.empty({x: 1, y: 2}); //=> {}
|
|
629
|
+
* R.empty(Uint8Array.from('123')); //=> Uint8Array []
|
|
630
|
+
*/
|
|
631
|
+
|
|
632
|
+
var empty =
|
|
633
|
+
/*#__PURE__*/
|
|
634
|
+
_curry1(function empty(x) {
|
|
635
|
+
return x != null && typeof x['fantasy-land/empty'] === 'function' ? x['fantasy-land/empty']() : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function' ? x.constructor['fantasy-land/empty']() : x != null && typeof x.empty === 'function' ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === 'function' ? x.constructor.empty() : _isArray(x) ? [] : _isString(x) ? '' : _isObject(x) ? {} : _isArguments(x) ? function () {
|
|
636
|
+
return arguments;
|
|
637
|
+
}() : _isTypedArray(x) ? x.constructor.from('') : void 0 // else
|
|
638
|
+
;
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Returns `true` if the given value is its type's empty value; `false`
|
|
643
|
+
* otherwise.
|
|
644
|
+
*
|
|
645
|
+
* @func
|
|
646
|
+
* @memberOf R
|
|
647
|
+
* @since v0.1.0
|
|
648
|
+
* @category Logic
|
|
649
|
+
* @sig a -> Boolean
|
|
650
|
+
* @param {*} x
|
|
651
|
+
* @return {Boolean}
|
|
652
|
+
* @see R.empty
|
|
653
|
+
* @example
|
|
654
|
+
*
|
|
655
|
+
* R.isEmpty([1, 2, 3]); //=> false
|
|
656
|
+
* R.isEmpty([]); //=> true
|
|
657
|
+
* R.isEmpty(''); //=> true
|
|
658
|
+
* R.isEmpty(null); //=> false
|
|
659
|
+
* R.isEmpty({}); //=> true
|
|
660
|
+
* R.isEmpty({length: 0}); //=> false
|
|
661
|
+
* R.isEmpty(Uint8Array.from('')); //=> true
|
|
662
|
+
*/
|
|
663
|
+
|
|
664
|
+
var isEmpty =
|
|
665
|
+
/*#__PURE__*/
|
|
666
|
+
_curry1(function isEmpty(x) {
|
|
667
|
+
return x != null && equals(x, empty(x));
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
function checkCheckbox(checkboxInputElement, value) {
|
|
671
|
+
if (value) {
|
|
672
|
+
cy.wrap(checkboxInputElement).scrollIntoView().check({ force: true });
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
cy.wrap(checkboxInputElement).scrollIntoView().uncheck({ force: true });
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function checkMultiCheckboxOptions(fieldsetElement, values) {
|
|
680
|
+
cy.wrap(fieldsetElement).scrollIntoView().find('input[type="checkbox"]').uncheck({ force: true });
|
|
681
|
+
if (values) {
|
|
682
|
+
values.forEach(value => {
|
|
683
|
+
cy.wrap(fieldsetElement).find('label').contains(value).find('input[type="checkbox"]').check({ force: true });
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
return fieldsetElement;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function checkMultiRadioOption(fieldsetElement, value) {
|
|
690
|
+
cy.wrap(fieldsetElement)
|
|
691
|
+
.find('label')
|
|
692
|
+
.contains(value)
|
|
693
|
+
.find('input[type="radio"]')
|
|
694
|
+
.scrollIntoView()
|
|
695
|
+
.check({ force: true });
|
|
696
|
+
return fieldsetElement;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function fillTextarea(textareaElement, value) {
|
|
700
|
+
if (value) {
|
|
701
|
+
cy.wrap(textareaElement).scrollIntoView().type(value, { delay: 1, force: true });
|
|
702
|
+
}
|
|
703
|
+
else {
|
|
704
|
+
cy.wrap(textareaElement).scrollIntoView().clear();
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
function fillTextInput(textInputElement, value) {
|
|
709
|
+
if (value) {
|
|
710
|
+
cy.wrap(textInputElement).scrollIntoView().type(value);
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
cy.wrap(textInputElement).scrollIntoView().clear();
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
function pickMultiSelectOptions(cypressMultiSelectInputElement, values) {
|
|
718
|
+
cypressMultiSelectInputElement
|
|
719
|
+
.parent()
|
|
720
|
+
.parent()
|
|
721
|
+
.parent()
|
|
722
|
+
.parent()
|
|
723
|
+
.then(([rsuiteMultiSelectElement]) => {
|
|
724
|
+
if (!rsuiteMultiSelectElement) {
|
|
725
|
+
throw new Error('This should never happen.');
|
|
726
|
+
}
|
|
727
|
+
const maybeClearButton = rsuiteMultiSelectElement.querySelector('.rs-picker-toggle-clean');
|
|
728
|
+
if (maybeClearButton) {
|
|
729
|
+
cy.wrap(maybeClearButton).scrollIntoView().click({ force: true });
|
|
730
|
+
}
|
|
731
|
+
if (values) {
|
|
732
|
+
cy.wrap(rsuiteMultiSelectElement).scrollIntoView().click();
|
|
733
|
+
cy.get('.rs-picker-picker-check-menu').then(([rsuiteMultiSelectMenu]) => {
|
|
734
|
+
if (!rsuiteMultiSelectMenu) {
|
|
735
|
+
throw new Error('This should never happen.');
|
|
736
|
+
}
|
|
737
|
+
const maybeSearchInput = rsuiteMultiSelectMenu.querySelector('.rs-picker-search-bar-input');
|
|
738
|
+
values.forEach(value => {
|
|
739
|
+
if (maybeSearchInput) {
|
|
740
|
+
cy.wrap(maybeSearchInput).scrollIntoView().type(value);
|
|
741
|
+
}
|
|
742
|
+
cy.get('.rs-checkbox-checker').contains(value).scrollIntoView().click({ force: true });
|
|
743
|
+
});
|
|
744
|
+
const offsetLeft = rsuiteMultiSelectElement.offsetLeft
|
|
745
|
+
? rsuiteMultiSelectElement.offsetLeft
|
|
746
|
+
: (() => {
|
|
747
|
+
if (!rsuiteMultiSelectElement.offsetParent) {
|
|
748
|
+
throw new Error('`rsuiteMultiSelectElement.offsetParent` is undefined.');
|
|
749
|
+
}
|
|
750
|
+
return rsuiteMultiSelectElement.offsetParent.offsetLeft;
|
|
751
|
+
})();
|
|
752
|
+
const offsetTop = rsuiteMultiSelectElement.offsetTop !== 0
|
|
753
|
+
? rsuiteMultiSelectElement.offsetTop
|
|
754
|
+
: (() => {
|
|
755
|
+
if (!rsuiteMultiSelectElement.offsetParent) {
|
|
756
|
+
throw new Error('`rsuiteMultiSelectElement.offsetParent` is undefined.');
|
|
757
|
+
}
|
|
758
|
+
return rsuiteMultiSelectElement.offsetParent.offsetTop;
|
|
759
|
+
})();
|
|
760
|
+
// TODO Investigate that (this should be -1).
|
|
761
|
+
cy.clickOutside(offsetLeft, offsetTop - 16);
|
|
762
|
+
cy.wait(250);
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function pickSelectOption(cypressSelectInputElement, value) {
|
|
769
|
+
cypressSelectInputElement
|
|
770
|
+
.parent()
|
|
771
|
+
.parent()
|
|
772
|
+
.parent()
|
|
773
|
+
.parent()
|
|
774
|
+
.scrollIntoView()
|
|
775
|
+
.then(([rsuiteSelectElement]) => {
|
|
776
|
+
if (!rsuiteSelectElement) {
|
|
777
|
+
throw new Error('This should never happen.');
|
|
778
|
+
}
|
|
779
|
+
const maybeClearButton = rsuiteSelectElement.querySelector('.rs-picker-toggle-clean');
|
|
780
|
+
if (maybeClearButton) {
|
|
781
|
+
cy.wrap(maybeClearButton).scrollIntoView().click({ force: true });
|
|
782
|
+
}
|
|
783
|
+
if (value) {
|
|
784
|
+
cy.wrap(rsuiteSelectElement).scrollIntoView().click();
|
|
785
|
+
cy.get('.rs-picker-select-menu').then(([rsuiteSelectMenu]) => {
|
|
786
|
+
if (!rsuiteSelectMenu) {
|
|
787
|
+
throw new Error('This should never happen.');
|
|
788
|
+
}
|
|
789
|
+
const maybeSearchInput = rsuiteSelectMenu.querySelector('.rs-picker-search-bar-input');
|
|
790
|
+
if (maybeSearchInput) {
|
|
791
|
+
cy.wrap(maybeSearchInput).scrollIntoView().type(value);
|
|
792
|
+
}
|
|
793
|
+
cy.get('.rs-picker-select-menu-item').contains(value).scrollIntoView().click({ force: true });
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
return cypressSelectInputElement;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/* eslint-disable cypress/no-assigning-return-values */
|
|
801
|
+
const RETRIES = 5;
|
|
802
|
+
function fill(label, value, leftRetries = RETRIES) {
|
|
803
|
+
// -------------------------------------------------------------------------
|
|
804
|
+
// If this is a `<label />` element
|
|
805
|
+
const labelElement = findElementBytext('label', label);
|
|
806
|
+
if (labelElement) {
|
|
807
|
+
// -------------------------------------------------------------------------
|
|
808
|
+
// If the label has a `for` attribute
|
|
809
|
+
if (!isEmpty(labelElement.htmlFor)) {
|
|
810
|
+
const htmlforElement = findElementBySelector(`[id="${labelElement.htmlFor}"]`);
|
|
811
|
+
if (!htmlforElement) {
|
|
812
|
+
throw new Error(`Could not find the element with [id="${labelElement.htmlFor}"] targetted by label "${label}" (via its \`for\` attribute).`);
|
|
813
|
+
}
|
|
814
|
+
const cypressHtmlforElement = cy.get(`[id="${labelElement.htmlFor}"]`);
|
|
815
|
+
cypressHtmlforElement.then((() => {
|
|
816
|
+
if (htmlforElement.classList.contains('rs-picker-toggle-textbox')) {
|
|
817
|
+
const rsuitePickerElement = htmlforElement.parentElement &&
|
|
818
|
+
htmlforElement.parentElement.parentElement &&
|
|
819
|
+
htmlforElement.parentElement.parentElement.parentElement
|
|
820
|
+
? htmlforElement.parentElement.parentElement.parentElement.parentElement
|
|
821
|
+
: undefined;
|
|
822
|
+
if (!rsuitePickerElement) {
|
|
823
|
+
throw new Error('This should never happen.');
|
|
824
|
+
}
|
|
825
|
+
switch (true) {
|
|
826
|
+
// Select
|
|
827
|
+
case rsuitePickerElement.classList.contains('rs-picker-select'):
|
|
828
|
+
pickSelectOption(cypressHtmlforElement, value !== undefined ? String(value) : value);
|
|
829
|
+
break;
|
|
830
|
+
// Multi Select
|
|
831
|
+
case rsuitePickerElement.classList.contains('rs-picker-tag'):
|
|
832
|
+
pickMultiSelectOptions(cypressHtmlforElement, Array.isArray(value) && value.length > 0 ? value : undefined);
|
|
833
|
+
break;
|
|
834
|
+
default:
|
|
835
|
+
throw new Error(`\`cy.fill()\` can't handle Rsuite picker with class "${rsuitePickerElement.className}" elements.`);
|
|
836
|
+
}
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
switch (htmlforElement.tagName) {
|
|
840
|
+
// Text/Number Input
|
|
841
|
+
case 'INPUT':
|
|
842
|
+
fillTextInput(htmlforElement, value !== undefined ? String(value) : value);
|
|
843
|
+
break;
|
|
844
|
+
// Textarea
|
|
845
|
+
case 'TEXTAREA':
|
|
846
|
+
fillTextarea(htmlforElement, value !== undefined ? String(value) : value);
|
|
847
|
+
break;
|
|
848
|
+
default:
|
|
849
|
+
throw new Error(`\`cy.fill()\` doesn't handle "${htmlforElement.tagName}" elements.`);
|
|
850
|
+
}
|
|
851
|
+
}));
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
// -------------------------------------------------------------------------
|
|
855
|
+
// If the label doesn't have a `for` attribute
|
|
856
|
+
// Checkbox Input
|
|
857
|
+
const checkboxInputElement = labelElement.querySelector('input[type="checkbox"]');
|
|
858
|
+
if (checkboxInputElement) {
|
|
859
|
+
checkCheckbox(checkboxInputElement, Boolean(value));
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
// Text Input
|
|
863
|
+
const textInputElement = labelElement.querySelector('input[type="text"]');
|
|
864
|
+
if (textInputElement) {
|
|
865
|
+
fillTextInput(textInputElement, String(value));
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
// Textarea
|
|
869
|
+
const textareaElement = labelElement.querySelector('textarea');
|
|
870
|
+
if (textareaElement) {
|
|
871
|
+
fillTextarea(textareaElement, String(value));
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
throw new Error(`Could find neither a checkbox, an input nor a textarea with the label "${label}".`);
|
|
875
|
+
}
|
|
876
|
+
// -------------------------------------------------------------------------
|
|
877
|
+
// If this is a `<legend />` element
|
|
878
|
+
const legendElement = findElementBytext('legend', label);
|
|
879
|
+
if (legendElement) {
|
|
880
|
+
const cypressLegendElement = cy.get('legend').contains(label);
|
|
881
|
+
cypressLegendElement.then(async () => {
|
|
882
|
+
await waitFor(500);
|
|
883
|
+
const fieldsetElement = legendElement.parentElement;
|
|
884
|
+
if (!fieldsetElement || fieldsetElement.tagName !== 'FIELDSET') {
|
|
885
|
+
throw new Error(`Could not find parent fieldset of legend element with text "${label}".`);
|
|
886
|
+
}
|
|
887
|
+
const isMultiCheckbox = Boolean(fieldsetElement.querySelector('input[type="checkbox"]'));
|
|
888
|
+
const isMultiRadio = Boolean(fieldsetElement.querySelector('input[type="radio"]'));
|
|
889
|
+
if (isMultiCheckbox) {
|
|
890
|
+
checkMultiCheckboxOptions(fieldsetElement, Array.isArray(value) && value.length > 0 ? value : undefined);
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
if (isMultiRadio) {
|
|
894
|
+
checkMultiRadioOption(fieldsetElement, String(value));
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
throw new Error(`\`cy.fill()\` can't handle the field with legend "${label}".`);
|
|
898
|
+
});
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
if (leftRetries > 0) {
|
|
902
|
+
cy.wait(250).then(() => {
|
|
903
|
+
cy.log(`Retrying (${RETRIES - leftRetries + 1} / ${RETRIES})...`);
|
|
904
|
+
fill(label, value, leftRetries - 1);
|
|
905
|
+
});
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
throw new Error(`Could not find label or legend element with text "${label}".`);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
function forceClick([subject]) {
|
|
912
|
+
if (!subject) {
|
|
913
|
+
throw new Error(`Could not find subject.`);
|
|
914
|
+
}
|
|
915
|
+
return subject.click({ force: true });
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
function getDataCy(dataCy) {
|
|
919
|
+
return cy.get(`[data-cy="${dataCy}"]`);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
Cypress.Commands.add('clickButton', clickButton);
|
|
923
|
+
Cypress.Commands.add('clickLink', (linkText) => cy.get('a').contains(linkText).click());
|
|
924
|
+
/**
|
|
925
|
+
* @description
|
|
926
|
+
* Useful to close modals.
|
|
927
|
+
*/
|
|
928
|
+
Cypress.Commands.add('clickOutside', clickOutside);
|
|
929
|
+
/**
|
|
930
|
+
* @example
|
|
931
|
+
* ```ts
|
|
932
|
+
* cy.fill('Password', 'P422W0Rd')
|
|
933
|
+
* ```
|
|
934
|
+
*/
|
|
935
|
+
Cypress.Commands.add('fill', fill);
|
|
936
|
+
// Maybe because of https://github.com/cypress-io/cypress/issues/19564
|
|
937
|
+
Cypress.Commands.add('forceClick', { prevSubject: true }, forceClick);
|
|
938
|
+
Cypress.Commands.add('getDataCy', getDataCy);
|
|
939
|
+
//# sourceMappingURL=index.js.map
|