Skip to content

Commit

Permalink
Merge pull request #491 from SuitestAutomation/hotfix/SUIT-19493
Browse files Browse the repository at this point in the history
hotfix/SUIT-19493
  • Loading branch information
JeKachan authored Jan 31, 2023
2 parents dea32f8 + e668bd2 commit ba9a861
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 73 deletions.
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const timestamp = require('../lib/constants/timestamp');
const {validate, validators} = require('../lib/validation');
const {invalidConfigObj} = require('../lib/texts');
const {pickNonNil} = require('../lib/utils/common');
const envVars = require('../lib/constants/enviroment');
const envVars = require('../lib/constants/environment');

const sentryDsn = 'https://1f74b885d0c44549b57f307733d60351:[email protected]/288812';
const DEFAULT_TIMEOUT = 2000;
Expand Down
21 changes: 12 additions & 9 deletions lib/composers/acceptModalComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ const {invalidInputMessage} = require('../texts');
* Accept modal dialog, optionally sending message
* @param {String} [message] - text to be send to modal dialog
*/
const acceptModalComposer = makeModifierComposer(composers.ACCEPT_MODAL, ['acceptModal'], (_, meta, message = null) => ({
...meta,
isAcceptModal: true,
acceptModalMessage: validate(
validators.NON_EMPTY_STRING_OR_NUll,
message,
invalidInputMessage('acceptModal', 'Message value'),
),
}));
const acceptModalComposer = makeModifierComposer(
composers.ACCEPT_MODAL,
['acceptModal'],
(_, meta, message = null) => ({
...meta,
isAcceptModal: true,
acceptModalMessage: validate(
validators.NON_EMPTY_STRING_OR_NUll,
message,
invalidInputMessage('acceptModal', 'Message value'),
),
}));

module.exports = acceptModalComposer;
2 changes: 1 addition & 1 deletion lib/composers/cloneComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const cloneComposer = makeModifierComposer(
composers.CLONE,
['clone'],
(_, meta) => ({...meta}),
{unregisterParent: false}
{unregisterParent: false},
);

module.exports = cloneComposer;
2 changes: 1 addition & 1 deletion lib/composers/matchBrightScriptComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const matchBrightScriptComposer = makeModifierComposer(
val: res,
},
};
}
},
);

module.exports = matchBrightScriptComposer;
25 changes: 14 additions & 11 deletions lib/composers/matchRepoComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@ const processMatchRepoArgs = makeArgumentsProcessor(
}),
);

const matchRepoComposer = makeModifierComposer(composers.MATCH_REPO, ['matchRepo', 'matchesRepo'], (_, data, ...args) => ({
...data,
comparator: {
type: SUBJ_COMPARATOR.MATCH,
props: validation.validate(
validation.validators.ELEMENT_REPO_PROPS,
processMatchRepoArgs(args),
invalidInputMessage('matchRepo', 'Property')
),
},
}));
const matchRepoComposer = makeModifierComposer(
composers.MATCH_REPO,
['matchRepo', 'matchesRepo'],
(_, data, ...args) => ({
...data,
comparator: {
type: SUBJ_COMPARATOR.MATCH,
props: validation.validate(
validation.validators.ELEMENT_REPO_PROPS,
processMatchRepoArgs(args),
invalidInputMessage('matchRepo', 'Property'),
),
},
}));

module.exports = matchRepoComposer;
4 changes: 2 additions & 2 deletions lib/composers/requestMatchesComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const processRequestArgs = makeArgumentsProcessor(
*/
({name, val, type = PROP_COMPARATOR.EQUAL}) => getRequestMatchItem(name, val, type),
objArg => 'name' in objArg && 'val' in objArg,
getRequestMatchItem
getRequestMatchItem,
);

const requestMatchesComposer = makeModifierComposer(
Expand All @@ -47,7 +47,7 @@ const requestMatchesComposer = makeModifierComposer(
invalidInputMessage('requestMatch', 'Header'),
),
},
})
}),
);

module.exports = requestMatchesComposer;
6 changes: 3 additions & 3 deletions lib/composers/responseMatchesComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const processResponseArgs = makeArgumentsProcessor(
*/
({name, val, type = PROP_COMPARATOR.EQUAL}) => getResponseMatchComposers(name, val, type),
objArg => 'name' in objArg && 'val' in objArg,
getResponseMatchComposers
getResponseMatchComposers,
);

const responseMatchesComposer = makeModifierComposer(
Expand All @@ -45,10 +45,10 @@ const responseMatchesComposer = makeModifierComposer(
props: validation.validate(
validation.validators.RESPONSE_MATCHES,
processResponseArgs(args),
invalidInputMessage('responseMatch', 'Header')
invalidInputMessage('responseMatch', 'Header'),
),
},
})
}),
);

