File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ describe('Sync', () => {
111111
112112 it ( 'recovers from a lost and closed connection' , ( ) => {
113113 let reconnect = false
114+ // block all requests until the session is closed and reopened
114115 cy . intercept ( '**/apps/text/session/*/*' , ( req ) => {
115116 if ( req . url . includes ( 'close' ) || req . url . includes ( 'create' ) || reconnect ) {
116117 req . continue ( )
@@ -125,6 +126,11 @@ describe('Sync', () => {
125126 cy . get ( '#editor-container .document-status' , { timeout : 30000 } )
126127 . should ( 'contain' , 'Document could not be loaded.' )
127128
129+ // Reconnect button works - it closes and reopens the session
130+ cy . get ( '#editor-container .document-status a.button' )
131+ . contains ( 'Reconnect' )
132+ . click ( )
133+
128134 cy . wait ( '@syncAfterRecovery' , { timeout : 60000 } )
129135
130136 cy . get ( '#editor-container .document-status' , { timeout : 30000 } )
Original file line number Diff line number Diff line change @@ -104,12 +104,14 @@ class SyncService {
104104 }
105105
106106 async open ( { fileId, initialSession } ) {
107-
107+ if ( this . #connection && ! this . #connection. isClosed ) {
108+ // We're already connected.
109+ return
110+ }
108111 const connect = initialSession
109112 ? Promise . resolve ( new Connection ( { data : initialSession } , { } ) )
110113 : this . _api . open ( { fileId, baseVersionEtag : this . baseVersionEtag } )
111114 . catch ( error => this . _emitError ( error ) )
112-
113115 this . #connection = await connect
114116 if ( ! this . #connection) {
115117 // Error was already emitted in connect
You can’t perform that action at this time.
0 commit comments