@@ -219,6 +219,63 @@ describe('usePredictMarketData', () => {
219219 ) ;
220220 } ) ;
221221
222+ it ( 'filters child more-market cards without disabling pagination' , async ( ) => {
223+ const rawMarkets = Array . from ( { length : 20 } , ( _ , index ) => ( {
224+ ...mockMarketData [ 0 ] ,
225+ id : `market-${ index } ` ,
226+ slug : `market-${ index } ` ,
227+ parentMarketId : index >= 18 ? 'parent-market' : undefined ,
228+ } ) ) ;
229+ mockGetMarkets . mockResolvedValue ( rawMarkets ) ;
230+
231+ const { result } = renderHook ( ( ) => usePredictMarketData ( { pageSize : 20 } ) ) ;
232+
233+ await waitFor ( ( ) => {
234+ expect ( result . current . isFetching ) . toBe ( false ) ;
235+ } ) ;
236+
237+ expect ( result . current . marketData ) . toHaveLength ( 18 ) ;
238+ expect ( result . current . marketData . map ( ( market ) => market . id ) ) . toEqual (
239+ rawMarkets . slice ( 0 , 18 ) . map ( ( market ) => market . id ) ,
240+ ) ;
241+ expect ( result . current . hasMore ) . toBe ( true ) ;
242+ } ) ;
243+
244+ it ( 'uses raw page offsets when loading more after child cards are filtered' , async ( ) => {
245+ const firstRawPage = Array . from ( { length : 20 } , ( _ , index ) => ( {
246+ ...mockMarketData [ 0 ] ,
247+ id : `first-page-market-${ index } ` ,
248+ slug : `first-page-market-${ index } ` ,
249+ parentMarketId : index >= 18 ? 'parent-market' : undefined ,
250+ } ) ) ;
251+ const secondRawPage = Array . from ( { length : 5 } , ( _ , index ) => ( {
252+ ...mockMarketData [ 0 ] ,
253+ id : `second-page-market-${ index } ` ,
254+ slug : `second-page-market-${ index } ` ,
255+ } ) ) ;
256+
257+ mockGetMarkets
258+ . mockResolvedValueOnce ( firstRawPage )
259+ . mockResolvedValueOnce ( secondRawPage ) ;
260+
261+ const { result } = renderHook ( ( ) => usePredictMarketData ( { pageSize : 20 } ) ) ;
262+
263+ await waitFor ( ( ) => {
264+ expect ( result . current . isFetching ) . toBe ( false ) ;
265+ } ) ;
266+
267+ await act ( async ( ) => {
268+ await result . current . fetchMore ( ) ;
269+ } ) ;
270+
271+ expect ( mockGetMarkets ) . toHaveBeenNthCalledWith (
272+ 2 ,
273+ expect . objectContaining ( { limit : 20 , offset : 20 } ) ,
274+ ) ;
275+ expect ( result . current . marketData ) . toHaveLength ( 23 ) ;
276+ expect ( result . current . hasMore ) . toBe ( false ) ;
277+ } ) ;
278+
222279 it ( 'handle null market data' , async ( ) => {
223280 mockGetMarkets . mockResolvedValue ( null ) ;
224281
0 commit comments