@@ -552,6 +552,58 @@ describe('useUpdate', () => {
552552 } ) ;
553553 } ) ;
554554 } ) ;
555+ it ( 'updates getManyReference query cache with pageInfo when dataProvider promise resolves' , async ( ) => {
556+ const queryClient = new QueryClient ( ) ;
557+ queryClient . setQueryData ( [ 'foo' , 'getManyReference' ] , {
558+ data : [ { id : 1 , bar : 'bar' } ] ,
559+ pageInfo : {
560+ hasPreviousPage : false ,
561+ hasNextPage : true ,
562+ } ,
563+ } ) ;
564+ const dataProvider = {
565+ update : jest . fn ( ( ) =>
566+ Promise . resolve ( { data : { id : 1 , bar : 'baz' } } as any )
567+ ) ,
568+ } as any ;
569+ let localUpdate ;
570+ const Dummy = ( ) => {
571+ const [ update ] = useUpdate ( ) ;
572+ localUpdate = update ;
573+ return < span /> ;
574+ } ;
575+ render (
576+ < CoreAdminContext
577+ dataProvider = { dataProvider }
578+ queryClient = { queryClient }
579+ >
580+ < Dummy />
581+ </ CoreAdminContext >
582+ ) ;
583+ localUpdate ( 'foo' , {
584+ id : 1 ,
585+ data : { bar : 'baz' } ,
586+ previousData : { id : 1 , bar : 'bar' } ,
587+ } ) ;
588+ await waitFor ( ( ) => {
589+ expect ( dataProvider . update ) . toHaveBeenCalledWith ( 'foo' , {
590+ id : 1 ,
591+ data : { bar : 'baz' } ,
592+ previousData : { id : 1 , bar : 'bar' } ,
593+ } ) ;
594+ } ) ;
595+ await waitFor ( ( ) => {
596+ expect (
597+ queryClient . getQueryData ( [ 'foo' , 'getManyReference' ] )
598+ ) . toEqual ( {
599+ data : [ { id : 1 , bar : 'baz' } ] ,
600+ pageInfo : {
601+ hasPreviousPage : false ,
602+ hasNextPage : true ,
603+ } ,
604+ } ) ;
605+ } ) ;
606+ } ) ;
555607 it ( 'updates getInfiniteList query cache when dataProvider promise resolves' , async ( ) => {
556608 const queryClient = new QueryClient ( ) ;
557609 queryClient . setQueryData ( [ 'foo' , 'getInfiniteList' ] , {
0 commit comments