@@ -573,4 +573,75 @@ describe('component: FleetClusters', () => {
573573 expect ( additionalSubRow . exists ( ) ) . toBe ( false ) ;
574574 } ) ;
575575 } ) ;
576+
577+ describe ( 'labels visibility regardless of error state' , ( ) => {
578+ it ( 'should pass sub-rows prop as true to ResourceTable so labels always render' , ( ) => {
579+ const wrapper = createWrapper ( ) ;
580+
581+ // sub-rows=true ensures SortableTable.showSubRow() returns true,
582+ // which makes the #additional-sub-row slot render regardless of stateDescription.
583+ // Without this, labels only appear when there is an error (stateDescription).
584+ const resourceTableStub = wrapper . findComponent ( '.resource-table' ) as any ;
585+
586+ expect ( resourceTableStub . props ( 'subRows' ) ) . toBe ( true ) ;
587+ } ) ;
588+
589+ it ( 'should render labels when cluster has no stateDescription (no error)' , ( ) => {
590+ const rows = [ {
591+ customLabels : [ 'env:prod' , 'team:backend' ] ,
592+ displayCustomLabels : false ,
593+ stateDescription : undefined ,
594+ } ] ;
595+
596+ const wrapper = createWrapper ( { rows } ) ;
597+ const tags = wrapper . findAll ( '.tag' ) ;
598+
599+ expect ( tags ) . toHaveLength ( 2 ) ;
600+ expect ( tags [ 0 ] . text ( ) ) . toBe ( 'env:prod' ) ;
601+ expect ( tags [ 1 ] . text ( ) ) . toBe ( 'team:backend' ) ;
602+ } ) ;
603+
604+ it ( 'should render labels when cluster has a stateDescription (error)' , ( ) => {
605+ const rows = [ {
606+ customLabels : [ 'env:prod' , 'team:backend' ] ,
607+ displayCustomLabels : false ,
608+ stateDescription : 'Something went wrong' ,
609+ } ] ;
610+
611+ const wrapper = createWrapper ( { rows } ) ;
612+ const tags = wrapper . findAll ( '.tag' ) ;
613+
614+ expect ( tags ) . toHaveLength ( 2 ) ;
615+ expect ( tags [ 0 ] . text ( ) ) . toBe ( 'env:prod' ) ;
616+ expect ( tags [ 1 ] . text ( ) ) . toBe ( 'team:backend' ) ;
617+ } ) ;
618+
619+ it ( 'should render labels when stateDescription is empty string' , ( ) => {
620+ const rows = [ {
621+ customLabels : [ 'env:staging' ] ,
622+ displayCustomLabels : false ,
623+ stateDescription : '' ,
624+ } ] ;
625+
626+ const wrapper = createWrapper ( { rows } ) ;
627+ const tags = wrapper . findAll ( '.tag' ) ;
628+
629+ expect ( tags ) . toHaveLength ( 1 ) ;
630+ expect ( tags [ 0 ] . text ( ) ) . toBe ( 'env:staging' ) ;
631+ } ) ;
632+
633+ it ( 'should render labels when stateDescription is null' , ( ) => {
634+ const rows = [ {
635+ customLabels : [ 'region:eu-west' ] ,
636+ displayCustomLabels : false ,
637+ stateDescription : null ,
638+ } ] ;
639+
640+ const wrapper = createWrapper ( { rows } ) ;
641+ const tags = wrapper . findAll ( '.tag' ) ;
642+
643+ expect ( tags ) . toHaveLength ( 1 ) ;
644+ expect ( tags [ 0 ] . text ( ) ) . toBe ( 'region:eu-west' ) ;
645+ } ) ;
646+ } ) ;
576647} ) ;
0 commit comments