@@ -402,6 +402,7 @@ t.test('progress', t => {
402402
403403 const flat = { }
404404
405+ // Test flatten function behavior
405406 mockDefs ( ) . progress . flatten ( 'progress' , { } , flat )
406407 t . strictSame ( flat , { progress : false } )
407408
@@ -417,6 +418,59 @@ t.test('progress', t => {
417418 mockDefs ( ) . progress . flatten ( 'progress' , { progress : true } , flat )
418419 t . strictSame ( flat , { progress : false } )
419420
421+ // Ensures consistency between default and flatOptions behavior
422+ t . test ( 'default value consistency' , t => {
423+ // Test case 1: Both TTYs, normal terminal, not CI
424+ setEnv ( { tty : true , term : 'xterm' } )
425+ const def1 = mockDefs ( { 'ci-info' : { isCI : false , name : null } } ) . progress
426+ t . equal ( def1 . default , true , 'default should be true when both TTYs, normal terminal, and not CI' )
427+
428+ // Test case 2: No TTYs, not CI
429+ setEnv ( { tty : false , term : 'xterm' } )
430+ const def2 = mockDefs ( { 'ci-info' : { isCI : false , name : null } } ) . progress
431+ t . equal ( def2 . default , false , 'default should be false when no TTYs' )
432+
433+ // Test case 3: Both TTYs but dumb terminal, not CI
434+ setEnv ( { tty : true , term : 'dumb' } )
435+ const def3 = mockDefs ( { 'ci-info' : { isCI : false , name : null } } ) . progress
436+ t . equal ( def3 . default , false , 'default should be false in dumb terminal' )
437+
438+ // Test case 4: Mixed TTY states, not CI
439+ mockGlobals ( t , {
440+ 'process.stderr.isTTY' : true ,
441+ 'process.stdout.isTTY' : false ,
442+ 'process.env.TERM' : 'xterm' ,
443+ } )
444+ const def4 = mockDefs ( { 'ci-info' : { isCI : false , name : null } } ) . progress
445+ t . equal ( def4 . default , false , 'default should be false when only one TTY' )
446+
447+ // Test case 5: Good TTY environment but in CI
448+ setEnv ( { tty : true , term : 'xterm' } )
449+ const def5 = mockDefs ( { 'ci-info' : { isCI : true , name : 'github-actions' } } ) . progress
450+ t . equal ( def5 . default , false , 'default should be false in CI even with good TTY environment' )
451+
452+ t . end ( )
453+ } )
454+
455+ // Test that flatten behavior is independent of CI detection
456+ t . test ( 'flatten function ignores CI detection' , t => {
457+ const flatObj = { }
458+
459+ // Test that CI doesn't affect flatten behavior when user explicitly enables
460+ setEnv ( { tty : true , term : 'xterm' } )
461+ const defsCI = mockDefs ( { 'ci-info' : { isCI : true , name : 'github-actions' } } )
462+ defsCI . progress . flatten ( 'progress' , { progress : true } , flatObj )
463+ t . equal ( flatObj . progress , true , 'flatten should enable progress in CI if user explicitly sets true and TTY is available' )
464+
465+ // Test that non-CI doesn't guarantee flatten success if TTY is bad
466+ setEnv ( { tty : false , term : 'xterm' } )
467+ const defsNoCI = mockDefs ( { 'ci-info' : { isCI : false , name : null } } )
468+ defsNoCI . progress . flatten ( 'progress' , { progress : true } , flatObj )
469+ t . equal ( flatObj . progress , false , 'flatten should disable progress outside CI if TTY is not available' )
470+
471+ t . end ( )
472+ } )
473+
420474 t . end ( )
421475} )
422476
0 commit comments