module.exports = responseMatchesComposer;
23 changes: 16 additions & 7 deletions lib/composers/swipeComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ const {invalidInputMessage} = require('../texts');
/**
* Defines click method
*/
const swipeComposer = makeModifierComposer(composers.TAP, ['swipe', 'flick'], (_, meta, direction, distance, duration) => ({
...meta,
isSwipe: true,
direction: validate(validators.DIRECTIONS, direction, invalidInputMessage('swipe/flick', 'direction')),
distance: validate(validators.ST_VAR_OR_POSITIVE_NUMBER, distance, invalidInputMessage('swipe/flick', 'distance')),
duration: validate(validators.ST_VAR_OR_POSITIVE_NUMBER, duration, invalidInputMessage('swipe/flick', 'duration')),
}));
const swipeComposer = makeModifierComposer(
composers.TAP,
['swipe', 'flick'],
(_, meta, direction, distance, duration) => ({
...meta,
isSwipe: true,
direction: validate(validators.DIRECTIONS, direction, invalidInputMessage('swipe/flick', 'direction')),
distance: validate(
validators.ST_VAR_OR_POSITIVE_NUMBER, distance,
invalidInputMessage('swipe/flick', 'distance'),
),
duration: validate(
validators.ST_VAR_OR_POSITIVE_NUMBER, duration,
invalidInputMessage('swipe/flick', 'duration'),
),
}));

