From 474e1e1fba3ee47295317fd281e5a7be11c0e606 Mon Sep 17 00:00:00 2001 From: JeKachan Date: Fri, 8 Apr 2022 14:44:59 +0300 Subject: [PATCH 01/24] SUIT-18682 Update result types for return 'undefined' instead 'void' --- typeDefinition/ApplicationChain.d.ts | 2 +- typeDefinition/BrightScriptExpression.d.ts | 2 +- typeDefinition/ClearAppData.d.ts | 2 +- typeDefinition/CloseAppChain.d.ts | 2 +- typeDefinition/CookieChain.d.ts | 4 ++-- typeDefinition/ElementChain.d.ts | 4 ++-- typeDefinition/ExecuteBrightScriptChain.d.ts | 2 +- typeDefinition/ExecuteCommandChain.d.ts | 2 +- typeDefinition/JavascriptExpression.d.ts | 2 +- typeDefinition/LocationChain.d.ts | 2 +- typeDefinition/NetworkRequest.d.ts | 2 +- typeDefinition/OpenAppChain.d.ts | 2 +- typeDefinition/OpenUrl.d.ts | 2 +- typeDefinition/PlayStationVideoChain.d.ts | 4 ++-- typeDefinition/PollUrl.d.ts | 2 +- typeDefinition/PositionChain.d.ts | 2 +- typeDefinition/PressButton.d.ts | 2 +- typeDefinition/RelativePositionChain.d.ts | 2 +- typeDefinition/SleepChain.d.ts | 2 +- typeDefinition/SuspendAppChain.d.ts | 2 +- typeDefinition/VideoChain.d.ts | 4 ++-- typeDefinition/WindowChain.d.ts | 2 +- 22 files changed, 26 insertions(+), 26 deletions(-) diff --git a/typeDefinition/ApplicationChain.d.ts b/typeDefinition/ApplicationChain.d.ts index 5549552c..22451694 100644 --- a/typeDefinition/ApplicationChain.d.ts +++ b/typeDefinition/ApplicationChain.d.ts @@ -56,4 +56,4 @@ interface ApplicationAbandonedChain extends {} type ApplicationQueryResult = string; -type ApplicationEvalResult = boolean | void; +type ApplicationEvalResult = boolean | undefined; diff --git a/typeDefinition/BrightScriptExpression.d.ts b/typeDefinition/BrightScriptExpression.d.ts index 2e78a828..a3a3a950 100644 --- a/typeDefinition/BrightScriptExpression.d.ts +++ b/typeDefinition/BrightScriptExpression.d.ts @@ -75,4 +75,4 @@ interface BrightScriptExpressionAbandonedChain extends {} type BrightScriptExpressionQueryResult = string; -type BrightScriptExpressionEvalResult = boolean | void; +type BrightScriptExpressionEvalResult = boolean | undefined; diff --git a/typeDefinition/ClearAppData.d.ts b/typeDefinition/ClearAppData.d.ts index 15b4c535..363347ae 100644 --- a/typeDefinition/ClearAppData.d.ts +++ b/typeDefinition/ClearAppData.d.ts @@ -10,4 +10,4 @@ export interface ClearAppDataChain extends interface ClearAppDataAbandonedChain extends AbstractChain {} -type ClearAppDataEvalResult = void | boolean; +type ClearAppDataEvalResult = undefined | boolean; diff --git a/typeDefinition/CloseAppChain.d.ts b/typeDefinition/CloseAppChain.d.ts index fcb98eba..c85fc07a 100644 --- a/typeDefinition/CloseAppChain.d.ts +++ b/typeDefinition/CloseAppChain.d.ts @@ -9,4 +9,4 @@ export interface CloseAppChain extends interface CloseAppAbandonedChain extends AbstractChain {} -type CloseAppEvalResult = void | boolean; +type CloseAppEvalResult = undefined | boolean; diff --git a/typeDefinition/CookieChain.d.ts b/typeDefinition/CookieChain.d.ts index 365a08d7..e1ba5277 100644 --- a/typeDefinition/CookieChain.d.ts +++ b/typeDefinition/CookieChain.d.ts @@ -71,5 +71,5 @@ interface CookieEvalModifiers extends interface CookieAbandonedChain extends AbstractChain {} -type CookieQueryResult = string | void; -type CookieEvalResult = boolean | void; +type CookieQueryResult = string | undefined; +type CookieEvalResult = boolean | undefined; diff --git a/typeDefinition/ElementChain.d.ts b/typeDefinition/ElementChain.d.ts index a737ced4..d967c637 100644 --- a/typeDefinition/ElementChain.d.ts +++ b/typeDefinition/ElementChain.d.ts @@ -151,5 +151,5 @@ interface ElementBaseEvalChain extends interface ElementAbandonedChain extends AbstractChain {} -type ElementQueryResult = ElementProps | void; -type ElementEvalResult = boolean | void; +type ElementQueryResult = ElementProps | undefined; +type ElementEvalResult = boolean | undefined; diff --git a/typeDefinition/ExecuteBrightScriptChain.d.ts b/typeDefinition/ExecuteBrightScriptChain.d.ts index 144627c9..750da65f 100644 --- a/typeDefinition/ExecuteBrightScriptChain.d.ts +++ b/typeDefinition/ExecuteBrightScriptChain.d.ts @@ -9,4 +9,4 @@ export interface ExecuteBrightScriptChain extends interface ExecuteBrightScriptAbandonedChain extends AbstractChain {} -type ExecuteBrightScriptEvalResult = boolean | void; +type ExecuteBrightScriptEvalResult = boolean | undefined; diff --git a/typeDefinition/ExecuteCommandChain.d.ts b/typeDefinition/ExecuteCommandChain.d.ts index 9900c62e..2d86c35e 100644 --- a/typeDefinition/ExecuteCommandChain.d.ts +++ b/typeDefinition/ExecuteCommandChain.d.ts @@ -9,4 +9,4 @@ export interface ExecuteCommandChain extends interface ExecuteCommandAbandonedChain extends AbstractChain {} -type ExecuteCommandEvalResult = boolean | void; +type ExecuteCommandEvalResult = boolean | undefined; diff --git a/typeDefinition/JavascriptExpression.d.ts b/typeDefinition/JavascriptExpression.d.ts index 3cf3a21f..8e68262a 100644 --- a/typeDefinition/JavascriptExpression.d.ts +++ b/typeDefinition/JavascriptExpression.d.ts @@ -75,4 +75,4 @@ interface JsExpressionAbandonedChain extends {} type JsExpressionQueryResult = string; -type JsExpressionEvalResult = boolean | void; +type JsExpressionEvalResult = boolean | undefined; diff --git a/typeDefinition/LocationChain.d.ts b/typeDefinition/LocationChain.d.ts index 56517331..01b2b4df 100644 --- a/typeDefinition/LocationChain.d.ts +++ b/typeDefinition/LocationChain.d.ts @@ -77,4 +77,4 @@ interface LocationAbandonedChain extends {} type LocationQueryResult = string; -type LocationEvalResult = boolean | void; +type LocationEvalResult = boolean | undefined; diff --git a/typeDefinition/NetworkRequest.d.ts b/typeDefinition/NetworkRequest.d.ts index 980663a0..5d1030e2 100644 --- a/typeDefinition/NetworkRequest.d.ts +++ b/typeDefinition/NetworkRequest.d.ts @@ -35,4 +35,4 @@ interface NetworkRequestEvalChain extends interface NetworkRequestAbandonedChain extends AbstractChain {} -type NetworkRequestEvalResult = boolean | void; +type NetworkRequestEvalResult = boolean | undefined; diff --git a/typeDefinition/OpenAppChain.d.ts b/typeDefinition/OpenAppChain.d.ts index 1182f32d..06f01051 100644 --- a/typeDefinition/OpenAppChain.d.ts +++ b/typeDefinition/OpenAppChain.d.ts @@ -11,4 +11,4 @@ export interface OpenAppChain extends interface OpenAppAbandonedChain extends AbstractChain {} -type OpenAppEvalResult = void | boolean; +type OpenAppEvalResult = undefined | boolean; diff --git a/typeDefinition/OpenUrl.d.ts b/typeDefinition/OpenUrl.d.ts index 8c45a8a8..a2dfd2f7 100644 --- a/typeDefinition/OpenUrl.d.ts +++ b/typeDefinition/OpenUrl.d.ts @@ -9,4 +9,4 @@ export interface OpenUrlChain extends interface OpenUrlAbandonedChain extends AbstractChain {} -type OpenUrlEvalResult = void | boolean; +type OpenUrlEvalResult = undefined | boolean; diff --git a/typeDefinition/PlayStationVideoChain.d.ts b/typeDefinition/PlayStationVideoChain.d.ts index 2fa4b3bc..47394acc 100644 --- a/typeDefinition/PlayStationVideoChain.d.ts +++ b/typeDefinition/PlayStationVideoChain.d.ts @@ -47,5 +47,5 @@ interface PlayStationVideoBaseEvalChain extends interface PlayStationVideoAbandonedChain extends AbstractChain {} -type PlayStationVideoQueryResult = PlayStationVideoProps | void; -type PlayStationVideoEvalResult = boolean | void; +type PlayStationVideoQueryResult = PlayStationVideoProps | undefined; +type PlayStationVideoEvalResult = boolean | undefined; diff --git a/typeDefinition/PollUrl.d.ts b/typeDefinition/PollUrl.d.ts index 9ea70ee3..50edb2f4 100644 --- a/typeDefinition/PollUrl.d.ts +++ b/typeDefinition/PollUrl.d.ts @@ -9,4 +9,4 @@ export interface PollUrlChain extends interface PollUrlAbandonedChain extends AbstractChain {} -type PollUrlEvalResult = void | boolean; +type PollUrlEvalResult = undefined | boolean; diff --git a/typeDefinition/PositionChain.d.ts b/typeDefinition/PositionChain.d.ts index 906327b7..aa340dc8 100644 --- a/typeDefinition/PositionChain.d.ts +++ b/typeDefinition/PositionChain.d.ts @@ -52,4 +52,4 @@ interface PositionEmptyChain extends PositionBaseEvalChain { interface PositionAbandonedChain extends AbstractChain {} type PositionQueryResult = string; -type PositionEvalResult = boolean | void; +type PositionEvalResult = boolean | undefined; diff --git a/typeDefinition/PressButton.d.ts b/typeDefinition/PressButton.d.ts index 9c9a82f6..84e4269e 100644 --- a/typeDefinition/PressButton.d.ts +++ b/typeDefinition/PressButton.d.ts @@ -38,4 +38,4 @@ interface PressButtonEmptyChain extends PressButtonBaseEvalChain extends interface VideoAbandonedChain extends AbstractChain {} -type VideoQueryResult = ElementProps | void; -type VideoEvalResult = boolean | void; +type VideoQueryResult = ElementProps | undefined; +type VideoEvalResult = boolean | undefined; diff --git a/typeDefinition/WindowChain.d.ts b/typeDefinition/WindowChain.d.ts index fd422ebc..aa42be9f 100644 --- a/typeDefinition/WindowChain.d.ts +++ b/typeDefinition/WindowChain.d.ts @@ -54,4 +54,4 @@ interface WindowEmptyChain extends WindowBaseEvalChain {} interface WindowAbandonedChain extends AbstractChain {} type WindowQueryResult = string; -type WindowEvalResult = boolean | void; +type WindowEvalResult = boolean | undefined; From 82106beab4df963cb9375aaa7b9f22475130ae2e Mon Sep 17 00:00:00 2001 From: JeKachan Date: Tue, 30 Aug 2022 15:10:40 +0300 Subject: [PATCH 02/24] SUIT-19173 Added DONE to KEY's for Tizen platform. Added SEARCH to KEY's for Roku platform. --- lib/constants/keys.js | 2 ++ typeDefinition/constants/Keys.d.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/constants/keys.js b/lib/constants/keys.js index b9b85b3a..0bce42cf 100644 --- a/lib/constants/keys.js +++ b/lib/constants/keys.js @@ -56,6 +56,8 @@ const KEY = { SUBTRACT: '[[Subtract]]', TAB: '[[Tab]]', UP_ARROW: '[[Up arrow]]', + SEARCH: '[[Search]]', + DONE: '[[Done]]', }; Object.freeze(KEY); diff --git a/typeDefinition/constants/Keys.d.ts b/typeDefinition/constants/Keys.d.ts index 24976b5a..3481133c 100644 --- a/typeDefinition/constants/Keys.d.ts +++ b/typeDefinition/constants/Keys.d.ts @@ -55,4 +55,6 @@ export type Keys = { SUBTRACT: '[[Subtract]]', TAB: '[[Tab]]', UP_ARROW: '[[Up arrow]]', + SEARCH: '[[Search]]', + DONE: '[[Done]]', } From 4820f2cd43c757f099bbaaeb09066202e1f34225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Thu, 22 Sep 2022 09:55:31 +0200 Subject: [PATCH 03/24] 3.6.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c0cbb83d..e3b239bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.5.0", + "version": "3.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 89d24402..6820b831 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.5.0", + "version": "3.6.0", "main": "index.js", "repository": "git@github.com:SuitestAutomation/suitest-js-api.git", "author": "Suitest ", From 91b37851dff7fb906267437abeccafe74ce738e8 Mon Sep 17 00:00:00 2001 From: Maxym Date: Fri, 18 Nov 2022 12:21:11 +0200 Subject: [PATCH 04/24] SUIT-19383 - new validation was added for string, positive numbers, but not 0. Validator strategy for 'repeat' was changed --- lib/composers/repeatComposer.js | 2 +- lib/constants/validationKeys.js | 1 + lib/validation/validators.js | 18 ++++++++++++++++-- lib/validation/validatorsMap.js | 3 +++ test/validation/validators.test.js | 11 +++++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/composers/repeatComposer.js b/lib/composers/repeatComposer.js index 0f7d0dfb..9d463668 100644 --- a/lib/composers/repeatComposer.js +++ b/lib/composers/repeatComposer.js @@ -8,7 +8,7 @@ const {invalidInputMessage} = require('../texts'); */ const repeatComposer = makeModifierComposer(composers.REPEAT, ['repeat'], (_, meta, value) => ({ ...meta, - repeat: validate(validators.ST_VAR_OR_POSITIVE_NUMBER, value, invalidInputMessage('repeat', 'Repeat')), + repeat: validate(validators.ST_VAR_OR_POSITIVE_NUMBER_NOT_NULL, value, invalidInputMessage('repeat', 'Repeat')), })); module.exports = repeatComposer; diff --git a/lib/constants/validationKeys.js b/lib/constants/validationKeys.js index 6e96d675..3374409e 100644 --- a/lib/constants/validationKeys.js +++ b/lib/constants/validationKeys.js @@ -4,6 +4,7 @@ const validationKeys = { NON_EMPTY_STRING: Symbol('nonEmptyString'), POSITIVE_NUMBER: Symbol('positiveNumber'), ST_VAR_OR_POSITIVE_NUMBER: Symbol('stVarOrPositiveNumber'), + ST_VAR_OR_POSITIVE_NUMBER_NOT_NULL: Symbol('stVarOrPositiveNumberNotNull'), ST_VAR_OR_NUMBER: Symbol('stVarOrNumber'), NON_EMPTY_STRING_OR_UNDEFINED: Symbol('nonEmptyStringOrUndefined'), NON_EMPTY_STRING_OR_NUll: Symbol('nonEmptyStringOrNull'), diff --git a/lib/validation/validators.js b/lib/validation/validators.js index 38a6493b..b5c2bd47 100644 --- a/lib/validation/validators.js +++ b/lib/validation/validators.js @@ -153,6 +153,14 @@ const validatePositiveNumber = (val, name) => { return val; }; +const validatePositiveNumberNotNull = (val, name) => { + if (!Number.isFinite(val) || val <= 0) { + throwError(name + ' should be positive number'); + } + + return val; +}; + const validateNumber = (val, name) => { if (!Number.isFinite(val)) { throwError(name + ' should be number'); @@ -161,11 +169,15 @@ const validateNumber = (val, name) => { return val; }; -const createStVarOrNumberValidator = (onlyPositiveNumber = false) => (val, name) => { +const createStVarOrNumberValidator = (onlyPositiveNumber = false, biggerThanNull = false) => (val, name) => { if (!['number', 'string'].includes(typeof val)) { throwError(name + ' should be suitest configuration variable or number'); } else if (typeof val === 'number') { - (onlyPositiveNumber ? validatePositiveNumber : validateNumber)(val, name); + if (onlyPositiveNumber && biggerThanNull) { + (validatePositiveNumberNotNull)(val, name); + } else { + (onlyPositiveNumber ? validatePositiveNumber : validateNumber)(val, name); + } } else if (typeof val === 'string' && !/^<%.+%>$/.test(val)) { throwError(name + ' should be suitest configuration variable'); } @@ -175,6 +187,7 @@ const createStVarOrNumberValidator = (onlyPositiveNumber = false) => (val, name) const validateStVarOrNumber = createStVarOrNumberValidator(); const validateStVarOrPositiveNumber = createStVarOrNumberValidator(true); +const validateStVarOrPositiveNumberNotNull = createStVarOrNumberValidator(true, true); const validateNonEmptyStringOrUndefined = (val, name) => { if (typeof val === 'string' && val.length || val === undefined) { @@ -292,5 +305,6 @@ module.exports = { validateNonEmptyArrayOfStrings, validateStVarOrNumber, validateStVarOrPositiveNumber, + validateStVarOrPositiveNumberNotNull, validateTapTypeAndDuration, }; diff --git a/lib/validation/validatorsMap.js b/lib/validation/validatorsMap.js index 1d7bf06e..ea687692 100644 --- a/lib/validation/validatorsMap.js +++ b/lib/validation/validatorsMap.js @@ -14,6 +14,9 @@ const validatorsMap = { [validationKeys.ST_VAR_OR_POSITIVE_NUMBER]: (value, text) => { return validators.validateStVarOrPositiveNumber(value, text); }, + [validationKeys.ST_VAR_OR_POSITIVE_NUMBER_NOT_NULL]: (value, text) => { + return validators.validateStVarOrPositiveNumberNotNull(value, text); + }, [validationKeys.ST_VAR_OR_NUMBER]: (value, text) => { return validators.validateStVarOrNumber(value, text); }, diff --git a/test/validation/validators.test.js b/test/validation/validators.test.js index 76579111..aac1c2d0 100644 --- a/test/validation/validators.test.js +++ b/test/validation/validators.test.js @@ -5,6 +5,7 @@ const { validateNonEmptyStringOrUndefined, validateStVarOrPositiveNumber, validateStVarOrNumber, + validateStVarOrPositiveNumberNotNull, } = require('../../lib/validation/validators'); const {validate, validators} = require('../../lib/validation'); const {testInputErrorSync} = require('../../lib/utils/testHelpers/testInputError'); @@ -51,6 +52,16 @@ describe('validators', () => { assert.throws(() => validateStVarOrPositiveNumber(NaN), /Error/); assert.throws(() => validateStVarOrPositiveNumber('10'), /Error/); }); + it('should validate vars or positive number, but not null', () => { + assert.strictEqual(validateStVarOrPositiveNumberNotNull(1), 1); + assert.strictEqual(validateStVarOrPositiveNumberNotNull('<%any var%>'), '<%any var%>'); + assert.throws(() => validateStVarOrPositiveNumberNotNull(0), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotNull(-1), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotNull(''), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotNull(null), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotNull(NaN), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotNull('10'), /Error/); + }); it('should validate vars or number', () => { assert.strictEqual(validateStVarOrNumber(0), 0); assert.strictEqual(validateStVarOrNumber(1), 1); From 3e05dc633ce6cb38c62f6b91c184e2e4c1239450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Wed, 14 Dec 2022 09:34:21 +0100 Subject: [PATCH 05/24] 3.6.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e3b239bc..df522457 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.6.0", + "version": "3.6.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6820b831..087773b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.6.0", + "version": "3.6.1", "main": "index.js", "repository": "git@github.com:SuitestAutomation/suitest-js-api.git", "author": "Suitest ", From 6ef57055a06c342331b534972d96b6e2ed4a82e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Thu, 15 Dec 2022 17:10:26 +0100 Subject: [PATCH 06/24] prevent parsing file with .json extension as ini file --- lib/testLauncher/composeConfig.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/testLauncher/composeConfig.js b/lib/testLauncher/composeConfig.js index 6033a98c..8b2db26c 100644 --- a/lib/testLauncher/composeConfig.js +++ b/lib/testLauncher/composeConfig.js @@ -70,6 +70,8 @@ function readConfigFile(filePath) { return ini.parse(fileContent); case '.js': return require(filePath); + case '.json': + return JSON.parse(fileContent); default: try { return JSON.parse(fileContent); From b5e88d12ffe800e804987b52ec0de5ecb99c8fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Wed, 14 Dec 2022 22:51:09 +0100 Subject: [PATCH 07/24] SUIT-19461 customer config can be in all supported formats --- lib/testLauncher/composeConfig.js | 6 +++--- lib/texts.js | 2 +- test/testLauncher/composeConfig.test.js | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/testLauncher/composeConfig.js b/lib/testLauncher/composeConfig.js index 8b2db26c..0b53dc50 100644 --- a/lib/testLauncher/composeConfig.js +++ b/lib/testLauncher/composeConfig.js @@ -212,14 +212,14 @@ function readRcConfig(pathToConfig) { } /** - * Read json config file provided by user. + * Read config file provided by user. * @param {string} path - path to config file * @throws {SuitestError} - * @returns {Object} - parsed json + * @returns {Object} - parsed config file */ function readUserConfig(path) { try { - return JSON.parse(fs.readFileSync(path)); + return readConfigFile(path); } catch (error) { throw new SuitestError(invalidUserConfig(path, error.message), error.code); } diff --git a/lib/texts.js b/lib/texts.js index 3b83df4e..9cffcc40 100644 --- a/lib/texts.js +++ b/lib/texts.js @@ -41,7 +41,7 @@ module.exports = { invalidInputMessage: (methodName, field) => `provided for .${methodName} function.` + (field ? ` ${field}` : ''), invalidConfigObj: () => 'provided for configuration object.', - invalidUserConfig: template`Failed to process config file '${0}'.\n\t${1}.\n\tMake sure path is correct and file is in valid json format.`, + invalidUserConfig: template`Failed to process config file '${0}'.\n\t${1}.\n\tMake sure path is correct and file is in valid format.`, circularDependencyError: (path) => `Circular dependency found on ${path} path.`, // WebSockets errors diff --git a/test/testLauncher/composeConfig.test.js b/test/testLauncher/composeConfig.test.js index c8c93d79..ee59e1ca 100644 --- a/test/testLauncher/composeConfig.test.js +++ b/test/testLauncher/composeConfig.test.js @@ -29,20 +29,32 @@ describe('testLauncher readUserConfig', () => { } }); + it('readUserConfig method should support other types of config files', () => { + // for test simplicity, only single format is used + sinon.stub(fs, 'readFileSync').returns('test: true'); + const expected = {test: true}; + + try { + assert.deepStrictEqual(readUserConfig('.file.yml'), expected, 'parsed successfully'); + } finally { + fs.readFileSync.restore(); + } + }); + it('readUserConfig method should throw correct errors', () => { assert.throws( () => readUserConfig(path.join('.', '__non-such-dir__', '__non-such-file__.json')), err => err.type === SuitestError.type, - 'falied to read file', + 'failed to read file', ); sinon.stub(fs, 'readFileSync').returns('invalid json'); try { assert.throws( - () => readUserConfig(''), + () => readUserConfig('file.json'), err => err.type === SuitestError.type, - 'falied to parse json', + 'failed to parse json', ); } finally { fs.readFileSync.restore(); From bda82adaa7cab5733baf0301f2644e9c9ab6eb68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Wed, 14 Dec 2022 22:55:35 +0100 Subject: [PATCH 08/24] move loop breaker to better place Check is closer to actual change of variable. --- lib/testLauncher/composeConfig.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/testLauncher/composeConfig.js b/lib/testLauncher/composeConfig.js index 0b53dc50..a092cc0d 100644 --- a/lib/testLauncher/composeConfig.js +++ b/lib/testLauncher/composeConfig.js @@ -172,9 +172,6 @@ function readRcConfig(pathToConfig) { .filter(defaultConfig => IS_WINDOWS ? defaultConfig.isGeneral : true); for (const defaultConfig of defaultConfigurations) { - if (mainConfigFilePath) { - break; - } if ( fs.existsSync(defaultConfig.path) && fs.lstatSync(defaultConfig.path).isDirectory() @@ -183,6 +180,9 @@ function readRcConfig(pathToConfig) { defaultConfig.deepSearch ? findConfigUpToRoot : findConfig)(defaultConfig.path, defaultConfig.filename); + if (mainConfigFilePath) { + break; + } } } } From 8b906c36fa6575eeff43df8cccdd95fa6b9956bb Mon Sep 17 00:00:00 2001 From: JeKachan Date: Wed, 21 Dec 2022 10:08:19 +0200 Subject: [PATCH 09/24] SUIT-19467 New keys added for android platform. --- lib/constants/keys.js | 5 +++++ typeDefinition/constants/Keys.d.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/constants/keys.js b/lib/constants/keys.js index 0bce42cf..4172f181 100644 --- a/lib/constants/keys.js +++ b/lib/constants/keys.js @@ -58,6 +58,11 @@ const KEY = { UP_ARROW: '[[Up arrow]]', SEARCH: '[[Search]]', DONE: '[[Done]]', + UP: '[[Up]]', + DOWN: '[[Down]]', + LEFT: '[[Left]]', + RIGHT: '[[Right]]', + OK: '[[Ok]]', }; Object.freeze(KEY); diff --git a/typeDefinition/constants/Keys.d.ts b/typeDefinition/constants/Keys.d.ts index 3481133c..24d0a186 100644 --- a/typeDefinition/constants/Keys.d.ts +++ b/typeDefinition/constants/Keys.d.ts @@ -57,4 +57,9 @@ export type Keys = { UP_ARROW: '[[Up arrow]]', SEARCH: '[[Search]]', DONE: '[[Done]]', + UP: '[[Up]]', + DOWN: '[[Down]]', + LEFT: '[[Left]]', + RIGHT: '[[Right]]', + OK: '[[Ok]]', } From eb475f9649b768515b1ac94ca650ee5d9d2d8274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Wed, 14 Dec 2022 23:37:45 +0100 Subject: [PATCH 10/24] SUIT-19461 --config-file is marked as deprecated and two additional options are introduced --- lib/testLauncher/commands/run.js | 11 +++++++++++ lib/testLauncher/composeConfig.js | 17 +++++++++++++++-- lib/validation/jsonSchemas.js | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/testLauncher/commands/run.js b/lib/testLauncher/commands/run.js index 0905fa3b..7436fc94 100644 --- a/lib/testLauncher/commands/run.js +++ b/lib/testLauncher/commands/run.js @@ -43,10 +43,21 @@ const builder = yargs => { describe: 'Will launch user command with --inspect-brk execArgv, used for debugging', global: false, }) + .option('override-config-file', { + describe: 'Specifies an additional config file which properties have precedence over properties in a standard configuration file.', + global: false, + type: 'string', + }) + .option('base-config-file', { + describe: 'Path to a config file to override standard configuration files. Standard configuration files are ignored.', + global: false, + type: 'string', + }) .option('config-file', { describe: texts.cliConfig(), global: false, type: 'string', + deprecate: 'Can have unexpected behaviour. Use --base-config-file or --override-config-file.', }) .option('default-timeout', { describe: texts.defaultTimeout(), diff --git a/lib/testLauncher/composeConfig.js b/lib/testLauncher/composeConfig.js index a092cc0d..21303005 100644 --- a/lib/testLauncher/composeConfig.js +++ b/lib/testLauncher/composeConfig.js @@ -160,6 +160,7 @@ function findConfigUpToRoot(pathToSearch, filename) { * Searches for 'extends' property for other config file and if presents merge them. * cli arguments are not parsed. * If file found, but json invalid, throw error. + * @param {string} [pathToConfig] expicit path to configuration file * @returns {Object} */ function readRcConfig(pathToConfig) { @@ -231,8 +232,20 @@ function readUserConfig(path) { * @returns {{ownArgs: Object, userCommandArgs: string[]}} */ const composeConfig = (argv) => { - const rcConfig = readRcConfig(argv.configFile); - const configFilePath = argv.configFile || rcConfig.configFile; + if (argv.configFile) { + console.warn('Warning: You are using deprecated argument --config-file. Please use --override-config-file or --base-config-file instead.'); + if (argv.baseConfigFile || argv.overrideConfigFile) { + throw new SuitestError('Combination of deprecated --config-file with either --base-config-file or --override-config-file is not allowed'); + } + } + const rcConfig = readRcConfig(argv.baseConfigFile || argv.configFile); + if (rcConfig.configFile) { + console.warn('Warning: You are using deprecated option configFile. Please use overrideConfigFile instead.'); + } + if ((argv.configFile || rcConfig.configFile) && (argv.baseConfigFile || argv.overrideConfigFile || rcConfig.overrideConfigFile)) { + throw new SuitestError('Combination of deprecated configFile with --base-config-file or --override-config-file or overrideConfigFile is not allowed'); + } + const configFilePath = argv.overrideConfigFile || rcConfig.overrideConfigFile || argv.configFile || rcConfig.configFile; const userConfig = configFilePath ? readUserConfig(configFilePath) : {}; const ownArgs = { diff --git a/lib/validation/jsonSchemas.js b/lib/validation/jsonSchemas.js index 34cdff52..99e66406 100644 --- a/lib/validation/jsonSchemas.js +++ b/lib/validation/jsonSchemas.js @@ -362,6 +362,7 @@ schemas[validationKeys.CONFIGURE] = { 'properties': { 'appConfigId': {'type': 'string'}, 'concurrency': {'type': 'number'}, + 'overrideConfigFile': {'type': 'string'}, 'configFile': {'type': 'string'}, 'deviceId': {'type': 'string'}, 'disallowCrashReports': {'type': 'boolean'}, From a9dda93320ce7cc1db9c6901b4c8be298682ddbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Thu, 15 Dec 2022 15:59:42 +0100 Subject: [PATCH 11/24] sanitize data passing to require to prevent unexpected issues When a file with the same relative path existed relative to __dirname and CWD, the file relative to __dirname was loaded instead of the file relative to CWD. --- lib/testLauncher/composeConfig.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/testLauncher/composeConfig.js b/lib/testLauncher/composeConfig.js index 21303005..90064fd2 100644 --- a/lib/testLauncher/composeConfig.js +++ b/lib/testLauncher/composeConfig.js @@ -58,9 +58,17 @@ const DEFAULT_PATHS = [ * @param {String} filePath path to file */ function readConfigFile(filePath) { + const extension = path.extname(filePath); + if (extension === '.js') { + if (!path.isAbsolute(filePath)) { + // ensure correct handling of relative paths, we want to prevent searching in __dirname + filePath = path.join(process.cwd(), filePath); + } + return require(filePath); + } const fileContent = fs.readFileSync(filePath, 'utf8'); - switch (path.extname(filePath)) { + switch (extension) { case '.yaml': case '.yml': return yaml.load(fileContent); @@ -68,8 +76,6 @@ function readConfigFile(filePath) { return JSON5.parse(fileContent); case '.ini': return ini.parse(fileContent); - case '.js': - return require(filePath); case '.json': return JSON.parse(fileContent); default: From 5741b7c6025e8fd65093f9963dc23a9c76c9ec40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Wed, 21 Dec 2022 22:58:20 +0100 Subject: [PATCH 12/24] fix circle ci tests which depends on package path --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 12cd4166..2b794158 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: # documented at https://circleci.com/docs/2.0/circleci-images/ # - image: circleci/mongo:3.4.4 - working_directory: ~/repo + working_directory: ~/suitest-js-api steps: - checkout From cb922c23f739ed85e5a162d7e758a6d445624b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Wed, 21 Dec 2022 22:59:58 +0100 Subject: [PATCH 13/24] modernize image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2b794158..ad6bd295 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ jobs: CC_TEST_REPORTER_ID: b8382b02e5d130520012123a7fcc97b478a6294991078cdabb721315bd2a9dd9 docker: # specify the version you desire here - - image: circleci/node:14 + - image: cimg/node:14 # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images From 215d3987ae65d530eb42ae3fed4a5ea318f02e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Wed, 21 Dec 2022 23:08:54 +0100 Subject: [PATCH 14/24] test multiple node versions --- .circleci/config.yml | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ad6bd295..e3c407d2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,25 +2,36 @@ # # Check https://circleci.com/docs/2.0/language-javascript/ for more details # -version: 2 +version: 2.1 + +executors: + node-14: + docker: + - image: cimg/node:14.21 + node-16: + docker: + - image: cimg/node:16.18 + node-18: + docker: + - image: cimg/node:18.12 + jobs: build: environment: CC_TEST_REPORTER_ID: b8382b02e5d130520012123a7fcc97b478a6294991078cdabb721315bd2a9dd9 - docker: - # specify the version you desire here - - image: cimg/node:14 - - # Specify service dependencies here if necessary - # CircleCI maintains a library of pre-built images - # documented at https://circleci.com/docs/2.0/circleci-images/ - # - image: circleci/mongo:3.4.4 working_directory: ~/suitest-js-api + parameters: + version: + type: string + executor: node-<< parameters.version >> + steps: - checkout + - run: node --version + - run: name: Install dependencies command: | @@ -46,3 +57,10 @@ jobs: name: Check TypeScript definitions command: | npm run test-definitions +workflows: + workflow: + jobs: + - build: + matrix: + parameters: + version: ["14", "16", "18"] From 96f7ac2b29b4568a66e0ed2af497e2b58222c220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Thu, 22 Dec 2022 12:30:49 +0100 Subject: [PATCH 15/24] proper report race condition in Queue test --- test/utils/Queue.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/Queue.test.js b/test/utils/Queue.test.js index 30776cc8..1ed69075 100644 --- a/test/utils/Queue.test.js +++ b/test/utils/Queue.test.js @@ -27,6 +27,6 @@ describe('Queue', function() { assert.ok(obj['0'] < obj['3'], 'last should finished latter then 1'); assert.ok(obj['1'] > obj['3'], '2 should finished latter then last'); done(); - }); + }).catch(done); }); }); From 91c46c1a86e405ff94240e118360a4610f7ad108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Thu, 22 Dec 2022 13:20:29 +0100 Subject: [PATCH 16/24] 3.7.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index df522457..3f2617ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.6.1", + "version": "3.7.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 087773b2..3e93cac9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.6.1", + "version": "3.7.0", "main": "index.js", "repository": "git@github.com:SuitestAutomation/suitest-js-api.git", "author": "Suitest ", From d1d2d1e93c5eb44edcdb9279dbf0526efacf4f54 Mon Sep 17 00:00:00 2001 From: Maxym Date: Fri, 23 Dec 2022 09:48:35 +0200 Subject: [PATCH 17/24] SUIT-19383 - ST_VAR_OR_POSITIVE_NUMBER_NOT_NULL was renamed to ST_VAR_OR_POSITIVE_NUMBER_NOT_ZERO --- lib/composers/repeatComposer.js | 2 +- lib/constants/validationKeys.js | 2 +- lib/validation/validatorsMap.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/composers/repeatComposer.js b/lib/composers/repeatComposer.js index 9d463668..501f87cf 100644 --- a/lib/composers/repeatComposer.js +++ b/lib/composers/repeatComposer.js @@ -8,7 +8,7 @@ const {invalidInputMessage} = require('../texts'); */ const repeatComposer = makeModifierComposer(composers.REPEAT, ['repeat'], (_, meta, value) => ({ ...meta, - repeat: validate(validators.ST_VAR_OR_POSITIVE_NUMBER_NOT_NULL, value, invalidInputMessage('repeat', 'Repeat')), + repeat: validate(validators.ST_VAR_OR_POSITIVE_NUMBER_NOT_ZERO, value, invalidInputMessage('repeat', 'Repeat')), })); module.exports = repeatComposer; diff --git a/lib/constants/validationKeys.js b/lib/constants/validationKeys.js index 3374409e..5adc0376 100644 --- a/lib/constants/validationKeys.js +++ b/lib/constants/validationKeys.js @@ -4,7 +4,7 @@ const validationKeys = { NON_EMPTY_STRING: Symbol('nonEmptyString'), POSITIVE_NUMBER: Symbol('positiveNumber'), ST_VAR_OR_POSITIVE_NUMBER: Symbol('stVarOrPositiveNumber'), - ST_VAR_OR_POSITIVE_NUMBER_NOT_NULL: Symbol('stVarOrPositiveNumberNotNull'), + ST_VAR_OR_POSITIVE_NUMBER_NOT_ZERO: Symbol('stVarOrPositiveNumberNotZero'), ST_VAR_OR_NUMBER: Symbol('stVarOrNumber'), NON_EMPTY_STRING_OR_UNDEFINED: Symbol('nonEmptyStringOrUndefined'), NON_EMPTY_STRING_OR_NUll: Symbol('nonEmptyStringOrNull'), diff --git a/lib/validation/validatorsMap.js b/lib/validation/validatorsMap.js index ea687692..6f373757 100644 --- a/lib/validation/validatorsMap.js +++ b/lib/validation/validatorsMap.js @@ -14,7 +14,7 @@ const validatorsMap = { [validationKeys.ST_VAR_OR_POSITIVE_NUMBER]: (value, text) => { return validators.validateStVarOrPositiveNumber(value, text); }, - [validationKeys.ST_VAR_OR_POSITIVE_NUMBER_NOT_NULL]: (value, text) => { + [validationKeys.ST_VAR_OR_POSITIVE_NUMBER_NOT_ZERO]: (value, text) => { return validators.validateStVarOrPositiveNumberNotNull(value, text); }, [validationKeys.ST_VAR_OR_NUMBER]: (value, text) => { From 45541b772d490b72bbc72c1fcc8dcf30b81c0efb Mon Sep 17 00:00:00 2001 From: Maxym Date: Fri, 23 Dec 2022 10:01:06 +0200 Subject: [PATCH 18/24] SUIT-19383 - naming changes. Null was changed to zero in some places --- lib/validation/validators.js | 12 ++++++------ lib/validation/validatorsMap.js | 2 +- test/validation/validators.test.js | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/validation/validators.js b/lib/validation/validators.js index b5c2bd47..d8c4ca6e 100644 --- a/lib/validation/validators.js +++ b/lib/validation/validators.js @@ -153,7 +153,7 @@ const validatePositiveNumber = (val, name) => { return val; }; -const validatePositiveNumberNotNull = (val, name) => { +const validatePositiveNumberNotZero = (val, name) => { if (!Number.isFinite(val) || val <= 0) { throwError(name + ' should be positive number'); } @@ -169,12 +169,12 @@ const validateNumber = (val, name) => { return val; }; -const createStVarOrNumberValidator = (onlyPositiveNumber = false, biggerThanNull = false) => (val, name) => { +const createStVarOrNumberValidator = (onlyPositiveNumber = false, biggerThanZero = false) => (val, name) => { if (!['number', 'string'].includes(typeof val)) { throwError(name + ' should be suitest configuration variable or number'); } else if (typeof val === 'number') { - if (onlyPositiveNumber && biggerThanNull) { - (validatePositiveNumberNotNull)(val, name); + if (onlyPositiveNumber && biggerThanZero) { + (validatePositiveNumberNotZero)(val, name); } else { (onlyPositiveNumber ? validatePositiveNumber : validateNumber)(val, name); } @@ -187,7 +187,7 @@ const createStVarOrNumberValidator = (onlyPositiveNumber = false, biggerThanNull const validateStVarOrNumber = createStVarOrNumberValidator(); const validateStVarOrPositiveNumber = createStVarOrNumberValidator(true); -const validateStVarOrPositiveNumberNotNull = createStVarOrNumberValidator(true, true); +const validateStVarOrPositiveNumberNotZero = createStVarOrNumberValidator(true, true); const validateNonEmptyStringOrUndefined = (val, name) => { if (typeof val === 'string' && val.length || val === undefined) { @@ -305,6 +305,6 @@ module.exports = { validateNonEmptyArrayOfStrings, validateStVarOrNumber, validateStVarOrPositiveNumber, - validateStVarOrPositiveNumberNotNull, + validateStVarOrPositiveNumberNotZero, validateTapTypeAndDuration, }; diff --git a/lib/validation/validatorsMap.js b/lib/validation/validatorsMap.js index 6f373757..d9a86c44 100644 --- a/lib/validation/validatorsMap.js +++ b/lib/validation/validatorsMap.js @@ -15,7 +15,7 @@ const validatorsMap = { return validators.validateStVarOrPositiveNumber(value, text); }, [validationKeys.ST_VAR_OR_POSITIVE_NUMBER_NOT_ZERO]: (value, text) => { - return validators.validateStVarOrPositiveNumberNotNull(value, text); + return validators.validateStVarOrPositiveNumberNotZero(value, text); }, [validationKeys.ST_VAR_OR_NUMBER]: (value, text) => { return validators.validateStVarOrNumber(value, text); diff --git a/test/validation/validators.test.js b/test/validation/validators.test.js index aac1c2d0..a56d3e44 100644 --- a/test/validation/validators.test.js +++ b/test/validation/validators.test.js @@ -5,7 +5,7 @@ const { validateNonEmptyStringOrUndefined, validateStVarOrPositiveNumber, validateStVarOrNumber, - validateStVarOrPositiveNumberNotNull, + validateStVarOrPositiveNumberNotZero, } = require('../../lib/validation/validators'); const {validate, validators} = require('../../lib/validation'); const {testInputErrorSync} = require('../../lib/utils/testHelpers/testInputError'); @@ -52,15 +52,15 @@ describe('validators', () => { assert.throws(() => validateStVarOrPositiveNumber(NaN), /Error/); assert.throws(() => validateStVarOrPositiveNumber('10'), /Error/); }); - it('should validate vars or positive number, but not null', () => { - assert.strictEqual(validateStVarOrPositiveNumberNotNull(1), 1); - assert.strictEqual(validateStVarOrPositiveNumberNotNull('<%any var%>'), '<%any var%>'); - assert.throws(() => validateStVarOrPositiveNumberNotNull(0), /Error/); - assert.throws(() => validateStVarOrPositiveNumberNotNull(-1), /Error/); - assert.throws(() => validateStVarOrPositiveNumberNotNull(''), /Error/); - assert.throws(() => validateStVarOrPositiveNumberNotNull(null), /Error/); - assert.throws(() => validateStVarOrPositiveNumberNotNull(NaN), /Error/); - assert.throws(() => validateStVarOrPositiveNumberNotNull('10'), /Error/); + it('should validate vars or positive number, but not zero', () => { + assert.strictEqual(validateStVarOrPositiveNumberNotZero(1), 1); + assert.strictEqual(validateStVarOrPositiveNumberNotZero('<%any var%>'), '<%any var%>'); + assert.throws(() => validateStVarOrPositiveNumberNotZero(0), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotZero(-1), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotZero(''), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotZero(null), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotZero(NaN), /Error/); + assert.throws(() => validateStVarOrPositiveNumberNotZero('10'), /Error/); }); it('should validate vars or number', () => { assert.strictEqual(validateStVarOrNumber(0), 0); From 6f9d49ade18bb3c41fec773245fb2dfd70c62168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Fri, 23 Dec 2022 19:13:05 +0100 Subject: [PATCH 19/24] 3.7.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f2617ca..c477eb85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.7.0", + "version": "3.7.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3e93cac9..fc34f078 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.7.0", + "version": "3.7.1", "main": "index.js", "repository": "git@github.com:SuitestAutomation/suitest-js-api.git", "author": "Suitest ", From e8808aae658d5ec2c1e232fbbbe97f0823377aed Mon Sep 17 00:00:00 2001 From: Maxym Date: Fri, 30 Dec 2022 13:11:01 +0200 Subject: [PATCH 20/24] SUIT-19484 - type definition for vars was added in ReplOptions --- typeDefinition/InteractiveCommandChain.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/typeDefinition/InteractiveCommandChain.d.ts b/typeDefinition/InteractiveCommandChain.d.ts index aac71720..ca5d0c8d 100644 --- a/typeDefinition/InteractiveCommandChain.d.ts +++ b/typeDefinition/InteractiveCommandChain.d.ts @@ -2,5 +2,8 @@ export type ReplOptions = { cwd?:string, repeater?: string|Function, watch?: string|Array, + vars?: { + [key: string]: any, + }, ignored?:string } From 743d51b12964f13f15ee5268058fdc55661044e6 Mon Sep 17 00:00:00 2001 From: Maxym Date: Fri, 6 Jan 2023 13:16:27 +0200 Subject: [PATCH 21/24] SUIT-19493 - refactoring and fixes for eslint warnings, typos --- config/index.js | 4 +- lib/composers/acceptModalComposer.js | 21 ++++++---- lib/composers/cloneComposer.js | 2 +- lib/composers/matchBrightScriptComposer.js | 2 +- lib/composers/matchRepoComposer.js | 25 ++++++----- lib/composers/requestMatchesComposer.js | 4 +- lib/composers/responseMatchesComposer.js | 6 +-- lib/composers/swipeComposer.js | 23 ++++++---- lib/composers/thenComposer.js | 2 +- .../{enviroment.js => environment.js} | 4 +- lib/constants/screenOrientation.js | 2 + lib/testLauncher/repl.js | 2 +- lib/utils/AuthContext.js | 2 +- lib/utils/chainUtils.js | 4 +- lib/utils/sessionStarter.js | 2 +- lib/utils/testLauncherHelper.js | 4 +- lib/validation/jsonSchemas.js | 42 +++++++++---------- lib/validation/validators.js | 4 +- test/testLauncher/repl.test.js | 16 +++---- test/utils/chainUtils.test.js | 12 +++--- 20 files changed, 99 insertions(+), 84 deletions(-) rename lib/constants/{enviroment.js => environment.js} (77%) diff --git a/config/index.js b/config/index.js index 6410bc44..7a10d70a 100644 --- a/config/index.js +++ b/config/index.js @@ -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:dd736ff3ac994104ab6635da53d9be2e@sentry.io/288812'; const DEFAULT_TIMEOUT = 2000; @@ -19,7 +19,7 @@ const DEFAULT_TIMEOUT = 2000; const overridableFields = [ 'tokenId', 'tokenPassword', 'concurrency', 'preset', 'presets', 'deviceId', 'appConfigId', 'inspect', 'inspectBrk', 'logLevel', 'logDir', 'timestamp', 'configFile', 'disallowCrashReports', 'defaultTimeout', 'screenshotDir', - 'includeChangelist', + 'includeChangeList', ]; const serverAddress = process.env[envVars.SUITEST_BE_SERVER] || 'the.suite.st'; diff --git a/lib/composers/acceptModalComposer.js b/lib/composers/acceptModalComposer.js index ad81e6f5..b2429113 100644 --- a/lib/composers/acceptModalComposer.js +++ b/lib/composers/acceptModalComposer.js @@ -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; diff --git a/lib/composers/cloneComposer.js b/lib/composers/cloneComposer.js index 3e58d37c..8fe2adf2 100644 --- a/lib/composers/cloneComposer.js +++ b/lib/composers/cloneComposer.js @@ -8,7 +8,7 @@ const cloneComposer = makeModifierComposer( composers.CLONE, ['clone'], (_, meta) => ({...meta}), - {unregisterParent: false} + {unregisterParent: false}, ); module.exports = cloneComposer; diff --git a/lib/composers/matchBrightScriptComposer.js b/lib/composers/matchBrightScriptComposer.js index 04184ce3..db9eb165 100644 --- a/lib/composers/matchBrightScriptComposer.js +++ b/lib/composers/matchBrightScriptComposer.js @@ -22,7 +22,7 @@ const matchBrightScriptComposer = makeModifierComposer( val: res, }, }; - } + }, ); module.exports = matchBrightScriptComposer; diff --git a/lib/composers/matchRepoComposer.js b/lib/composers/matchRepoComposer.js index ff5a4a77..a41a0239 100644 --- a/lib/composers/matchRepoComposer.js +++ b/lib/composers/matchRepoComposer.js @@ -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; diff --git a/lib/composers/requestMatchesComposer.js b/lib/composers/requestMatchesComposer.js index 63fbd440..0f6b9812 100644 --- a/lib/composers/requestMatchesComposer.js +++ b/lib/composers/requestMatchesComposer.js @@ -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( @@ -47,7 +47,7 @@ const requestMatchesComposer = makeModifierComposer( invalidInputMessage('requestMatch', 'Header'), ), }, - }) + }), ); module.exports = requestMatchesComposer; diff --git a/lib/composers/responseMatchesComposer.js b/lib/composers/responseMatchesComposer.js index ccd9a60b..7421a499 100644 --- a/lib/composers/responseMatchesComposer.js +++ b/lib/composers/responseMatchesComposer.js @@ -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( @@ -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; diff --git a/lib/composers/swipeComposer.js b/lib/composers/swipeComposer.js index dd53fbd5..2871a672 100644 --- a/lib/composers/swipeComposer.js +++ b/lib/composers/swipeComposer.js @@ -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; diff --git a/lib/composers/thenComposer.js b/lib/composers/thenComposer.js index ccbbcbf5..33e612cc 100644 --- a/lib/composers/thenComposer.js +++ b/lib/composers/thenComposer.js @@ -33,7 +33,7 @@ const makeThenComposer = (getSocketMessage, callback, beforeSend) => makeMethodC const {testId} = data; snippets = await fetchTestDefinitions({authContext})( - appId, versionId, testId, config.includeChangelist, data.stack); + appId, versionId, testId, config.includeChangeList, data.stack); } if (beforeSend) { diff --git a/lib/constants/enviroment.js b/lib/constants/environment.js similarity index 77% rename from lib/constants/enviroment.js rename to lib/constants/environment.js index e6eec53d..7aec2708 100644 --- a/lib/constants/enviroment.js +++ b/lib/constants/environment.js @@ -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 */ @@ -7,4 +7,4 @@ const ENVIROMENT_VARS = Object.freeze({ SUITEST_BE_SERVER: 'SUITEST_BE_SERVER', }); -module.exports = ENVIROMENT_VARS; +module.exports = ENVIRONMENT_VARS; diff --git a/lib/constants/screenOrientation.js b/lib/constants/screenOrientation.js index a75bc598..e33e5479 100644 --- a/lib/constants/screenOrientation.js +++ b/lib/constants/screenOrientation.js @@ -1,3 +1,5 @@ +/* eslint-disable key-spacing */ + const screenOrientation = { PORTRAIT: 'portrait', PORTRAIT_REVERSED: 'portraitReversed', diff --git a/lib/testLauncher/repl.js b/lib/testLauncher/repl.js index ef3c8f0b..b0d2795d 100644 --- a/lib/testLauncher/repl.js +++ b/lib/testLauncher/repl.js @@ -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'); diff --git a/lib/utils/AuthContext.js b/lib/utils/AuthContext.js index 1db20e27..2504d949 100644 --- a/lib/utils/AuthContext.js +++ b/lib/utils/AuthContext.js @@ -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}); diff --git a/lib/utils/chainUtils.js b/lib/utils/chainUtils.js index 6b1f85f4..5566fde7 100644 --- a/lib/utils/chainUtils.js +++ b/lib/utils/chainUtils.js @@ -281,7 +281,7 @@ const translateLineResult = (json, logLevel, lineResult) => { * @return {function} fetchTestDefinitions function */ -const fetchTestDefinitions = ({authContext}) => async(appId, versionId, mainTestId, includeChangelist, stack) => { +const fetchTestDefinitions = ({authContext}) => async(appId, versionId, mainTestId, includeChangeList, stack) => { const authedRequestObject = await authContext.authorizeHttp( endpoints.appTestDefinitionById, {method: 'GET'}, @@ -293,7 +293,7 @@ const fetchTestDefinitions = ({authContext}) => async(appId, versionId, mainTest const fetchSingleTest = async(testId) => { const {definition} = await request( [ - `${endpoints.appTestDefinitionById}?includeChangelist=${includeChangelist}`, + `${endpoints.appTestDefinitionById}?includeChangeList=${includeChangeList}`, {appId, versionId, testId}, ], authedRequestObject, diff --git a/lib/utils/sessionStarter.js b/lib/utils/sessionStarter.js index 259f5c0b..04d35798 100644 --- a/lib/utils/sessionStarter.js +++ b/lib/utils/sessionStarter.js @@ -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'); diff --git a/lib/utils/testLauncherHelper.js b/lib/utils/testLauncherHelper.js index fbb7ae51..261dd214 100644 --- a/lib/utils/testLauncherHelper.js +++ b/lib/utils/testLauncherHelper.js @@ -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'); @@ -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 */ diff --git a/lib/validation/jsonSchemas.js b/lib/validation/jsonSchemas.js index 99e66406..3a70be74 100644 --- a/lib/validation/jsonSchemas.js +++ b/lib/validation/jsonSchemas.js @@ -147,7 +147,7 @@ const deviation = { 'then': {'type': ['number', 'string']}, 'else': {'const': 'undefined'}, }; -const propComarator = { +const propComparator = { 'type': 'string', 'enum': Object.values(PROP_COMPARATOR), }; @@ -164,7 +164,7 @@ schemas[validationKeys.ELEMENT_PROPS] = { 'type': 'string', 'enum': Object.values(ELEMENT_PROP), }, - 'type': propComarator, + 'type': propComparator, 'val': {'const': VALUE.REPO}, deviation, }}, @@ -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, }}, @@ -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)}, }}, ], @@ -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, }, @@ -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, }}, ], }, @@ -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, }}, ], }, @@ -382,7 +382,7 @@ schemas[validationKeys.CONFIGURE] = { }, 'presets': {'type': 'object'}, 'screenshotDir': {'type': 'string'}, - 'includeChangelist': {'type': 'boolean'}, + 'includeChangeList': {'type': 'boolean'}, }, }; diff --git a/lib/validation/validators.js b/lib/validation/validators.js index d8c4ca6e..59adc30a 100644 --- a/lib/validation/validators.js +++ b/lib/validation/validators.js @@ -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 @@ -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) { diff --git a/test/testLauncher/repl.test.js b/test/testLauncher/repl.test.js index 5055b445..cbb65f61 100644 --- a/test/testLauncher/repl.test.js +++ b/test/testLauncher/repl.test.js @@ -5,7 +5,7 @@ const chokidar = require('chokidar'); const EventEmitter = require('events'); const logger = require('../../index').logger; -const envVars = require('../../lib/constants/enviroment'); +const envVars = require('../../lib/constants/environment'); const suitestRepl = require('../../lib/testLauncher/repl'); const ipcClient = require('../../lib/testLauncher/ipc/client'); @@ -60,11 +60,11 @@ describe('repl', () => { process.env[envVars.SUITEST_CHILD_PROCESS] = 'test'; - const replPromsie = suitestRepl.startRepl({}); + const replPromise = suitestRepl.startRepl({}); assert.ok(writeStub.calledOnce); assert.ok(addListenerStub.calledOnce); - assert.ok(replPromsie instanceof Promise); + assert.ok(replPromise instanceof Promise); delete process.env[envVars.SUITEST_CHILD_PROCESS]; }); @@ -73,11 +73,11 @@ describe('repl', () => { sandbox.stub(process, 'chdir'); const writeStub = sandbox.stub(ipcClient, 'write'); const addListenerStub = sandbox.stub(ipcClient, 'addListener'); - const replPromsie = suitestRepl.startRepl({}); + const replPromise = suitestRepl.startRepl({}); assert.ok(writeStub.notCalled); assert.ok(addListenerStub.notCalled); - assert.ok(replPromsie instanceof Promise); + assert.ok(replPromise instanceof Promise); }); it('stopRepl', () => { @@ -150,7 +150,7 @@ describe('repl', () => { repeaterFromString( 'repl#repeater', path.join(__dirname, '/../../lib/utils/testHelpers/'), - '' + '', )(); assert(repeater.called, 'Repeater with module spec was correctly resolved'); @@ -163,7 +163,7 @@ describe('repl', () => { repeaterFromString( 'repl#nested.repeater', path.join(__dirname, '/../../lib/utils/testHelpers/'), - '' + '', )(); assert(repeater.called, 'Nested repeater with module spec was correctly resolved'); @@ -171,7 +171,7 @@ describe('repl', () => { repeaterFromString( 'nested.repeater', path.join(__dirname, '/../../lib/utils/testHelpers/'), - 'repl.js' + 'repl.js', )(); assert(repeater.secondCall, 'Repeater without module name was correctly resolved'); diff --git a/test/utils/chainUtils.test.js b/test/utils/chainUtils.test.js index a5e257bd..7b03d9e6 100644 --- a/test/utils/chainUtils.test.js +++ b/test/utils/chainUtils.test.js @@ -50,7 +50,7 @@ describe('chainUtils', () => { nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, + `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'mainTestId'}, ])) .reply(200, {definition: [{lineId: '1', type: 'sleep', val: 1000}]}); @@ -74,13 +74,13 @@ describe('chainUtils', () => { nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, + `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'mainTestId'}, ])) .reply(200, {definition: [{lineId: '1', type: 'runSnippet', val: 'test2'}]}); nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, + `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'test2'}, ])) .reply(200, {definition: [{lineId: '1', type: 'sleep', val: 200}]}); @@ -109,7 +109,7 @@ describe('chainUtils', () => { nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, + `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'mainTestId'}, ])) .reply(404, 'not found'); @@ -125,13 +125,13 @@ describe('chainUtils', () => { nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, + `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'mainTestId'}, ])) .reply(200, {definition: [{lineId: '1', excluded: true, type: 'runSnippet', val: 'test2'}]}); nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, + `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'test2'}, ])) .reply(200, {definition: [{lineId: '1', type: 'sleep', val: 200}]}); From e668bd221b9385d959930f241816a17643b12cb8 Mon Sep 17 00:00:00 2001 From: Maxym Date: Thu, 12 Jan 2023 14:28:58 +0200 Subject: [PATCH 22/24] SUIT-19493 - includeChangelist renaming was reverted --- config/index.js | 2 +- lib/composers/thenComposer.js | 2 +- lib/utils/chainUtils.js | 4 ++-- lib/validation/jsonSchemas.js | 2 +- test/utils/chainUtils.test.js | 12 ++++++------ 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/index.js b/config/index.js index 7a10d70a..e755ba0d 100644 --- a/config/index.js +++ b/config/index.js @@ -19,7 +19,7 @@ const DEFAULT_TIMEOUT = 2000; const overridableFields = [ 'tokenId', 'tokenPassword', 'concurrency', 'preset', 'presets', 'deviceId', 'appConfigId', 'inspect', 'inspectBrk', 'logLevel', 'logDir', 'timestamp', 'configFile', 'disallowCrashReports', 'defaultTimeout', 'screenshotDir', - 'includeChangeList', + 'includeChangelist', ]; const serverAddress = process.env[envVars.SUITEST_BE_SERVER] || 'the.suite.st'; diff --git a/lib/composers/thenComposer.js b/lib/composers/thenComposer.js index 33e612cc..ccbbcbf5 100644 --- a/lib/composers/thenComposer.js +++ b/lib/composers/thenComposer.js @@ -33,7 +33,7 @@ const makeThenComposer = (getSocketMessage, callback, beforeSend) => makeMethodC const {testId} = data; snippets = await fetchTestDefinitions({authContext})( - appId, versionId, testId, config.includeChangeList, data.stack); + appId, versionId, testId, config.includeChangelist, data.stack); } if (beforeSend) { diff --git a/lib/utils/chainUtils.js b/lib/utils/chainUtils.js index 5566fde7..6b1f85f4 100644 --- a/lib/utils/chainUtils.js +++ b/lib/utils/chainUtils.js @@ -281,7 +281,7 @@ const translateLineResult = (json, logLevel, lineResult) => { * @return {function} fetchTestDefinitions function */ -const fetchTestDefinitions = ({authContext}) => async(appId, versionId, mainTestId, includeChangeList, stack) => { +const fetchTestDefinitions = ({authContext}) => async(appId, versionId, mainTestId, includeChangelist, stack) => { const authedRequestObject = await authContext.authorizeHttp( endpoints.appTestDefinitionById, {method: 'GET'}, @@ -293,7 +293,7 @@ const fetchTestDefinitions = ({authContext}) => async(appId, versionId, mainTest const fetchSingleTest = async(testId) => { const {definition} = await request( [ - `${endpoints.appTestDefinitionById}?includeChangeList=${includeChangeList}`, + `${endpoints.appTestDefinitionById}?includeChangelist=${includeChangelist}`, {appId, versionId, testId}, ], authedRequestObject, diff --git a/lib/validation/jsonSchemas.js b/lib/validation/jsonSchemas.js index 3a70be74..5adf7f82 100644 --- a/lib/validation/jsonSchemas.js +++ b/lib/validation/jsonSchemas.js @@ -382,7 +382,7 @@ schemas[validationKeys.CONFIGURE] = { }, 'presets': {'type': 'object'}, 'screenshotDir': {'type': 'string'}, - 'includeChangeList': {'type': 'boolean'}, + 'includeChangelist': {'type': 'boolean'}, }, }; diff --git a/test/utils/chainUtils.test.js b/test/utils/chainUtils.test.js index 7b03d9e6..a5e257bd 100644 --- a/test/utils/chainUtils.test.js +++ b/test/utils/chainUtils.test.js @@ -50,7 +50,7 @@ describe('chainUtils', () => { nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, + `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'mainTestId'}, ])) .reply(200, {definition: [{lineId: '1', type: 'sleep', val: 1000}]}); @@ -74,13 +74,13 @@ describe('chainUtils', () => { nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, + `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'mainTestId'}, ])) .reply(200, {definition: [{lineId: '1', type: 'runSnippet', val: 'test2'}]}); nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, + `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'test2'}, ])) .reply(200, {definition: [{lineId: '1', type: 'sleep', val: 200}]}); @@ -109,7 +109,7 @@ describe('chainUtils', () => { nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, + `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'mainTestId'}, ])) .reply(404, 'not found'); @@ -125,13 +125,13 @@ describe('chainUtils', () => { nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, + `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'mainTestId'}, ])) .reply(200, {definition: [{lineId: '1', excluded: true, type: 'runSnippet', val: 'test2'}]}); nock(config.apiUrl) .get(makeUrlFromArray([ - `${endpoints.appTestDefinitionById}?includeChangeList=${false}`, + `${endpoints.appTestDefinitionById}?includeChangelist=${false}`, {appId: 'appId', versionId: 'versionId', testId: 'test2'}, ])) .reply(200, {definition: [{lineId: '1', type: 'sleep', val: 200}]}); From 688b8597d606845ffeefc61acd1ea62fc28a4a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Fri, 13 Jan 2023 10:47:35 +0100 Subject: [PATCH 23/24] 3.7.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c477eb85..494df4e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.7.1", + "version": "3.7.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fc34f078..05911762 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "suitest-js-api", - "version": "3.7.1", + "version": "3.7.2", "main": "index.js", "repository": "git@github.com:SuitestAutomation/suitest-js-api.git", "author": "Suitest ", From dea32f861ab24474ea67032a8aade6e2b95c0f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Mon, 16 Jan 2023 13:56:44 +0100 Subject: [PATCH 24/24] publish other supported platforms and Vizio --- README.md | 6 ++++-- package.json | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d41051f2..95664e75 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ etc. - Locally installed Chrome, Firefox, Safari and Edge - Apple tvOS, iOS and iPadOS devices, including simulators - Roku +- Vizio Suitest supports automating end-to-end testing of: @@ -52,11 +53,12 @@ Suitest supports automating end-to-end testing of: - Samsung Orsay and Tizen apps - LG NetCast and webOS apps - HTML apps for other TV's or set-top boxes -- Android TV apps (including FireTV) -- tvOS apps +- Android TV and mobile apps (including FireTV) +- Apple TV (tvOS), iOS and iPadOS apps - Xbox One and Xbox Series S and X apps - PlayStation 4 / 5 apps - Roku apps +- Vizio SmartCast - Traditional websites and web apps for desktop browsers. ## Contributing diff --git a/package.json b/package.json index 05911762..fbda494c 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "Android TV testing", "Apple TV testing", "Roku testing", + "Vizio SmartCast testing", "Smart TV test automation", "Fire TV test automation" ],