@@ -737,6 +737,54 @@ describe('EarnLendingBalance', () => {
737737 expect ( queryByTestId ( EARN_EMPTY_STATE_CTA_TEST_ID ) ) . toBeNull ( ) ;
738738 } ) ;
739739
740+ it ( 'updates user state when close button is pressed on mUSD CTA' , async ( ) => {
741+ (
742+ selectStablecoinLendingEnabledFlag as jest . MockedFunction <
743+ typeof selectStablecoinLendingEnabledFlag
744+ >
745+ ) . mockReturnValue ( false ) ;
746+
747+ (
748+ selectIsMusdConversionFlowEnabledFlag as jest . MockedFunction <
749+ typeof selectIsMusdConversionFlowEnabledFlag
750+ >
751+ ) . mockReturnValue ( true ) ;
752+
753+ (
754+ useMusdConversionTokens as jest . MockedFunction <
755+ typeof useMusdConversionTokens
756+ >
757+ ) . mockReturnValue ( {
758+ isConversionToken : jest . fn ( ) . mockReturnValue ( true ) ,
759+ filterAllowedTokens : jest . fn ( ) . mockReturnValue ( [ ] ) ,
760+ isMusdSupportedOnChain : jest . fn ( ) . mockReturnValue ( true ) ,
761+ getMusdOutputChainId : jest . fn ( ) . mockReturnValue ( '0x1' ) ,
762+ tokens : [ ] ,
763+ } ) ;
764+
765+ mockShouldShowAssetOverviewCta . mockReturnValue ( true ) ;
766+
767+ const { getByTestId, store } = renderWithProvider (
768+ < EarnLendingBalance asset = { mockDaiMainnet } /> ,
769+ { state : mockInitialState } ,
770+ ) ;
771+
772+ const closeButton = getByTestId (
773+ EARN_TEST_IDS . MUSD . ASSET_OVERVIEW_CONVERSION_CTA_CLOSE_BUTTON ,
774+ ) ;
775+
776+ await act ( async ( ) => {
777+ fireEvent . press ( closeButton ) ;
778+ } ) ;
779+
780+ const expectedCtaKey = '0x1-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ;
781+ const updatedState = store . getState ( ) ;
782+
783+ expect (
784+ updatedState . user . musdConversionAssetDetailCtasSeen [ expectedCtaKey ] ,
785+ ) . toBe ( true ) ;
786+ } ) ;
787+
740788 it ( 'hides mUSD conversion CTA when user is geo-blocked' , ( ) => {
741789 const mockEmptyReceiptToken = {
742790 ...mockADAIMainnet ,
@@ -754,18 +802,6 @@ describe('EarnLendingBalance', () => {
754802 earnToken : mockDaiMainnet ,
755803 } ) ;
756804
757- (
758- selectStablecoinLendingEnabledFlag as jest . MockedFunction <
759- typeof selectStablecoinLendingEnabledFlag
760- >
761- ) . mockReturnValue ( false ) ;
762-
763- (
764- selectIsMusdConversionFlowEnabledFlag as jest . MockedFunction <
765- typeof selectIsMusdConversionFlowEnabledFlag
766- >
767- ) . mockReturnValue ( true ) ;
768-
769805 // Geo-blocked: shouldShowAssetOverviewCta returns false
770806 mockShouldShowAssetOverviewCta . mockReturnValue ( false ) ;
771807
@@ -816,7 +852,6 @@ describe('EarnLendingBalance', () => {
816852 < EarnLendingBalance asset = { mockDaiMainnet } /> ,
817853 { state : mockInitialState } ,
818854 ) ;
819-
820855 // mUSD CTA visible because geo-eligible (useMusdCtaVisibility returns true)
821856 expect (
822857 getByTestId ( EARN_TEST_IDS . MUSD . ASSET_OVERVIEW_CONVERSION_CTA ) ,
0 commit comments