@@ -628,6 +628,8 @@ exports.isPositiveInteger = (str) => {
628
628
629
629
exports . isTrueString = value => ( ! this . isUndefined ( value ) && value . toString ( ) . toLowerCase ( ) === 'true' ) ;
630
630
631
+ exports . isUndefinedOrFalse = value => ( this . isUndefined ( value ) || value . toString ( ) . toLowerCase ( ) === 'false' ) ;
632
+
631
633
exports . isFloat = ( value ) => Number ( value ) && Number ( value ) % 1 !== 0 ;
632
634
633
635
exports . isInteger = ( value ) => Number . isInteger ( value ) ;
@@ -1077,7 +1079,8 @@ exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig) => {
1077
1079
if ( bsConfig . run_settings . cypressTestSuiteType === Constants . CYPRESS_V10_AND_ABOVE_TYPE ) {
1078
1080
defaultSpecFolder = Constants . DEFAULT_CYPRESS_10_SPEC_PATH
1079
1081
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 ) ) {
1081
1084
if ( ! this . isUndefined ( cypressConfig . e2e . specPattern ) ) {
1082
1085
globCypressConfigSpecPatterns = Array . isArray ( cypressConfig . e2e . specPattern ) ?
1083
1086
cypressConfig . e2e . specPattern : [ cypressConfig . e2e . specPattern ] ;
@@ -1286,6 +1289,24 @@ exports.setConfig = (bsConfig, args) => {
1286
1289
}
1287
1290
}
1288
1291
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
+
1289
1310
// blindly send other passed configs with run_settings and handle at backend
1290
1311
exports . setOtherConfigs = ( bsConfig , args ) => {
1291
1312
if ( isTestObservabilitySession ( ) && process . env . BS_TESTOPS_JWT ) {
@@ -1499,11 +1520,14 @@ exports.fetchFolderSize = async (dir) => {
1499
1520
}
1500
1521
}
1501
1522
1502
- exports . getVideoConfig = ( cypressConfig ) => {
1523
+ exports . getVideoConfig = ( cypressConfig , bsConfig = { } ) => {
1503
1524
let conf = {
1504
1525
video : true ,
1505
1526
videoUploadOnPasses : true
1506
1527
}
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 ;
1507
1531
if ( ! this . isUndefined ( cypressConfig . video ) ) conf . video = cypressConfig . video ;
1508
1532
if ( ! this . isUndefined ( cypressConfig . videoUploadOnPasses ) ) conf . videoUploadOnPasses = cypressConfig . videoUploadOnPasses ;
1509
1533
0 commit comments