@@ -338,17 +338,43 @@ describe('openapi-format CLI command', () => {
338338 fs . unlinkSync ( outputPath ) ;
339339 } ) ;
340340
341- it . skip ( 'should generate a playground share URL ' , async ( ) => {
341+ it ( 'should handle -- playground in CI mode ' , async ( ) => {
342342 const path = `test/yaml-filter-custom` ;
343343 const inputFile = `${ path } /input.yaml` ;
344- const outputFile = `${ path } /output.yaml` ;
345- const output = await getLocalFile ( outputFile ) ;
346344 const setting = `${ path } /customFilter.yaml` ;
347345
348- let result = await testUtils . cli ( [ inputFile , `--filterFile ${ setting } ` , `--playground` ] , '.' ) ;
349- // console.log('result', result)
346+ let result = await testUtils . cli ( [ inputFile , `--filterFile ${ setting } ` , `--playground` ] , '.' , { CI : 'true' } ) ;
347+ expect ( result . code ) . toBe ( 0 ) ;
348+ expect ( result . stderr ) . toContain ( 'Running in CI/CD environment, no Share URL generated' ) ;
349+ } ) ;
350+
351+ it ( 'should handle -p in CI mode' , async ( ) => {
352+ const path = `test/yaml-filter-custom` ;
353+ const inputFile = `${ path } /input.yaml` ;
354+ const setting = `${ path } /customFilter.yaml` ;
355+
356+ let result = await testUtils . cli ( [ inputFile , `--filterFile ${ setting } ` , `-p` ] , '.' , { CI : 'true' } ) ;
350357 expect ( result . code ) . toBe ( 0 ) ;
351- expect ( result . stdout ) . toContain ( '🌐' ) ;
358+ expect ( result . stderr ) . toContain ( 'Running in CI/CD environment, no Share URL generated' ) ;
359+ } ) ;
360+
361+ it ( 'should handle playground share URL generation based on environment' , async ( ) => {
362+ const path = `test/yaml-filter-custom` ;
363+ const inputFile = `${ path } /input.yaml` ;
364+ const setting = `${ path } /customFilter.yaml` ;
365+ const args = [ inputFile , `--filterFile ${ setting } ` , `--playground` ] ;
366+
367+ console . log ( 'playground request args:' , args ) ;
368+ let result = await testUtils . cli ( args , '.' ) ;
369+ console . log ( 'playground response stdout:' , result . stdout ) ;
370+ console . log ( 'playground response stderr:' , result . stderr ) ;
371+ expect ( result . code ) . toBe ( 0 ) ;
372+ if ( process . env . CI ) {
373+ expect ( result . stderr ) . toContain ( 'Running in CI/CD environment, no Share URL generated' ) ;
374+ } else {
375+ expect ( result . stdout ) . toContain ( '🌐' ) ;
376+ expect ( result . stdout ) . toContain ( 'playground.openapi-format.com' ) ;
377+ }
352378 } ) ;
353379
354380 it ( 'should use the sortComponentsFile' , async ( ) => {
0 commit comments