@@ -649,6 +649,72 @@ describe('HardwareWalletProvider', () => {
649649 } ) ;
650650 } ) ;
651651
652+ describe ( 'QR scan retry' , ( ) => {
653+ it ( 'closes QR scan errors when no retry handler is registered' , ( ) => {
654+ const { result } = renderWithActions ( ) ;
655+
656+ act ( ( ) => {
657+ result . current . actions . showHardwareWalletError (
658+ new Error ( 'QR scan failed' ) ,
659+ ) ;
660+ } ) ;
661+ expect ( result . current . state . connectionState . status ) . toBe (
662+ ConnectionStatus . ErrorState ,
663+ ) ;
664+
665+ act ( ( ) => {
666+ ( capturedBottomSheetProps . onRetryQrScan as ( ) => void ) ( ) ;
667+ } ) ;
668+
669+ expect ( result . current . state . connectionState . status ) . toBe (
670+ ConnectionStatus . Disconnected ,
671+ ) ;
672+ } ) ;
673+
674+ it ( 'calls registered QR scan retry handler for non-signing QR errors' , ( ) => {
675+ const { result } = renderWithActions ( ) ;
676+ const retryHandler = jest . fn ( ) ;
677+
678+ act ( ( ) => {
679+ result . current . actions . showHardwareWalletError (
680+ new Error ( 'QR scan failed' ) ,
681+ ) ;
682+ } ) ;
683+ act ( ( ) => {
684+ result . current . actions . setQrScanRetryHandler ?.( retryHandler ) ;
685+ } ) ;
686+ act ( ( ) => {
687+ ( capturedBottomSheetProps . onRetryQrScan as ( ) => void ) ( ) ;
688+ } ) ;
689+
690+ expect ( retryHandler ) . toHaveBeenCalledTimes ( 1 ) ;
691+ expect ( result . current . state . connectionState . status ) . toBe (
692+ ConnectionStatus . Disconnected ,
693+ ) ;
694+ } ) ;
695+
696+ it ( 'returns to awaiting confirmation when retrying a signing QR error' , async ( ) => {
697+ const { result } = renderWithActions ( ) ;
698+
699+ await act ( async ( ) => {
700+ result . current . actions . showAwaitingConfirmation ( 'message' ) ;
701+ } ) ;
702+ await act ( async ( ) => {
703+ result . current . actions . showHardwareWalletError (
704+ new Error ( 'QR scan failed' ) ,
705+ ) ;
706+ } ) ;
707+ act ( ( ) => {
708+ ( capturedBottomSheetProps . onRetryQrScan as ( ) => void ) ( ) ;
709+ } ) ;
710+
711+ expect ( result . current . state . connectionState ) . toMatchObject ( {
712+ status : ConnectionStatus . AwaitingConfirmation ,
713+ operationType : 'message' ,
714+ } ) ;
715+ } ) ;
716+ } ) ;
717+
652718 describe ( 'retryEnsureDeviceReady (internal, via bottom sheet props)' , ( ) => {
653719 it ( 'transitions to connecting state when retrying a connection error' , async ( ) => {
654720 const { result } = renderWithActions ( ) ;
0 commit comments