suitest-js-api 3.20.0 → 3.20.2
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.
|
@@ -95,6 +95,10 @@ const pressButtonFactory = (classInstance) => {
|
|
|
95
95
|
validators.ST_VAR_NOT_NEGATIVE_NUMBER,
|
|
96
96
|
options.longPressMs,
|
|
97
97
|
invalidInputMessage('pressButton', 'Invalid longPressMs'),
|
|
98
|
+
) && validate(
|
|
99
|
+
validators.ST_VAR_MS_DURATION,
|
|
100
|
+
options.longPressMs,
|
|
101
|
+
invalidInputMessage('pressButton', 'Invalid longPressMs'),
|
|
98
102
|
)
|
|
99
103
|
: undefined,
|
|
100
104
|
});
|
|
@@ -6,6 +6,7 @@ const validationKeys = {
|
|
|
6
6
|
ST_VAR_NOT_NEGATIVE_NUMBER: Symbol('stVarOrPositiveNumber'),
|
|
7
7
|
ST_VAR_OR_POSITIVE_NUMBER: Symbol('stVarOrPositiveNumberNotZero'),
|
|
8
8
|
ST_VAR_OR_NUMBER: Symbol('stVarOrNumber'),
|
|
9
|
+
ST_VAR_MS_DURATION: Symbol('stVarMsDuration'),
|
|
9
10
|
NON_EMPTY_STRING_OR_UNDEFINED: Symbol('nonEmptyStringOrUndefined'),
|
|
10
11
|
STRING_OR_NULL: Symbol('stringOrNull'),
|
|
11
12
|
ARRAY_OF_BUTTONS: Symbol('arrayOfButtons'),
|
|
@@ -161,6 +161,16 @@ function validateJsonSchema(schemaKey, data, errorMessage) {
|
|
|
161
161
|
return data;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
const validateMaxMsDuration = (val, name) => {
|
|
165
|
+
const MAX_DURATION = 30000;
|
|
166
|
+
|
|
167
|
+
if (!Number.isFinite(val) || val > MAX_DURATION) {
|
|
168
|
+
throwError(name + ' maximum duration (30s) exceeded');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return val;
|
|
172
|
+
};
|
|
173
|
+
|
|
164
174
|
const validateNotNegativeNumber = (val, name) => {
|
|
165
175
|
if (!Number.isFinite(val) || val < 0) {
|
|
166
176
|
throwError(name + ' should be not negative number');
|
|
@@ -188,6 +198,7 @@ const validateNumber = (val, name) => {
|
|
|
188
198
|
const createStVarOrNumberValidator = ({
|
|
189
199
|
notNegativeNumbers = false,
|
|
190
200
|
positiveNumbers = false,
|
|
201
|
+
maxDuration = false,
|
|
191
202
|
}) => (val, name) => {
|
|
192
203
|
if (
|
|
193
204
|
!['number', 'string'].includes(typeof val)
|
|
@@ -199,6 +210,8 @@ const createStVarOrNumberValidator = ({
|
|
|
199
210
|
validatePositiveNumber(val, name);
|
|
200
211
|
} else if (notNegativeNumbers) {
|
|
201
212
|
validateNotNegativeNumber(val, name);
|
|
213
|
+
} else if (maxDuration) {
|
|
214
|
+
validateMaxMsDuration(val, name);
|
|
202
215
|
} else {
|
|
203
216
|
validateNumber(val, name);
|
|
204
217
|
}
|
|
@@ -210,6 +223,7 @@ const createStVarOrNumberValidator = ({
|
|
|
210
223
|
const validateStVarOrNumber = createStVarOrNumberValidator({});
|
|
211
224
|
const validateStVarOrPositiveNumber = createStVarOrNumberValidator({notNegativeNumbers: true});
|
|
212
225
|
const validateStVarOrPositiveNumberNotZero = createStVarOrNumberValidator({positiveNumbers: true});
|
|
226
|
+
const validateStVarMsDuration = createStVarOrNumberValidator({maxDuration: true});
|
|
213
227
|
|
|
214
228
|
const validateNonEmptyStringOrUndefined = (val, name) => {
|
|
215
229
|
if (typeof val === 'string' && val.length || val === undefined) {
|
|
@@ -330,5 +344,6 @@ module.exports = {
|
|
|
330
344
|
validateStVarOrNumber,
|
|
331
345
|
validateStVarOrPositiveNumber,
|
|
332
346
|
validateStVarOrPositiveNumberNotZero,
|
|
347
|
+
validateStVarMsDuration,
|
|
333
348
|
validateTapTypeAndDuration,
|
|
334
349
|
};
|
|
@@ -20,6 +20,9 @@ const validatorsMap = {
|
|
|
20
20
|
[validationKeys.ST_VAR_OR_NUMBER]: (value, text) => {
|
|
21
21
|
return validators.validateStVarOrNumber(value, text);
|
|
22
22
|
},
|
|
23
|
+
[validationKeys.ST_VAR_MS_DURATION]: (value, text) => {
|
|
24
|
+
return validators.validateStVarMsDuration(value, text);
|
|
25
|
+
},
|
|
23
26
|
[validationKeys.NON_EMPTY_STRING_OR_UNDEFINED]: (value, text) => {
|
|
24
27
|
return validators.validateNonEmptyStringOrUndefined(value, text);
|
|
25
28
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suitest-js-api",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": "git@github.com:SuitestAutomation/suitest-js-api.git",
|
|
6
6
|
"author": "Suitest <hello@suite.st>",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
96
|
"@suitest/smst-to-text": "^4.13.0",
|
|
97
|
-
"@suitest/translate": "^4.
|
|
97
|
+
"@suitest/translate": "^4.23.0",
|
|
98
98
|
"@types/node": "^14.0.10",
|
|
99
99
|
"ajv": "^6.12.2",
|
|
100
100
|
"ansi-regex": "^5.0.0",
|