@@ -539,18 +539,19 @@ describe('PredictFeed', () => {
539539 } ) ;
540540
541541 describe ( 'search error recovery' , ( ) => {
542- it ( 'shows the offline error state in the search overlay when all market fetch retries fail' , async ( ) => {
543- const getMarketsSpy = jest . spyOn (
542+ it ( 'shows the offline error state in the search overlay when all search retries fail' , async ( ) => {
543+ const searchMarketsSpy = jest . spyOn (
544544 Engine . context . PredictController ,
545- 'getMarkets ' ,
545+ 'searchMarkets ' ,
546546 ) ;
547- getMarketsSpy . mockRejectedValue ( new Error ( 'Network error' ) ) ;
547+ searchMarketsSpy . mockRejectedValue ( new Error ( 'Network error' ) ) ;
548548
549549 const { getByTestId, findByPlaceholderText, findByTestId } =
550550 renderPredictFeedView ( ) ;
551551
552552 fireEvent . press ( getByTestId ( PredictSearchSelectorsIDs . SEARCH_BUTTON ) ) ;
553- await findByPlaceholderText ( SEARCH_PLACEHOLDER ) ;
553+ const searchInput = await findByPlaceholderText ( SEARCH_PLACEHOLDER ) ;
554+ fireEvent . changeText ( searchInput , 'bitcoin' ) ;
554555
555556 // The hook retries up to 3 times with exponential backoff (~3-5 s total).
556557 // findByTestId waits until the error state appears after all retries exhaust.
@@ -562,42 +563,43 @@ describe('PredictFeed', () => {
562563 ) ,
563564 ) . toBeOnTheScreen ( ) ;
564565
565- getMarketsSpy . mockRestore ( ) ;
566+ searchMarketsSpy . mockRestore ( ) ;
566567 } ) ;
567568
568- it ( 'calls getMarkets again when the user presses Retry after an error' , async ( ) => {
569- const getMarketsSpy = jest . spyOn (
569+ it ( 'calls searchMarkets again when the user presses Retry after an error' , async ( ) => {
570+ const searchMarketsSpy = jest . spyOn (
570571 Engine . context . PredictController ,
571- 'getMarkets ' ,
572+ 'searchMarkets ' ,
572573 ) ;
573- getMarketsSpy . mockRejectedValue ( new Error ( 'Network error' ) ) ;
574+ searchMarketsSpy . mockRejectedValue ( new Error ( 'Network error' ) ) ;
574575
575576 const { getByTestId, findByPlaceholderText, findByTestId, findByText } =
576577 renderPredictFeedView ( ) ;
577578
578579 fireEvent . press ( getByTestId ( PredictSearchSelectorsIDs . SEARCH_BUTTON ) ) ;
579- await findByPlaceholderText ( SEARCH_PLACEHOLDER ) ;
580+ const searchInput = await findByPlaceholderText ( SEARCH_PLACEHOLDER ) ;
581+ fireEvent . changeText ( searchInput , 'bitcoin' ) ;
580582
581583 await findByTestId (
582584 PREDICT_OFFLINE_TEST_IDS . ERROR_STATE ,
583585 { } ,
584586 { timeout : 10000 } ,
585587 ) ;
586588
587- const callCountBeforeRetry = getMarketsSpy . mock . calls . length ;
589+ const callCountBeforeRetry = searchMarketsSpy . mock . calls . length ;
588590
589591 // Make subsequent calls succeed so the retry completes quickly.
590- getMarketsSpy . mockResolvedValue ( { markets : [ ] , nextCursor : null } ) ;
592+ searchMarketsSpy . mockResolvedValue ( [ ] ) ;
591593
592594 fireEvent . press ( await findByText ( 'Retry' ) ) ;
593595
594596 await waitFor ( ( ) => {
595- expect ( getMarketsSpy . mock . calls . length ) . toBeGreaterThan (
597+ expect ( searchMarketsSpy . mock . calls . length ) . toBeGreaterThan (
596598 callCountBeforeRetry ,
597599 ) ;
598600 } ) ;
599601
600- getMarketsSpy . mockRestore ( ) ;
602+ searchMarketsSpy . mockRestore ( ) ;
601603 } ) ;
602604 } ) ;
603605} ) ;
0 commit comments