diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 923808d7..e7aff508 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -96,6 +96,8 @@ module.exports = function run(args, rawArgs) { //get the number of spec files let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressJson); + bsConfig['run_settings']['video_config'] = utils.getVideoConfig(cypressJson); + // return the number of parallels user specified let userSpecifiedParallels = utils.getParallels(bsConfig, args); diff --git a/bin/helpers/utils.js b/bin/helpers/utils.js index db27dd28..b0cc5376 100644 --- a/bin/helpers/utils.js +++ b/bin/helpers/utils.js @@ -1053,3 +1053,14 @@ exports.fetchZipSize = (fileName) => { return 0; } } + +exports.getVideoConfig = (cypressJson) => { + let conf = { + video: true, + videoUploadOnPasses: true + } + if (!this.isUndefined(cypressJson.video)) conf.video = cypressJson.video; + if (!this.isUndefined(cypressJson.videoUploadOnPasses)) conf.videoUploadOnPasses = cypressJson.videoUploadOnPasses; + + return conf; +} diff --git a/test/unit/bin/commands/runs.js b/test/unit/bin/commands/runs.js index 7f29dc42..ba62a9b6 100644 --- a/test/unit/bin/commands/runs.js +++ b/test/unit/bin/commands/runs.js @@ -249,6 +249,7 @@ describe("runs", () => { setBrowsersStub = sandbox.stub(); setConfigStub = sandbox.stub(); setCLIModeStub = sandbox.stub(); + getVideoConfigStub = sandbox.stub(); }); afterEach(() => { @@ -290,7 +291,8 @@ describe("runs", () => { setSystemEnvs: setSystemEnvsStub, setBrowsers: setBrowsersStub, setConfig: setConfigStub, - setCLIMode: setCLIModeStub + setCLIMode: setCLIModeStub, + getVideoConfig: getVideoConfigStub, }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub, @@ -339,6 +341,7 @@ describe("runs", () => { sinon.assert.calledOnce(setHeadedStub); sinon.assert.calledOnce(setNoWrapStub); sinon.assert.calledOnce(setCLIModeStub); + sinon.assert.calledOnce(getVideoConfigStub); sinon.assert.calledOnce(setOtherConfigsStub); sinon.assert.calledOnce(validateBstackJsonStub); sinon.assert.calledOnce(capabilityValidatorStub); @@ -405,6 +408,7 @@ describe("runs", () => { setBrowsersStub = sandbox.stub(); setCLIModeStub = sandbox.stub(); fetchZipSizeStub = sandbox.stub(); + getVideoConfigStub = sandbox.stub(); }); afterEach(() => { @@ -448,6 +452,7 @@ describe("runs", () => { setConfig: setConfigStub, setCLIMode: setCLIModeStub, fetchZipSize: fetchZipSizeStub, + getVideoConfig: getVideoConfigStub, }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub, @@ -487,6 +492,7 @@ describe("runs", () => { sinon.assert.calledOnce(getConfigPathStub); sinon.assert.calledOnce(getConfigPathStub); sinon.assert.calledTwice(fetchZipSizeStub); + sinon.assert.calledOnce(getVideoConfigStub); sinon.assert.calledOnce(setLocalModeStub); sinon.assert.calledOnce(setLocalConfigFileStub); sinon.assert.calledOnce(getNumberOfSpecFilesStub); @@ -569,6 +575,7 @@ describe("runs", () => { setBrowsersStub = sandbox.stub(); setCLIModeStub = sandbox.stub(); fetchZipSizeStub = sandbox.stub(); + getVideoConfigStub = sandbox.stub(); }); afterEach(() => { @@ -613,6 +620,7 @@ describe("runs", () => { setConfig: setConfigStub, setCLIMode: setCLIModeStub, fetchZipSize: fetchZipSizeStub, + getVideoConfig: getVideoConfigStub, }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub, @@ -659,6 +667,7 @@ describe("runs", () => { sinon.assert.calledOnce(getConfigPathStub); sinon.assert.calledOnce(getConfigPathStub); sinon.assert.calledTwice(fetchZipSizeStub); + sinon.assert.calledOnce(getVideoConfigStub); sinon.assert.calledOnce(setLocalConfigFileStub); sinon.assert.calledOnce(setLocalModeStub); sinon.assert.calledOnce(setupLocalTestingStub); @@ -759,6 +768,7 @@ describe("runs", () => { setCLIModeStub = sandbox.stub(); setProcessHooksStub = sandbox.stub(); fetchZipSizeStub = sandbox.stub(); + getVideoConfigStub = sandbox.stub(); }); afterEach(() => { @@ -771,7 +781,7 @@ describe("runs", () => { let errorCode = null; let message = `Success! ${Constants.userMessages.BUILD_CREATED} with build id: random_build_id`; let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${dashboardUrl}`; - let data = { user_id: 1234, parallels: 10, time_components: {}, unique_id: 'random_hash', package_error: 'test', checkmd5_error: 'test', build_id: 'random_build_id', test_zip_size: 123, npm_zip_size: 123} + let data = { user_id: 1234, parallels: 10, time_components: {}, unique_id: 'random_hash', package_error: 'test', checkmd5_error: 'test', build_id: 'random_build_id', test_zip_size: 123, npm_zip_size: 123, test_suite_zip_upload: 1, package_zip_upload: 1} const runs = proxyquire('../../../../bin/commands/runs', { '../helpers/utils': { @@ -811,6 +821,7 @@ describe("runs", () => { setCLIMode: setCLIModeStub, setProcessHooks: setProcessHooksStub, fetchZipSize: fetchZipSizeStub, + getVideoConfig: getVideoConfigStub, }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub, @@ -880,6 +891,7 @@ describe("runs", () => { sinon.assert.calledOnce(setParallelsStub); sinon.assert.calledOnce(warnSpecLimitStub); sinon.assert.calledTwice(fetchZipSizeStub); + sinon.assert.calledOnce(getVideoConfigStub); sinon.assert.calledOnce(setLocalStub); sinon.assert.calledOnce(setLocalModeStub); sinon.assert.calledOnce(setupLocalTestingStub); diff --git a/test/unit/bin/helpers/utils.js b/test/unit/bin/helpers/utils.js index 797136df..1d2699f6 100644 --- a/test/unit/bin/helpers/utils.js +++ b/test/unit/bin/helpers/utils.js @@ -2763,4 +2763,17 @@ describe('utils', () => { expect(utils.fetchZipSize('unknown.tar.gz')).to.be.eql(0); }); }); + + describe('getVideoConfig', () => { + it('should return default hash if no config is passed by the user', () => { + expect(utils.getVideoConfig({})).to.be.eql({video: true, videoUploadOnPasses: true}); + expect(utils.getVideoConfig({reporter: "mochawesome"})).to.be.eql({video: true, videoUploadOnPasses: true}); + }); + + it('should replace video config as passed by the user', () => { + expect(utils.getVideoConfig({video: false})).to.be.eql({video: false, videoUploadOnPasses: true}); + expect(utils.getVideoConfig({videoUploadOnPasses: false})).to.be.eql({video: true, videoUploadOnPasses: false}); + expect(utils.getVideoConfig({video: false, videoUploadOnPasses: false})).to.be.eql({video: false, videoUploadOnPasses: false}); + }); + }); });