@@ -598,4 +598,99 @@ describe('ListView', () => {
598598 expect ( screen . queryByTestId ( 'user-filters' ) ) . not . toBeInTheDocument ( ) ;
599599 } ) ;
600600 } ) ;
601+
602+ // ============================
603+ // Toolbar Toggle Visibility
604+ // ============================
605+ describe ( 'Toolbar Toggle Visibility' , ( ) => {
606+ it ( 'should hide Search button when showSearch is false' , ( ) => {
607+ const schema : ListViewSchema = {
608+ type : 'list-view' ,
609+ objectName : 'contacts' ,
610+ viewType : 'grid' ,
611+ fields : [ 'name' , 'email' ] ,
612+ showSearch : false ,
613+ } ;
614+
615+ renderWithProvider ( < ListView schema = { schema } /> ) ;
616+ expect ( screen . queryByRole ( 'button' , { name : / s e a r c h / i } ) ) . not . toBeInTheDocument ( ) ;
617+ } ) ;
618+
619+ it ( 'should show Search button when showSearch is true' , ( ) => {
620+ const schema : ListViewSchema = {
621+ type : 'list-view' ,
622+ objectName : 'contacts' ,
623+ viewType : 'grid' ,
624+ fields : [ 'name' , 'email' ] ,
625+ showSearch : true ,
626+ } ;
627+
628+ renderWithProvider ( < ListView schema = { schema } /> ) ;
629+ expect ( screen . getByRole ( 'button' , { name : / s e a r c h / i } ) ) . toBeInTheDocument ( ) ;
630+ } ) ;
631+
632+ it ( 'should show Search button when showSearch is undefined (default)' , ( ) => {
633+ const schema : ListViewSchema = {
634+ type : 'list-view' ,
635+ objectName : 'contacts' ,
636+ viewType : 'grid' ,
637+ fields : [ 'name' , 'email' ] ,
638+ } ;
639+
640+ renderWithProvider ( < ListView schema = { schema } /> ) ;
641+ expect ( screen . getByRole ( 'button' , { name : / s e a r c h / i } ) ) . toBeInTheDocument ( ) ;
642+ } ) ;
643+
644+ it ( 'should hide Filter button when showFilters is false' , ( ) => {
645+ const schema : ListViewSchema = {
646+ type : 'list-view' ,
647+ objectName : 'contacts' ,
648+ viewType : 'grid' ,
649+ fields : [ 'name' , 'email' ] ,
650+ showFilters : false ,
651+ } ;
652+
653+ renderWithProvider ( < ListView schema = { schema } /> ) ;
654+ expect ( screen . queryByRole ( 'button' , { name : / f i l t e r / i } ) ) . not . toBeInTheDocument ( ) ;
655+ } ) ;
656+
657+ it ( 'should show Filter button when showFilters is true' , ( ) => {
658+ const schema : ListViewSchema = {
659+ type : 'list-view' ,
660+ objectName : 'contacts' ,
661+ viewType : 'grid' ,
662+ fields : [ 'name' , 'email' ] ,
663+ showFilters : true ,
664+ } ;
665+
666+ renderWithProvider ( < ListView schema = { schema } /> ) ;
667+ expect ( screen . getByRole ( 'button' , { name : / f i l t e r / i } ) ) . toBeInTheDocument ( ) ;
668+ } ) ;
669+
670+ it ( 'should hide Sort button when showSort is false' , ( ) => {
671+ const schema : ListViewSchema = {
672+ type : 'list-view' ,
673+ objectName : 'contacts' ,
674+ viewType : 'grid' ,
675+ fields : [ 'name' , 'email' ] ,
676+ showSort : false ,
677+ } ;
678+
679+ renderWithProvider ( < ListView schema = { schema } /> ) ;
680+ expect ( screen . queryByRole ( 'button' , { name : / ^ s o r t $ / i } ) ) . not . toBeInTheDocument ( ) ;
681+ } ) ;
682+
683+ it ( 'should show Sort button when showSort is true' , ( ) => {
684+ const schema : ListViewSchema = {
685+ type : 'list-view' ,
686+ objectName : 'contacts' ,
687+ viewType : 'grid' ,
688+ fields : [ 'name' , 'email' ] ,
689+ showSort : true ,
690+ } ;
691+
692+ renderWithProvider ( < ListView schema = { schema } /> ) ;
693+ expect ( screen . getByRole ( 'button' , { name : / ^ s o r t $ / i } ) ) . toBeInTheDocument ( ) ;
694+ } ) ;
695+ } ) ;
601696} ) ;
0 commit comments