@@ -26,16 +26,16 @@ describe('Server-Side Filtering (on-demand mode)', () => {
2626 vi . restoreAllMocks ( )
2727 } )
2828
29- it ( 'should pass filter to PocketBase getList when .where() is present' , async ( ) => {
29+ it ( 'should pass filter to PocketBase getFullList when .where() is present' , async ( ) => {
3030 const booksCollection = createBooksCollection ( queryClient , { syncMode : 'on-demand' } )
3131
3232 // Get a valid genre to filter by
33- const allBooks = await pb . collection ( 'books' ) . getList ( 1 , 10 )
34- expect ( allBooks . items . length ) . toBeGreaterThan ( 0 )
35- const testGenre = allBooks . items [ 0 ] . genre
33+ const allBooks = await pb . collection ( 'books' ) . getFullList ( )
34+ expect ( allBooks . length ) . toBeGreaterThan ( 0 )
35+ const testGenre = allBooks [ 0 ] . genre
3636
37- // Spy on PocketBase getList to verify it's called with filter options
38- const getListSpy = vi . spyOn ( pb . collection ( 'books' ) , 'getList ' )
37+ // Spy on PocketBase getFullList to verify it's called with filter options
38+ const getFullListSpy = vi . spyOn ( pb . collection ( 'books' ) , 'getFullList ' )
3939
4040 const { result } = renderHook ( ( ) =>
4141 useLiveQuery ( ( q ) =>
@@ -52,36 +52,33 @@ describe('Server-Side Filtering (on-demand mode)', () => {
5252 { timeout : 10000 }
5353 )
5454
55- // Verify getList was called with filter parameter (server-side filtering)
56- expect ( getListSpy ) . toHaveBeenCalled ( )
55+ // Verify getFullList was called with filter parameter (server-side filtering)
56+ expect ( getFullListSpy ) . toHaveBeenCalled ( )
5757
5858 // Find the call with filter
59- const calls = getListSpy . mock . calls
59+ const calls = getFullListSpy . mock . calls
6060 const callWithFilter = calls . find ( call => {
61- const options = call [ 2 ]
61+ const options = call [ 0 ] as { filter ?: string } | undefined
6262 return options && typeof options === 'object' && 'filter' in options && options . filter
6363 } )
6464
6565 expect ( callWithFilter ) . toBeDefined ( )
6666
6767 // Verify the filter parameter was passed correctly
68- const [ page , perPage , options ] = callWithFilter !
69- expect ( page ) . toBe ( 1 )
70- expect ( perPage ) . toBe ( 500 ) // Default limit
71- expect ( options ?. filter ) . toBe ( `genre = "${ testGenre } "` )
68+ const [ options ] = callWithFilter !
69+ expect ( ( options as { filter ?: string } ) ?. filter ) . toBe ( `genre = "${ testGenre } "` )
7270
7371 // All returned records must match the filter
7472 result . current . data . forEach ( book => {
7573 expect ( book . genre ) . toBe ( testGenre )
7674 } )
7775 } , 15000 )
7876
79- it ( 'should pass limit to PocketBase getList when .limit() is present' , async ( ) => {
77+ // Note: TanStack DB does NOT pass limit to loadSubsetOptions - limiting is applied client-side.
78+ // This test verifies that client-side limiting works correctly.
79+ it ( 'should apply limit client-side when .limit() is present' , async ( ) => {
8080 const booksCollection = createBooksCollection ( queryClient , { syncMode : 'on-demand' } )
8181
82- // Spy on PocketBase getList
83- const getListSpy = vi . spyOn ( pb . collection ( 'books' ) , 'getList' )
84-
8582 const { result } = renderHook ( ( ) =>
8683 useLiveQuery ( ( q ) =>
8784 q . from ( { books : booksCollection } )
@@ -98,21 +95,7 @@ describe('Server-Side Filtering (on-demand mode)', () => {
9895 { timeout : 10000 }
9996 )
10097
101- // Verify getList was called
102- expect ( getListSpy ) . toHaveBeenCalled ( )
103-
104- // Find the call with limit=2 (perPage=2)
105- const calls = getListSpy . mock . calls
106- const callWithLimit = calls . find ( call => call [ 1 ] === 2 )
107-
108- expect ( callWithLimit ) . toBeDefined ( )
109-
110- // Verify the limit parameter was passed correctly
111- const [ page , perPage ] = callWithLimit !
112- expect ( page ) . toBe ( 1 )
113- expect ( perPage ) . toBe ( 2 ) // limit passed as perPage
114-
115- // Verify results respect the limit
98+ // Verify results respect the limit (client-side limiting)
11699 expect ( result . current . data . length ) . toBeLessThanOrEqual ( 2 )
117100 } , 15000 )
118101
@@ -161,9 +144,9 @@ describe('Server-Side Filtering (on-demand mode)', () => {
161144 const booksCollection = createBooksCollection ( queryClient , { syncMode : 'on-demand' } )
162145
163146 // Use a filter to trigger on-demand fetch
164- const allBooks = await pb . collection ( 'books' ) . getList ( 1 , 10 )
165- expect ( allBooks . items . length ) . toBeGreaterThan ( 0 )
166- const testGenre = allBooks . items [ 0 ] . genre
147+ const allBooks = await pb . collection ( 'books' ) . getFullList ( )
148+ expect ( allBooks . length ) . toBeGreaterThan ( 0 )
149+ const testGenre = allBooks [ 0 ] . genre
167150
168151 const { result } = renderHook ( ( ) =>
169152 useLiveQuery ( ( q ) =>
0 commit comments