@@ -96,6 +96,7 @@ describe.each(['https://remote.openbitfun.com/v/1.0.2', 'http://192.168.1.9:9700
9696 ? Response . json ( { device_id : 'desktop' , public_key : toB64 ( peerPublicKey ) } )
9797 : Response . json ( { encrypted_data : encrypted . data , nonce : encrypted . nonce } ) ) ;
9898 vi . stubGlobal ( 'fetch' , fetch ) ;
99+ vi . spyOn ( AccountRealtime . prototype , 'ready' ) . mockResolvedValue ( ) ;
99100 const rpc = vi . spyOn ( AccountRealtime . prototype , 'call' ) . mockResolvedValue ( { encrypted_data : encrypted . data , nonce : encrypted . nonce } ) ;
100101 await expect ( client . sendDeviceRpc ( 'desktop' , { cmd : 'cancel_task' } ) ) . rejects . toThrow ( message ) ;
101102 expect ( fetch ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -106,11 +107,14 @@ describe.each(['https://remote.openbitfun.com/v/1.0.2', 'http://192.168.1.9:9700
106107 } ) ;
107108 it ( 'does not post a command after the target changes during key lookup' , async ( ) => {
108109 const pending = deferred < Response > ( ) ; const fetch = vi . fn ( ( ) => pending . promise ) ; vi . stubGlobal ( 'fetch' , fetch ) ;
110+ const ready = vi . spyOn ( AccountRealtime . prototype , 'ready' ) . mockResolvedValue ( ) ;
109111 const client = new RelayHttpClient ( relayUrl , identity ( ) ) ; client . setTargetDeviceId ( 'desktop' ) ;
110112 const result = client . sendDeviceRpc ( 'desktop' , { cmd : 'cancel_task' } ) ;
111113 client . setTargetDeviceId ( 'another' ) ;
112114 pending . resolve ( Response . json ( { device_id : 'desktop' , public_key : toB64 ( peerPublicKey ) } ) ) ;
113115 await expect ( result ) . rejects . toBeInstanceOf ( AccountIdentityChangedError ) ;
116+ expect ( ready ) . not . toHaveBeenCalled ( ) ;
117+ client . resetConnectionIdentity ( ) ;
114118 expect ( fetch ) . toHaveBeenCalledTimes ( 1 ) ;
115119 } ) ;
116120 it ( 'stops transient directory retries when the account changes during backoff' , async ( ) => {
0 commit comments