Skip to content

Interactive session cypress #659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/commands/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ module.exports = function run(args, rawArgs) {
// set record feature caps
utils.setRecordCaps(bsConfig, args, cypressConfigFile);

// set the interactive debugging capability
utils.setInteractiveCapability(bsConfig);

// warn if specFiles cross our limit
utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs, buildReportData);
markBlockEnd('preArchiveSteps');
Expand Down
17 changes: 17 additions & 0 deletions bin/helpers/capabilityHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,23 @@ const validate = (bsConfig, args) => {
addCypressZipStartLocation(bsConfig.run_settings);
}

// check if Interactive Capabilities Caps passed is correct or not
if(!Utils.isUndefined(bsConfig.run_settings.interactive_debugging) && !Utils.isUndefined(bsConfig.run_settings.interactiveDebugging)) {
if(Utils.isConflictingBooleanValues(bsConfig.run_settings.interactive_debugging, bsConfig.run_settings.interactiveDebugging)) {
reject(Constants.userMessages.CYPRESS_INTERACTIVE_SESSION_CONFLICT_VALUES);
} else if(Utils.isNonBooleanValue(bsConfig.run_settings.interactive_debugging) && Utils.isNonBooleanValue(bsConfig.run_settings.interactiveDebugging)) {
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
}
} else if(!Utils.isUndefined(bsConfig.run_settings.interactive_debugging)) {
if(Utils.isNonBooleanValue(bsConfig.run_settings.interactive_debugging)) {
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
}
} else if(!Utils.isUndefined(bsConfig.run_settings.interactiveDebugging)) {
if(Utils.isNonBooleanValue(bsConfig.run_settings.interactiveDebugging)) {
logger.warn('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
}
}

// check if two config files are present at the same location
let cypressFileDirectory = path.dirname(path.resolve(bsConfig.run_settings.cypressConfigFilePath));
let listOfFiles = fs.readdirSync(cypressFileDirectory);
Expand Down
4 changes: 3 additions & 1 deletion bin/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ const userMessages = {
NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR:
"Unable to determine zip upload progress due to undefined/null connection request",
CYPRESS_PORT_WARNING:
"The requested port number <x> is ignored. The default BrowserStack port will be used for this execution"
"The requested port number <x> is ignored. The default BrowserStack port will be used for this execution",
CYPRESS_INTERACTIVE_SESSION_CONFLICT_VALUES:
"Conflicting values (True & False) were found for the interactive_debugging capability. Please resolve this issue to proceed further."
};

const validationMessages = {
Expand Down
18 changes: 18 additions & 0 deletions bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,24 @@ exports.setHeaded = (bsConfig, args) => {
logger.debug(`headless mode set to ${bsConfig.run_settings.headless}`);
};

exports.isConflictingBooleanValues = (value1, value2) => {
return (value1.toString() === "true" && value2.toString() === "false") || (value1.toString() === "false" && value2.toString() === "true")
};

exports.isNonBooleanValue = (value) => {
return value.toString() !== "true" && value.toString() !== "false";
};

exports.setInteractiveCapability = (bsConfig) => {
let interactiveDebuggingTemp = "true";
let interactive_debugging = bsConfig.run_settings.interactive_debugging;
let interactiveDebugging = bsConfig.run_settings.interactiveDebugging;
if(this.isNotUndefined(interactive_debugging) && !this.isNonBooleanValue(interactive_debugging)) interactiveDebuggingTemp = interactive_debugging;
else if(this.isNotUndefined(interactiveDebugging) && !this.isNonBooleanValue(interactiveDebugging)) interactiveDebuggingTemp = interactiveDebugging;
logger.debug(`Setting interactiveDebugging flag to ${interactiveDebuggingTemp}`);
bsConfig.run_settings.interactiveDebugging = interactiveDebuggingTemp;
}

exports.setNoWrap = (_bsConfig, args) => {
if (args.noWrap === true || this.searchForOption('--no-wrap')) {
process.env.SYNC_NO_WRAP = true;
Expand Down
89 changes: 89 additions & 0 deletions test/unit/bin/helpers/capabilityHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,95 @@ describe("capabilityHelper.js", () => {
});
});

describe("validate interactive caps debugging", () => {
let loggerWarningSpy;
beforeEach(() => {
loggerWarningSpy = sinon.stub(logger, 'warn').returns('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
});

afterEach(function() {
loggerWarningSpy.restore();
});
it("show the warning if interactive_debugging passed is a non boolean value", () => {
let bsConfig = {
auth: {},
browsers: [
{
browser: "chrome",
os: "Windows 10",
versions: ["78", "77"],
},
],
run_settings: {
cypress_proj_dir: "random path",
cypressConfigFilePath: "random path",
cypressProjectDir: "random path",
cypress_config_filename: "false",
interactive_debugging: "abc"
},
connection_settings: {}
}
return capabilityHelper
.validate(bsConfig, {})
.then(function (data) {
sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
});
});

it("show the warning if interactiveDebugging passed is a non boolean value", () => {
let bsConfig = {
auth: {},
browsers: [
{
browser: "chrome",
os: "Windows 10",
versions: ["78", "77"],
},
],
run_settings: {
cypress_proj_dir: "random path",
cypressConfigFilePath: "random path",
cypressProjectDir: "random path",
cypress_config_filename: "false",
interactiveDebugging: "abc"
},
connection_settings: {}
}
return capabilityHelper
.validate(bsConfig, {})
.then(function (data) {
sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
});
});

it("show the warning if both the interactive caps are non boolean", () => {
let bsConfig = {
auth: {},
browsers: [
{
browser: "chrome",
os: "Windows 10",
versions: ["78", "77"],
},
],
run_settings: {
cypress_proj_dir: "random path",
cypressConfigFilePath: "random path",
cypressProjectDir: "random path",
cypress_config_filename: "false",
interactiveDebugging: "def",
interactive_debugging: "abc"
},
connection_settings: {}
}
return capabilityHelper
.validate(bsConfig, {})
.then(function (data) {
sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
});
});
});

describe("validate home directory", () => {
beforeEach(() => {
bsConfig = {
Expand Down
121 changes: 121 additions & 0 deletions test/unit/bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3938,6 +3938,127 @@ describe('utils', () => {
});
});

describe('#isNonBooleanValue' , () => {
it('return true if value passed in empty string', () => {
expect(utils.isNonBooleanValue('')).to.be.eql(true);
});

it('return true if value passed is abc(non boolean)', () => {
expect(utils.isNonBooleanValue("abc")).to.be.eql(true);
});

it('return false if value passed is false(boolean)', () => {
expect(utils.isNonBooleanValue("false")).to.be.eql(false);
});

it('return false if value passed is true(boolean)', () => {
expect(utils.isNonBooleanValue(true)).to.be.eql(false);
});
});

describe('#isConflictingBooleanValues' , () => {
it('return false if value passed is true and true', () => {
expect(utils.isConflictingBooleanValues(true, true)).to.be.eql(false);
});

it('return false if value passed is false and "false"', () => {
expect(utils.isConflictingBooleanValues(false, "false")).to.be.eql(false);
});

it('return true if value passed is "true" and "false"', () => {
expect(utils.isConflictingBooleanValues("true", "false")).to.be.eql(true);
});

it('return true if value passed is true and "false"', () => {
expect(utils.isConflictingBooleanValues(true, "false")).to.be.eql(true);
});

it('return false if value passed is false and "true"', () => {
expect(utils.isConflictingBooleanValues(false, "true")).to.be.eql(true);
});

it('return false if value passed is false and "false"', () => {
expect(utils.isConflictingBooleanValues(false, "false")).to.be.eql(false);
});
});

describe('#setInteractiveCapability' , () => {
it('should set true if interactive caps is not passed', () => {
let bsConfig = {
run_settings: {}
}
let expectedResult = {
run_settings: {
interactiveDebugging: "true"
}
}
utils.setInteractiveCapability(bsConfig);
expect(bsConfig).to.be.eql(expectedResult);
});

it('should set true if interactiveDebugging caps passed is true', () => {
let bsConfig = {
run_settings: {
interactiveDebugging: true
}
}
let expectedResult = {
run_settings: {
interactiveDebugging: true
}
}
utils.setInteractiveCapability(bsConfig);
expect(bsConfig).to.be.eql(expectedResult);
});

it('should set true if interactive_debugging caps passed is true', () => {
let bsConfig = {
run_settings: {
interactive_debugging: true
}
}
let expectedResult = {
run_settings: {
interactive_debugging: true,
interactiveDebugging: true
}
}
utils.setInteractiveCapability(bsConfig);
expect(bsConfig).to.be.eql(expectedResult);
});

it('should set false if interactive_debugging caps passed is false', () => {
let bsConfig = {
run_settings: {
interactive_debugging: false
}
}
let expectedResult = {
run_settings: {
interactive_debugging: false,
interactiveDebugging: false
}
}
utils.setInteractiveCapability(bsConfig);
expect(bsConfig).to.be.eql(expectedResult);
});

it('should set false if interactiveDebugging caps passed is false', () => {
let bsConfig = {
run_settings: {
interactiveDebugging: false
}
}
let expectedResult = {
run_settings: {
interactiveDebugging: false
}
}
utils.setInteractiveCapability(bsConfig);
expect(bsConfig).to.be.eql(expectedResult);
});
});

describe('#setCypressNpmDependency', () => {

it('should set cypress as latest for cypress 10 test suite if cypress_version missing', () => {
Expand Down