Skip to content

Commit b45f5b1

Browse files
committed
added validations
1 parent 3bf7b0f commit b45f5b1

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

bin/helpers/capabilityHelper.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,23 @@ const validate = (bsConfig, args) => {
242242
addCypressZipStartLocation(bsConfig.run_settings);
243243
}
244244

245+
// check if Interactive Capabilities Caps passed is correct or not
246+
if(!Utils.isUndefined(bsConfig.run_settings.interactive_debugging) && !Utils.isUndefined(bsConfig.run_settings.interactiveDebugging)) {
247+
if(Utils.isConflictingBooleanValues(bsConfig.run_settings.interactive_debugging, bsConfig.run_settings.interactiveDebugging)) {
248+
reject(Constants.userMessages.CYPRESS_INTERACTIVE_SESSION_CONFLICT_VALUES);
249+
} else if(Utils.isNonBooleanValue(bsConfig.run_settings.interactive_debugging) && Utils.isNonBooleanValue(bsConfig.run_settings.interactiveDebugging)) {
250+
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
251+
}
252+
} else if(!Utils.isUndefined(bsConfig.run_settings.interactive_debugging)) {
253+
if(Utils.isNonBooleanValue(bsConfig.run_settings.interactive_debugging)) {
254+
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
255+
}
256+
} else if(!Utils.isUndefined(bsConfig.run_settings.interactiveDebugging)) {
257+
if(Utils.isNonBooleanValue(bsConfig.run_settings.interactiveDebugging)) {
258+
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
259+
}
260+
}
261+
245262
// check if two config files are present at the same location
246263
let cypressFileDirectory = path.dirname(path.resolve(bsConfig.run_settings.cypressConfigFilePath));
247264
let listOfFiles = fs.readdirSync(cypressFileDirectory);

bin/helpers/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ const userMessages = {
117117
NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR:
118118
"Unable to determine zip upload progress due to undefined/null connection request",
119119
CYPRESS_PORT_WARNING:
120-
"The requested port number <x> is ignored. The default BrowserStack port will be used for this execution"
120+
"The requested port number <x> is ignored. The default BrowserStack port will be used for this execution",
121+
CYPRESS_INTERACTIVE_SESSION_CONFLICT_VALUES:
122+
"Conflicting values (True & False) were found for the interactive_debugging capability. Please resolve this issue to proceed further."
121123
};
122124

123125
const validationMessages = {

bin/helpers/utils.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,16 +1000,22 @@ exports.setHeaded = (bsConfig, args) => {
10001000
logger.debug(`headless mode set to ${bsConfig.run_settings.headless}`);
10011001
};
10021002

1003+
exports.isConflictingBooleanValues = (value1, value2) => {
1004+
return (value1.toString() == "true" && value2.toString() == "false") || (value1.toString() == "false" && value2.toString() == "true")
1005+
};
1006+
1007+
exports.isNonBooleanValue = (value) => {
1008+
return value.toString() != "true" && value.toString() != "false";
1009+
};
1010+
10031011
exports.setInteractiveCapability = (bsConfig) => {
1004-
let interactiveDegugging = true;
1005-
if(bsConfig.interactive_debugging != undefined) {
1006-
interactiveDegugging = bsConfig.interactive_debugging;
1007-
}
1008-
if(bsConfig.interactiveDegugging != undefined) {
1009-
interactiveDegugging = bsConfig.interactiveDegugging;
1010-
}
1011-
console.log(`roshan1: the interactiveDegugging ${interactiveDegugging} ::`);
1012-
bsConfig.interactiveDegugging = interactiveDegugging;
1012+
let interactiveDebuggingTemp = "true";
1013+
let interactive_debugging = bsConfig.run_settings.interactive_debugging;
1014+
let interactiveDebugging = bsConfig.run_settings.interactiveDebugging;
1015+
if(!isNonBooleanValue(interactive_debugging)) interactiveDebuggingTemp = interactive_debugging;
1016+
else if(!isNonBooleanValue(interactiveDebugging)) interactiveDebuggingTemp = interactiveDebugging;
1017+
logger.debug(`Setting interactiveDebugging flag to ${interactiveDebuggingTemp}`);
1018+
bsConfig.run_settings.interactiveDebugging = interactiveDebuggingTemp;
10131019
}
10141020

10151021
exports.setNoWrap = (_bsConfig, args) => {

0 commit comments

Comments
 (0)