@@ -628,6 +628,8 @@ exports.isPositiveInteger = (str) => {
628628
629629exports . isTrueString = value => ( ! this . isUndefined ( value ) && value . toString ( ) . toLowerCase ( ) === 'true' ) ;
630630
631+ exports . isUndefinedOrFalse = value => ( this . isUndefined ( value ) || value . toString ( ) . toLowerCase ( ) === 'false' ) ;
632+
631633exports . isFloat = ( value ) => Number ( value ) && Number ( value ) % 1 !== 0 ;
632634
633635exports . isInteger = ( value ) => Number . isInteger ( value ) ;
@@ -1077,7 +1079,8 @@ exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig) => {
10771079 if ( bsConfig . run_settings . cypressTestSuiteType === Constants . CYPRESS_V10_AND_ABOVE_TYPE ) {
10781080 defaultSpecFolder = Constants . DEFAULT_CYPRESS_10_SPEC_PATH
10791081 testFolderPath = defaultSpecFolder
1080- if ( ! this . isUndefined ( cypressConfig ) && ! this . isUndefined ( cypressConfig . e2e ) ) {
1082+ // Read cypress config if enforce_settings is not present
1083+ if ( this . isUndefinedOrFalse ( bsConfig . run_settings . enforce_settings ) && ! this . isUndefined ( cypressConfig ) && ! this . isUndefined ( cypressConfig . e2e ) ) {
10811084 if ( ! this . isUndefined ( cypressConfig . e2e . specPattern ) ) {
10821085 globCypressConfigSpecPatterns = Array . isArray ( cypressConfig . e2e . specPattern ) ?
10831086 cypressConfig . e2e . specPattern : [ cypressConfig . e2e . specPattern ] ;
@@ -1286,6 +1289,24 @@ exports.setConfig = (bsConfig, args) => {
12861289 }
12871290}
12881291
1292+ // set configs if enforce_settings is passed
1293+ exports . setEnforceSettingsConfig = ( bsConfig ) => {
1294+ let config_args = ( ! this . isUndefined ( bsConfig ) && ! this . isUndefined ( bsConfig . run_settings ) && ! this . isUndefined ( bsConfig . run_settings . config ) ) ? bsConfig . run_settings . config : undefined ;
1295+ if ( this . isUndefined ( config_args ) || ! config_args . includes ( "video" ) ) {
1296+ let video_args = ( this . isUndefined ( bsConfig . run_settings . video_config ) || this . isUndefined ( bsConfig . run_settings . video_config . video ) || ! bsConfig . run_settings . video_config . video ) ? 'video=false' : 'video=true' ;
1297+ video_args += ( this . isUndefined ( bsConfig . run_settings . video_config ) || this . isUndefined ( bsConfig . run_settings . video_config . videoUploadOnPasses ) || ! bsConfig . run_settings . video_config . videoUploadOnPasses ) ? ',videoUploadOnPasses=false' : ',videoUploadOnPasses=true' ;
1298+ config_args = this . isUndefined ( config_args ) ? video_args : config_args + ',' + video_args ;
1299+ logger . debug ( `Setting video_args for enforce_settings to ${ video_args } ` ) ;
1300+ }
1301+ if ( this . isUndefined ( config_args ) || ! config_args . includes ( "baseUrl" ) ) {
1302+ let base_url_args = ( ! this . isUndefined ( bsConfig ) && ! this . isUndefined ( bsConfig . run_settings ) && ! this . isUndefined ( bsConfig . run_settings . config ) ) ? "baseUrl='" + bsConfig . run_settings . baseUrl + "'" : "baseUrl=''" ;
1303+ config_args = this . isUndefined ( config_args ) ? base_url_args : config_args + ',' + base_url_args ;
1304+ logger . debug ( `Setting base_url_args for enforce_settings to ${ base_url_args } ` ) ;
1305+ }
1306+ if ( ! this . isUndefined ( config_args ) ) bsConfig [ "run_settings" ] [ "config" ] = config_args ;
1307+ logger . debug ( `Setting conifg_args for enforce_settings to ${ config_args } ` ) ;
1308+ }
1309+
12891310// blindly send other passed configs with run_settings and handle at backend
12901311exports . setOtherConfigs = ( bsConfig , args ) => {
12911312 if ( isTestObservabilitySession ( ) && process . env . BS_TESTOPS_JWT ) {
@@ -1499,11 +1520,14 @@ exports.fetchFolderSize = async (dir) => {
14991520 }
15001521}
15011522
1502- exports . getVideoConfig = ( cypressConfig ) => {
1523+ exports . getVideoConfig = ( cypressConfig , bsConfig = { } ) => {
15031524 let conf = {
15041525 video : true ,
15051526 videoUploadOnPasses : true
15061527 }
1528+ // Reading from bsconfig first to give precedance and cypress config will be empty in case of enforce_settings
1529+ if ( ! this . isUndefined ( bsConfig . run_settings . video ) ) conf . video = bsConfig . run_settings . video ;
1530+ if ( ! this . isUndefined ( bsConfig . run_settings . videoUploadOnPasses ) ) conf . videoUploadOnPasses = bsConfig . run_settings . videoUploadOnPasses ;
15071531 if ( ! this . isUndefined ( cypressConfig . video ) ) conf . video = cypressConfig . video ;
15081532 if ( ! this . isUndefined ( cypressConfig . videoUploadOnPasses ) ) conf . videoUploadOnPasses = cypressConfig . videoUploadOnPasses ;
15091533
0 commit comments