@@ -131,9 +131,12 @@ jest.mock('@react-navigation/native', () => {
131131 } ;
132132} ) ;
133133
134+ const mockGate = jest . fn (
135+ async ( action : ( ) => Promise < unknown > ) => await action ( ) ,
136+ ) ;
134137jest . mock ( '../../Compliance' , ( ) => ( {
135138 useComplianceGate : ( ) => ( {
136- gate : ( action : ( ) => Promise < unknown > ) => action ( ) ,
139+ gate : ( action : ( ) => Promise < unknown > ) => mockGate ( action ) ,
137140 isBlocked : false ,
138141 isComplianceEnabled : false ,
139142 checkCompliance : jest . fn ( ) ,
@@ -325,6 +328,51 @@ describe('AssetOverviewContent', () => {
325328 expect ( mockTrack ) . not . toHaveBeenCalled ( ) ;
326329 } ) ;
327330
331+ it ( 'releases the navigation lock when gate() settles without navigating so Long can be pressed again' , async ( ) => {
332+ // Simulate a blocked wallet: gate() shows the compliance modal and
333+ // returns without invoking the action. Without releasing the nav lock
334+ // in the finally(), the second press would be silently ignored.
335+ mockGate . mockImplementationOnce ( async ( ) => undefined ) ;
336+ mockGate . mockImplementationOnce ( async ( ) => undefined ) ;
337+
338+ const { getByTestId } = renderWithProvider (
339+ < AssetOverviewContent { ...defaultProps } /> ,
340+ { state : createState ( true ) } ,
341+ ) ;
342+
343+ await act ( async ( ) => {
344+ fireEvent . press ( getByTestId ( TokenOverviewSelectorsIDs . LONG_BUTTON ) ) ;
345+ } ) ;
346+ expect ( mockGate ) . toHaveBeenCalledTimes ( 1 ) ;
347+
348+ await act ( async ( ) => {
349+ fireEvent . press ( getByTestId ( TokenOverviewSelectorsIDs . LONG_BUTTON ) ) ;
350+ } ) ;
351+ expect ( mockGate ) . toHaveBeenCalledTimes ( 2 ) ;
352+ expect ( mockHandlePerpsAction ) . not . toHaveBeenCalled ( ) ;
353+ } ) ;
354+
355+ it ( 'releases the navigation lock when gate() settles without navigating so Short can be pressed again' , async ( ) => {
356+ mockGate . mockImplementationOnce ( async ( ) => undefined ) ;
357+ mockGate . mockImplementationOnce ( async ( ) => undefined ) ;
358+
359+ const { getByTestId } = renderWithProvider (
360+ < AssetOverviewContent { ...defaultProps } /> ,
361+ { state : createState ( true ) } ,
362+ ) ;
363+
364+ await act ( async ( ) => {
365+ fireEvent . press ( getByTestId ( TokenOverviewSelectorsIDs . SHORT_BUTTON ) ) ;
366+ } ) ;
367+ expect ( mockGate ) . toHaveBeenCalledTimes ( 1 ) ;
368+
369+ await act ( async ( ) => {
370+ fireEvent . press ( getByTestId ( TokenOverviewSelectorsIDs . SHORT_BUTTON ) ) ;
371+ } ) ;
372+ expect ( mockGate ) . toHaveBeenCalledTimes ( 2 ) ;
373+ expect ( mockHandlePerpsAction ) . not . toHaveBeenCalled ( ) ;
374+ } ) ;
375+
328376 it ( 'closes geo block modal when closeEligibilityModal is called' , ( ) => {
329377 const { getByTestId } = renderWithProvider (
330378 < AssetOverviewContent { ...defaultProps } /> ,
0 commit comments