@@ -42,7 +42,7 @@ describe('The session Api', function() {
4242 cy . wrap ( connection )
4343 . its ( 'document.id' )
4444 . should ( 'equal' , fileId )
45- connection . close ( )
45+ cy . destroySession ( connection )
4646 } )
4747 } )
4848
@@ -51,7 +51,7 @@ describe('The session Api', function() {
5151 cy . wrap ( connection )
5252 . its ( 'state.documentSource' )
5353 . should ( 'eql' , '## Hello world\n' )
54- connection . close ( )
54+ cy . destroySession ( connection )
5555 } )
5656 } )
5757
@@ -81,7 +81,7 @@ describe('The session Api', function() {
8181 } )
8282
8383 afterEach ( function ( ) {
84- connection . close ( )
84+ cy . destroySession ( connection )
8585 } )
8686
8787 // Echoes all message types but queries
@@ -180,7 +180,7 @@ describe('The session Api', function() {
180180 } )
181181
182182 afterEach ( function ( ) {
183- connection . close ( )
183+ cy . destroySession ( connection )
184184 } )
185185 } )
186186
@@ -212,7 +212,7 @@ describe('The session Api', function() {
212212 } )
213213
214214 afterEach ( function ( ) {
215- connection . close ( )
215+ cy . destroySession ( connection )
216216 } )
217217
218218 it ( 'starts empty public' , function ( ) {
@@ -276,22 +276,6 @@ describe('The session Api', function() {
276276 } )
277277 } )
278278
279- it ( 'signals closing connection' , function ( ) {
280- cy . then ( ( ) => {
281- return new Promise ( ( resolve , reject ) => {
282- // Create a promise that resolves when close completes
283- connection . close ( )
284- . then ( ( ) => {
285- connection . push ( { steps : [ messages . update ] , version, awareness : '' } )
286- . then (
287- ( ) => reject ( new Error ( 'Push should have thrown ConnectionClosed()' ) ) ,
288- resolve ,
289- )
290- } )
291- } )
292- } )
293- } )
294-
295279 it ( 'does not send initial content if other session is alive but did not push any steps' , function ( ) {
296280 let joining
297281 cy . createTextSession ( undefined , { filePath : '' , shareToken } )
@@ -301,8 +285,8 @@ describe('The session Api', function() {
301285 } )
302286 . its ( 'state.documentSource' )
303287 . should ( 'eql' , '## Hello world\n' )
304- . then ( ( ) => joining . close ( ) )
305- . then ( ( ) => connection . close ( ) )
288+ . then ( ( ) => cy . destroySession ( joining ) )
289+ cy . destroySession ( connection )
306290 } )
307291
308292 it ( 'does not send initial content if session is alive even without saved state' , function ( ) {
@@ -317,8 +301,8 @@ describe('The session Api', function() {
317301 } )
318302 . its ( 'state.documentSource' )
319303 . should ( 'eql' , '## Hello world\n' )
320- . then ( ( ) => joining . close ( ) )
321- . then ( ( ) => connection . close ( ) )
304+ . then ( ( ) => cy . destroySession ( joining ) )
305+ cy . destroySession ( connection )
322306 } )
323307
324308 it ( 'refuses create,push,sync,save with non-matching baseVersionEtag' , function ( ) {
@@ -340,7 +324,7 @@ describe('The session Api', function() {
340324 . its ( 'status' )
341325 . should ( 'equal' , 412 )
342326
343- cy . then ( ( ) => connection . close ( ) )
327+ cy . destroySession ( connection )
344328 } )
345329
346330 it ( 'recovers session even if last person leaves right after create' , function ( ) {
@@ -355,7 +339,7 @@ describe('The session Api', function() {
355339 joining = con
356340 } )
357341 cy . log ( 'Initial user closes session' )
358- . then ( ( ) => connection . close ( ) )
342+ cy . destroySession ( connection )
359343 cy . log ( 'Other user still finds the steps' )
360344 . then ( ( ) => {
361345 cy . syncSteps ( joining , {
0 commit comments