module.exports = swipeComposer;
4 changes: 2 additions & 2 deletions lib/constants/enviroment.js → lib/constants/environment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const ENVIROMENT_VARS = Object.freeze({
const ENVIRONMENT_VARS = Object.freeze({
/**
* @description indicates that session is running as launcher child process, contains deviceId|configId|ipcPortNumber
*/
Expand All @@ -7,4 +7,4 @@ const ENVIROMENT_VARS = Object.freeze({
SUITEST_BE_SERVER: 'SUITEST_BE_SERVER',
});

module.exports = ENVIROMENT_VARS;
module.exports = ENVIRONMENT_VARS;
2 changes: 2 additions & 0 deletions lib/constants/screenOrientation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable key-spacing */

const screenOrientation = {
PORTRAIT: 'portrait',
PORTRAIT_REVERSED: 'portraitReversed',
Expand Down
2 changes: 1 addition & 1 deletion lib/testLauncher/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const chokidar = require('chokidar');

const texts = require('../texts');
const ipcClient = require('./ipc/client');
const envVars = require('../constants/enviroment');
const envVars = require('../constants/environment');
const messageId = require('../constants/ipcMessageId');
const errorListeners = require('../utils/errorListeners');
const {getShortFunctionBody} = require('../utils/stringUtils');
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/AuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const allowedRequests = {
* Decorate http requestObject with current context headers
* @param {*} requestObject
* @param {*} headers
* @returns requestObject decoerated with auth headers
* @returns requestObject decorated with auth headers
*/
function decorateRequestObject(requestObject, headers) {
return Object.assign({}, requestObject, {headers});
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/sessionStarter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const {TOKEN} = require('../constants/modes');
const chainPromise = require('./chainPromise');
const {validate, validators} = require('../validation');
const {captureException} = require('./sentry/Raven');
const envVars = require('../constants/enviroment');
const envVars = require('../constants/environment');
const messageId = require('../constants/ipcMessageId');
const ipcClient = require('../testLauncher/ipc/client');
const {replWarn} = require('../texts');
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/testLauncherHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const texts = require('../texts');

const Queue = require('./Queue');
const {registerProcess} = require('../testLauncher/processReaper');
const envVars = require('../constants/enviroment');
const envVars = require('../constants/environment');

const {version} = require('../../package.json');
const {stripAnsiChars} = require('./stringUtils');
Expand Down Expand Up @@ -192,7 +192,7 @@ function logOutput(child, chunk, logStream) {
* needs to be called to enable sending terminal codes.
* When repl ends the node process for some reason does not want to take over
* the ownership of the terminal anymore (setRawMode(false) does not help).
* This function manually enables ctrl+c togther with the keypress module
* This function manually enables ctrl+c together with the keypress module
* @param {string} ch
* @param {Object} key
*/
Expand Down
40 changes: 20 additions & 20 deletions lib/validation/jsonSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const deviation = {
'then': {'type': ['number', 'string']},
'else': {'const': 'undefined'},
};
const propComarator = {
const propComparator = {
'type': 'string',
'enum': Object.values(PROP_COMPARATOR),
};
Expand All @@ -164,7 +164,7 @@ schemas[validationKeys.ELEMENT_PROPS] = {
'type': 'string',
'enum': Object.values(ELEMENT_PROP),
},
'type': propComarator,
'type': propComparator,
'val': {'const': VALUE.REPO},
deviation,
}},
Expand All @@ -173,7 +173,7 @@ schemas[validationKeys.ELEMENT_PROPS] = {
'type': 'string',
'enum': ELEMENT_PROP_BY_TYPE.integer,
},
'type': propComarator,
'type': propComparator,
'val': {'type': ['integer', 'string']},
deviation,
}},
Expand All @@ -182,55 +182,55 @@ schemas[validationKeys.ELEMENT_PROPS] = {
'type': 'string',
'enum': ELEMENT_PROP_BY_TYPE.string,
},
'type': propComarator,
'type': propComparator,
'val': {'type': 'string'},
deviation,
}},
{'properties': {
'name': {'enum': ELEMENT_PROP_BY_TYPE.number},
'type': propComarator,
'type': propComparator,
'val': {'type': ['number', 'string']},
deviation,
}},
{'properties': {
'name': {'enum': ELEMENT_PROP_BY_TYPE.boolean},
'type': propComarator,
'type': propComparator,
'val': {'type': 'boolean'},
deviation,
}},
{'properties': {
'name': {'const': ELEMENT_PROP.BORDER_STYLE},
'type': propComarator,
'type': propComparator,
'val': {'enum': Object.values(BORDER_STYLE)},
}},
{'properties': {
'name': {'const': ELEMENT_PROP.VIDEO_STATE},
'type': propComarator,
'type': propComparator,
'val': {'enum': Object.values(VIDEO_STATE)},
}},
{'properties': {
'name': {'const': ELEMENT_PROP.VISIBILITY},
'type': propComarator,
'type': propComparator,
'val': {'enum': [VISIBILITY_STATE.COLLAPSED, VISIBILITY_STATE.INVISIBLE, VISIBILITY_STATE.VISIBLE]},
}},
{'properties': {
'name': {'const': ELEMENT_PROP.CONTENT_MODE},
'type': propComarator,
'type': propComparator,
'val': {'enum': Object.values(CONTENT_MODE)},
}},
{'properties': {
'name': {'const': ELEMENT_PROP.STATE},
'type': propComarator,
'type': propComparator,
'val': {'enum': Object.values(ELEMENT_STATE)},
}},
{'properties': {
'name': {'const': ELEMENT_PROP.TEXT_ALIGNMENT},
'type': propComarator,
'type': propComparator,
'val': {'enum': Object.values(TEXT_ALIGNMENT)},
}},
{'properties': {
'name': {'const': ELEMENT_PROP.IMAGE_LOAD_STATE},
'type': propComarator,
'type': propComparator,
'val': {'enum': Object.values(IMAGE_LOAD_STATE)},
}},
],
Expand All @@ -245,7 +245,7 @@ schemas[validationKeys.ELEMENT_REPO_PROPS] = {
'additionalProperties': false,
'properties': {
'name': {'enum': Object.values(ELEMENT_PROP)},
'type': propComarator,
'type': propComparator,
'val': {'const': VALUE.REPO},
deviation,
},
Expand All @@ -261,17 +261,17 @@ schemas[validationKeys.REQUEST_MATCHES] = {
{'properties': {
'name': {'type': 'string'},
'val': {'type': 'string'},
'compare': propComarator,
'compare': propComparator,
}},
{'properties': {
'name': {'const': NETWORK_PROP.METHOD},
'val': {'enum': Object.values(NETWORK_METHOD)},
'compare': propComarator,
'compare': propComparator,
}},
{'properties': {
'name': {'const': NETWORK_PROP.BODY},
'val': {'type': 'string'},
'compare': propComarator,
'compare': propComparator,
}},
],
},
Expand All @@ -286,17 +286,17 @@ schemas[validationKeys.RESPONSE_MATCHES] = {
{'properties': {
'name': {'type': 'string'},
'val': {'type': 'string'},
'compare': propComarator,
'compare': propComparator,
}},
{'properties': {
'name': {'const': NETWORK_PROP.STATUS},
'val': {'type': ['number', 'string']},
'compare': propComarator,
'compare': propComparator,
}},
{'properties': {
'name': {'const': NETWORK_PROP.BODY},
'val': {'type': 'string'},
'compare': propComarator,
'compare': propComparator,
}},
],
},
Expand Down
4 changes: 1 addition & 3 deletions lib/validation/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ function throwError(text) {
);
}

const getElementPropName = (mapOfNames, name) => typeof mapOfNames[name] === 'string' ? mapOfNames[name] : name;

/**
* @description returns prettified errors messages for element properties errors
* @param {Object} validate
Expand Down Expand Up @@ -130,7 +128,7 @@ function prettifyJsonSchemaErrors(validate) {
* @param {*|Symbol} schemaKey json schema of schemas map key
* @param {*} data
* @param {String} errorMessage
* @returns {*} input data or thorws error
* @returns {*} input data or throws error
* @throws SuitestError
*/
function validateJsonSchema(schemaKey, data, errorMessage) {
Expand Down
Loading

0 comments on commit ba9a861

Please sign in to comment.