@@ -1973,4 +1973,61 @@ describe('ListView', () => {
19731973 expect ( shareButton ) . toHaveAttribute ( 'title' , 'Sharing: collaborative' ) ;
19741974 } ) ;
19751975 } ) ;
1976+
1977+ // ============================
1978+ // filterableFields whitelist
1979+ // ============================
1980+ describe ( 'filterableFields' , ( ) => {
1981+ it ( 'should render with filterableFields whitelist restricting available fields' , ( ) => {
1982+ const schema : ListViewSchema = {
1983+ type : 'list-view' ,
1984+ objectName : 'contacts' ,
1985+ viewType : 'grid' ,
1986+ fields : [
1987+ { name : 'name' , label : 'Name' , type : 'text' } ,
1988+ { name : 'email' , label : 'Email' , type : 'text' } ,
1989+ { name : 'phone' , label : 'Phone' , type : 'text' } ,
1990+ ] as any ,
1991+ filterableFields : [ 'name' , 'email' ] ,
1992+ } ;
1993+
1994+ renderWithProvider ( < ListView schema = { schema } /> ) ;
1995+ // Filter button should still be visible
1996+ const filterButton = screen . getByRole ( 'button' , { name : / f i l t e r / i } ) ;
1997+ expect ( filterButton ) . toBeInTheDocument ( ) ;
1998+ } ) ;
1999+
2000+ it ( 'should render filter button when filterableFields is not set' , ( ) => {
2001+ const schema : ListViewSchema = {
2002+ type : 'list-view' ,
2003+ objectName : 'contacts' ,
2004+ viewType : 'grid' ,
2005+ fields : [
2006+ { name : 'name' , label : 'Name' , type : 'text' } ,
2007+ { name : 'email' , label : 'Email' , type : 'text' } ,
2008+ ] as any ,
2009+ } ;
2010+
2011+ renderWithProvider ( < ListView schema = { schema } /> ) ;
2012+ const filterButton = screen . getByRole ( 'button' , { name : / f i l t e r / i } ) ;
2013+ expect ( filterButton ) . toBeInTheDocument ( ) ;
2014+ } ) ;
2015+
2016+ it ( 'should render filter button when filterableFields is empty array' , ( ) => {
2017+ const schema : ListViewSchema = {
2018+ type : 'list-view' ,
2019+ objectName : 'contacts' ,
2020+ viewType : 'grid' ,
2021+ fields : [
2022+ { name : 'name' , label : 'Name' , type : 'text' } ,
2023+ { name : 'email' , label : 'Email' , type : 'text' } ,
2024+ ] as any ,
2025+ filterableFields : [ ] ,
2026+ } ;
2027+
2028+ renderWithProvider ( < ListView schema = { schema } /> ) ;
2029+ const filterButton = screen . getByRole ( 'button' , { name : / f i l t e r / i } ) ;
2030+ expect ( filterButton ) . toBeInTheDocument ( ) ;
2031+ } ) ;
2032+ } ) ;
19762033} ) ;
0 commit comments