@@ -201,6 +201,63 @@ describe('usePredictMarketData', () => {
201201 ) ;
202202 } ) ;
203203
204+ it ( 'filters child more-market cards without disabling pagination' , async ( ) => {
205+ const rawMarkets = Array . from ( { length : 20 } , ( _ , index ) => ( {
206+ ...mockMarketData [ 0 ] ,
207+ id : `market-${ index } ` ,
208+ slug : `market-${ index } ` ,
209+ parentMarketId : index >= 18 ? 'parent-market' : undefined ,
210+ } ) ) ;
211+ mockGetMarkets . mockResolvedValue ( rawMarkets ) ;
212+
213+ const { result } = renderHook ( ( ) => usePredictMarketData ( { pageSize : 20 } ) ) ;
214+
215+ await waitFor ( ( ) => {
216+ expect ( result . current . isFetching ) . toBe ( false ) ;
217+ } ) ;
218+
219+ expect ( result . current . marketData ) . toHaveLength ( 18 ) ;
220+ expect ( result . current . marketData . map ( ( market ) => market . id ) ) . toEqual (
221+ rawMarkets . slice ( 0 , 18 ) . map ( ( market ) => market . id ) ,
222+ ) ;
223+ expect ( result . current . hasMore ) . toBe ( true ) ;
224+ } ) ;
225+
226+ it ( 'uses raw page offsets when loading more after child cards are filtered' , async ( ) => {
227+ const firstRawPage = Array . from ( { length : 20 } , ( _ , index ) => ( {
228+ ...mockMarketData [ 0 ] ,
229+ id : `first-page-market-${ index } ` ,
230+ slug : `first-page-market-${ index } ` ,
231+ parentMarketId : index >= 18 ? 'parent-market' : undefined ,
232+ } ) ) ;
233+ const secondRawPage = Array . from ( { length : 5 } , ( _ , index ) => ( {
234+ ...mockMarketData [ 0 ] ,
235+ id : `second-page-market-${ index } ` ,
236+ slug : `second-page-market-${ index } ` ,
237+ } ) ) ;
238+
239+ mockGetMarkets
240+ . mockResolvedValueOnce ( firstRawPage )
241+ . mockResolvedValueOnce ( secondRawPage ) ;
242+
243+ const { result } = renderHook ( ( ) => usePredictMarketData ( { pageSize : 20 } ) ) ;
244+
245+ await waitFor ( ( ) => {
246+ expect ( result . current . isFetching ) . toBe ( false ) ;
247+ } ) ;
248+
249+ await act ( async ( ) => {
250+ await result . current . fetchMore ( ) ;
251+ } ) ;
252+
253+ expect ( mockGetMarkets ) . toHaveBeenNthCalledWith (
254+ 2 ,
255+ expect . objectContaining ( { limit : 20 , offset : 20 } ) ,
256+ ) ;
257+ expect ( result . current . marketData ) . toHaveLength ( 23 ) ;
258+ expect ( result . current . hasMore ) . toBe ( false ) ;
259+ } ) ;
260+
204261 it ( 'handle null market data' , async ( ) => {
205262 mockGetMarkets . mockResolvedValue ( null ) ;
206263
0 commit comments