@@ -31,6 +31,7 @@ function props(
3131 canonicalOrigin : string ;
3232 onAuthenticated : ReturnType < typeof vi . fn > ;
3333 onLocked : ReturnType < typeof vi . fn > ;
34+ enrollmentTicket : string ;
3435 } > = { } ,
3536) {
3637 const client : TestClient = {
@@ -188,6 +189,28 @@ describe('FirstDeviceEnrollment', () => {
188189 expect ( values . client . status ) . not . toHaveBeenCalled ( ) ;
189190 } ) ;
190191
192+ it ( 'does not cancel ticket enrollment when an existing relay is locked on desktop' , async ( ) => {
193+ vi . useFakeTimers ( ) ;
194+ window . matchMedia = vi . fn ( ( ) => ( { matches : true } ) ) as never ;
195+ const values = props ( {
196+ enrollmentTicket : 'ticket' ,
197+ client : {
198+ ...props ( ) . client ,
199+ status : vi . fn ( async ( ) => ( { status : 'locked' , publicOrigin : 'https://relay.example' } ) ) ,
200+ } ,
201+ } ) ;
202+ mount ( values ) ;
203+ await fireEvent . input ( screen . getByLabelText ( 'Device nickname' ) , { target : { value : 'Omni' } } ) ;
204+ await fireEvent . click ( screen . getByRole ( 'button' , { name : 'Authorize this device' } ) ) ;
205+ await vi . advanceTimersByTimeAsync ( 15_000 ) ;
206+ await vi . waitFor ( ( ) =>
207+ expect ( values . client . verifyRegistration ) . toHaveBeenCalledWith ( { id : 'credential' } , 'Omni' ) ,
208+ ) ;
209+ expect ( values . client . status ) . not . toHaveBeenCalled ( ) ;
210+ expect ( values . onLocked ) . not . toHaveBeenCalled ( ) ;
211+ expect ( values . onAuthenticated ) . toHaveBeenCalledOnce ( ) ;
212+ } ) ;
213+
191214 it ( 'does not continue an in-flight registration after another device wins polling' , async ( ) => {
192215 vi . useFakeTimers ( ) ;
193216 window . matchMedia = vi . fn ( ( ) => ( { matches : true } ) ) as never ;
0 commit comments