@@ -1113,29 +1113,36 @@ describe('RecordPickerDialog — renderGrid slot', () => {
11131113 expect ( screen . getByTestId ( 'custom-grid' ) ) . toBeInTheDocument ( ) ;
11141114 } ) ;
11151115
1116- // renderGrid should have been called with grid slot props
1117- expect ( renderGrid ) . toHaveBeenCalledWith (
1118- expect . objectContaining ( {
1119- columns : expect . arrayContaining ( [
1120- expect . objectContaining ( { field : 'name' } ) ,
1121- ] ) ,
1122- records : expect . arrayContaining ( [
1123- expect . objectContaining ( { id : '1' , name : 'Acme Corp' } ) ,
1124- ] ) ,
1125- loading : false ,
1126- totalCount : 1 ,
1127- currentPage : 1 ,
1128- pageSize : 10 ,
1129- sortField : null ,
1130- sortDirection : 'asc' ,
1131- onSort : expect . any ( Function ) ,
1132- onPageChange : expect . any ( Function ) ,
1133- onRowClick : expect . any ( Function ) ,
1134- isSelected : expect . any ( Function ) ,
1135- multiple : false ,
1136- idField : 'id' ,
1137- } ) ,
1138- ) ;
1116+ // Wait for data to load, then check the last renderGrid call has records
1117+ await waitFor ( ( ) => {
1118+ expect ( renderGrid ) . toHaveBeenLastCalledWith (
1119+ expect . objectContaining ( {
1120+ columns : expect . arrayContaining ( [
1121+ expect . objectContaining ( { field : 'name' } ) ,
1122+ ] ) ,
1123+ records : expect . arrayContaining ( [
1124+ expect . objectContaining ( { id : '1' , name : 'Acme Corp' } ) ,
1125+ ] ) ,
1126+ loading : false ,
1127+ totalCount : 1 ,
1128+ } ) ,
1129+ ) ;
1130+ } ) ;
1131+
1132+ // Verify all expected props are present in the last call
1133+ const lastCallArgs = renderGrid . mock . calls [ renderGrid . mock . calls . length - 1 ] [ 0 ] ;
1134+ expect ( lastCallArgs ) . toMatchObject ( {
1135+ currentPage : 1 ,
1136+ pageSize : 10 ,
1137+ sortField : null ,
1138+ sortDirection : 'asc' ,
1139+ multiple : false ,
1140+ idField : 'id' ,
1141+ } ) ;
1142+ expect ( lastCallArgs . onSort ) . toBeTypeOf ( 'function' ) ;
1143+ expect ( lastCallArgs . onPageChange ) . toBeTypeOf ( 'function' ) ;
1144+ expect ( lastCallArgs . onRowClick ) . toBeTypeOf ( 'function' ) ;
1145+ expect ( lastCallArgs . isSelected ) . toBeTypeOf ( 'function' ) ;
11391146 } ) ;
11401147
11411148 it ( 'hides built-in table when renderGrid is provided' , async ( ) => {
0 commit comments