@@ -363,4 +363,72 @@ describe('useAccountTabIndicatorStatus', () => {
363363 expect ( indicatorColor ) . toBe ( defaultTheme . success ) ;
364364 } ) ;
365365 } ) ;
366+
367+ describe ( 'card connection RBR logic' , ( ) => {
368+ beforeEach ( async ( ) => {
369+ await Onyx . clear ( ) ;
370+ await waitForBatchedUpdatesWithAct ( ) ;
371+ } ) ;
372+
373+ it ( 'shows error for third party card with broken connection' , async ( ) => {
374+ await act ( async ( ) => {
375+ await Onyx . multiSet ( {
376+ [ `${ ONYXKEYS . CARD_LIST } ` ] : {
377+ card1 : {
378+ bank : 'Chase' ,
379+ lastScrapeResult : 403 ,
380+ } ,
381+ } ,
382+ } as unknown as OnyxMultiSetInput ) ;
383+ await waitForBatchedUpdatesWithAct ( ) ;
384+ } ) ;
385+
386+ const { result} = renderHook ( ( ) => useAccountTabIndicatorStatus ( ) ) ;
387+ await waitForBatchedUpdatesWithAct ( ) ;
388+ const { status, indicatorColor} = result . current ;
389+
390+ expect ( status ) . toBe ( CONST . INDICATOR_STATUS . HAS_CARD_CONNECTION_ERROR ) ;
391+ expect ( indicatorColor ) . toBe ( defaultTheme . danger ) ;
392+ } ) ;
393+
394+ it ( 'does not show error for Expensify Card with broken connection' , async ( ) => {
395+ await act ( async ( ) => {
396+ await Onyx . multiSet ( {
397+ [ `${ ONYXKEYS . CARD_LIST } ` ] : {
398+ card1 : {
399+ bank : CONST . EXPENSIFY_CARD . BANK ,
400+ lastScrapeResult : 403 ,
401+ } ,
402+ } ,
403+ } as unknown as OnyxMultiSetInput ) ;
404+ await waitForBatchedUpdatesWithAct ( ) ;
405+ } ) ;
406+
407+ const { result} = renderHook ( ( ) => useAccountTabIndicatorStatus ( ) ) ;
408+ await waitForBatchedUpdatesWithAct ( ) ;
409+ const { status} = result . current ;
410+
411+ expect ( status ) . toBeUndefined ( ) ;
412+ } ) ;
413+
414+ it ( 'does not show error for third party card with good connection' , async ( ) => {
415+ await act ( async ( ) => {
416+ await Onyx . multiSet ( {
417+ [ `${ ONYXKEYS . CARD_LIST } ` ] : {
418+ card1 : {
419+ bank : 'Chase' ,
420+ lastScrapeResult : 200 ,
421+ } ,
422+ } ,
423+ } as unknown as OnyxMultiSetInput ) ;
424+ await waitForBatchedUpdatesWithAct ( ) ;
425+ } ) ;
426+
427+ const { result} = renderHook ( ( ) => useAccountTabIndicatorStatus ( ) ) ;
428+ await waitForBatchedUpdatesWithAct ( ) ;
429+ const { status} = result . current ;
430+
431+ expect ( status ) . toBeUndefined ( ) ;
432+ } ) ;
433+ } ) ;
366434} ) ;
0 commit comments