@@ -57,6 +57,7 @@ Module.prototype.require = function (id: string) {
5757
5858import CLIProgressManager from '../../src/progress-summary/cli-progress-manager' ;
5959import SummaryManager from '../../src/progress-summary/summary-manager' ;
60+ import { configHandler } from '../../src' ;
6061
6162// Optimized cleanup function for fast tests
6263function forceCleanupSpinners ( ) {
@@ -237,11 +238,34 @@ describe('CLIProgressManager', () => {
237238 } ) ;
238239
239240 // Note: Skipping actual withLoadingSpinner tests to avoid ora spinner issues in test environment
240- fancy . it ( 'should print global summary when exists' , ( ) => {
241+ fancy . it ( 'should print global summary when exists and showConsoleLogs is false ' , ( ) => {
241242 const summaryStub = sinon . stub ( SummaryManager . prototype , 'printFinalSummary' ) ;
242- CLIProgressManager . initializeGlobalSummary ( 'TEST' , '' ) ;
243- CLIProgressManager . printGlobalSummary ( ) ;
244- expect ( summaryStub . calledOnce ) . to . be . true ;
243+ const configGetStub = sinon . stub ( configHandler , 'get' ) . callThrough ( ) ;
244+ configGetStub . withArgs ( 'log' ) . returns ( { showConsoleLogs : false } ) ;
245+
246+ try {
247+ CLIProgressManager . initializeGlobalSummary ( 'TEST' , '' ) ;
248+ CLIProgressManager . printGlobalSummary ( ) ;
249+ expect ( summaryStub . calledOnce ) . to . be . true ;
250+ } finally {
251+ configGetStub . restore ( ) ;
252+ summaryStub . restore ( ) ;
253+ }
254+ } ) ;
255+
256+ fancy . it ( 'should skip global summary when showConsoleLogs is true (pure console log mode)' , ( ) => {
257+ const summaryStub = sinon . stub ( SummaryManager . prototype , 'printFinalSummary' ) ;
258+ const configGetStub = sinon . stub ( configHandler , 'get' ) . callThrough ( ) ;
259+ configGetStub . withArgs ( 'log' ) . returns ( { showConsoleLogs : true } ) ;
260+
261+ try {
262+ CLIProgressManager . initializeGlobalSummary ( 'SKIP_SUMMARY_TEST' , '' ) ;
263+ CLIProgressManager . printGlobalSummary ( ) ;
264+ expect ( summaryStub . called ) . to . be . false ;
265+ } finally {
266+ configGetStub . restore ( ) ;
267+ summaryStub . restore ( ) ;
268+ }
245269 } ) ;
246270 } ) ;
247271
@@ -412,30 +436,28 @@ describe('CLIProgressManager', () => {
412436 expect ( consoleLogStub . called ) . to . be . false ;
413437 } ) ;
414438
415- fancy . it ( 'should print summary on stop when showConsoleLogs is true' , ( ) => {
439+ fancy . it ( 'should not print Progress Manager summary when showConsoleLogs is true (pure console log mode) ' , ( ) => {
416440 progressManager . tick ( true , 'item1' ) ;
417441 progressManager . tick ( false , 'item2' , 'error' ) ;
418442 progressManager . stop ( ) ;
419443
420- expect ( consoleLogStub . called ) . to . be . true ;
421- // Check if summary content was logged
444+ // When showConsoleLogs is enabled, per-module summary blocks are skipped for consistent log output
422445 const logCalls = consoleLogStub . getCalls ( ) ;
423- const summaryCall = logCalls . find ( call =>
446+ const summaryCall = logCalls . find ( call =>
424447 call . args [ 0 ] && call . args [ 0 ] . includes ( 'TEST Summary:' )
425448 ) ;
426- expect ( summaryCall ) . to . not . be . undefined ;
427-
428- // Ensure progress manager is stopped
449+ expect ( summaryCall ) . to . be . undefined ;
450+
429451 progressManager = null as any ;
430452 } ) ;
431453
432- fancy . it ( 'should print detailed summary for nested progress ' , ( ) => {
454+ fancy . it ( 'should not print Detailed Summary blocks when showConsoleLogs is true (pure console log mode) ' , ( ) => {
433455 const nestedManager = new CLIProgressManager ( {
434456 showConsoleLogs : true ,
435457 enableNestedProgress : true ,
436458 moduleName : 'NESTED_TEST' ,
437459 } ) ;
438-
460+
439461 try {
440462 nestedManager . addProcess ( 'process1' , 5 ) ;
441463 nestedManager . startProcess ( 'process1' ) ;
@@ -444,14 +466,13 @@ describe('CLIProgressManager', () => {
444466 nestedManager . completeProcess ( 'process1' ) ;
445467 nestedManager . stop ( ) ;
446468
447- expect ( consoleLogStub . called ) . to . be . true ;
469+ // When showConsoleLogs is enabled, Detailed Summary blocks are skipped
448470 const logCalls = consoleLogStub . getCalls ( ) ;
449- const detailedSummaryCall = logCalls . find ( call =>
471+ const detailedSummaryCall = logCalls . find ( call =>
450472 call . args [ 0 ] && call . args [ 0 ] . includes ( 'NESTED_TEST Detailed Summary:' )
451473 ) ;
452- expect ( detailedSummaryCall ) . to . not . be . undefined ;
474+ expect ( detailedSummaryCall ) . to . be . undefined ;
453475 } finally {
454- // Ensure cleanup
455476 try {
456477 nestedManager . stop ( ) ;
457478 } catch ( e ) {
0 commit comments