@@ -325,6 +325,68 @@ describe('displayFlags', () => {
325325 expect ( plainTextOutput ) . not . toContain ( ' @aws-cdk/s3:anotherFlag' ) ;
326326 expect ( plainTextOutput ) . not . toContain ( ' @aws-cdk/core:anothermatchingFlag' ) ;
327327 } ) ;
328+
329+ test ( 'displays empty table message when all flags are set to recommended values' , async ( ) => {
330+ // Create test data where all flags are set to their recommended values
331+ const allRecommendedFlagsData : FeatureFlag [ ] = [
332+ {
333+ module : 'aws-cdk-lib' ,
334+ name : '@aws-cdk/core:flag1' ,
335+ recommendedValue : 'true' ,
336+ userValue : 'true' ,
337+ explanation : 'Flag 1 set to recommended value' ,
338+ } ,
339+ {
340+ module : 'aws-cdk-lib' ,
341+ name : '@aws-cdk/core:flag2' ,
342+ recommendedValue : 'false' ,
343+ userValue : 'false' ,
344+ explanation : 'Flag 2 set to recommended value' ,
345+ } ,
346+ ] ;
347+
348+ const params = {
349+ flagData : allRecommendedFlagsData ,
350+ toolkit : createMockToolkit ( ) ,
351+ ioHelper,
352+ // Not using --all, so it should filter to only show non-recommended flags
353+ } ;
354+ await displayFlags ( params ) ;
355+
356+ const plainTextOutput = output ( ) ;
357+ // Should still show the table headers for API consistency
358+ expect ( plainTextOutput ) . toContain ( 'Feature Flag Name' ) ;
359+ expect ( plainTextOutput ) . toContain ( 'Recommended Value' ) ;
360+ // Should show helpful message after the empty table
361+ expect ( plainTextOutput ) . toContain ( '✅ All feature flags are already set to their recommended values.' ) ;
362+ expect ( plainTextOutput ) . toContain ( 'Use \'cdk flags --all --unstable=flags\' to see all flags and their current values.' ) ;
363+ // Should not show the actual flag names since they're filtered out
364+ expect ( plainTextOutput ) . not . toContain ( ' @aws-cdk/core:flag1' ) ;
365+ expect ( plainTextOutput ) . not . toContain ( ' @aws-cdk/core:flag2' ) ;
366+ } ) ;
367+
368+ test ( 'does not show empty table message when some flags are not set to recommended values' , async ( ) => {
369+ // Use the original mockFlagsData which has mixed flag states
370+ // @aws -cdk/core:testFlag has userValue 'false' but recommendedValue 'true'
371+ // @aws -cdk/s3:anotherFlag has userValue undefined (not set to recommended)
372+ const params = {
373+ flagData : mockFlagsData ,
374+ toolkit : createMockToolkit ( ) ,
375+ ioHelper,
376+ // Not using --all, so it should show flags that need attention
377+ } ;
378+ await displayFlags ( params ) ;
379+
380+ const plainTextOutput = output ( ) ;
381+ // Should show the table with flags that need attention
382+ expect ( plainTextOutput ) . toContain ( 'Feature Flag Name' ) ;
383+ expect ( plainTextOutput ) . toContain ( 'Recommended Value' ) ;
384+ expect ( plainTextOutput ) . toContain ( ' @aws-cdk/core:testFlag' ) ;
385+ expect ( plainTextOutput ) . toContain ( ' @aws-cdk/s3:anotherFlag' ) ;
386+ // Should NOT show the helpful message since there are flags to display
387+ expect ( plainTextOutput ) . not . toContain ( '✅ All feature flags are already set to their recommended values.' ) ;
388+ expect ( plainTextOutput ) . not . toContain ( 'Use \'cdk flags --all --unstable=flags\' to see all flags and their current values.' ) ;
389+ } ) ;
328390} ) ;
329391
330392describe ( 'handleFlags' , ( ) => {
0 commit comments