@@ -38,20 +38,20 @@ describe('The session Api', function() {
3838 } )
3939
4040 it ( 'returns connection' , function ( ) {
41- cy . createTextSession ( fileId ) . then ( connection => {
41+ cy . openConnection ( { fileId } ) . then ( ( { connection } ) => {
4242 cy . wrap ( connection )
43- . its ( 'document.id ' )
43+ . its ( 'documentId ' )
4444 . should ( 'equal' , fileId )
45- cy . destroySession ( connection )
45+ cy . closeConnection ( connection )
4646 } )
4747 } )
4848
4949 it ( 'provides initial content' , function ( ) {
50- cy . createTextSession ( fileId , { filePath } ) . then ( connection => {
51- cy . wrap ( connection )
52- . its ( 'state.documentSource ' )
50+ cy . openConnection ( { fileId, filePath } ) . then ( ( { connection, data } ) => {
51+ cy . wrap ( data )
52+ . its ( 'content ' )
5353 . should ( 'eql' , '## Hello world\n' )
54- cy . destroySession ( connection )
54+ cy . closeConnection ( connection )
5555 } )
5656 } )
5757
@@ -74,14 +74,14 @@ describe('The session Api', function() {
7474
7575 beforeEach ( function ( ) {
7676 cy . uploadTestFile ( )
77- . then ( cy . createTextSession )
78- . then ( con => {
77+ . then ( ( fileId ) => cy . openConnection ( { fileId } ) )
78+ . then ( ( { connection : con } ) => {
7979 connection = con
8080 } )
8181 } )
8282
8383 afterEach ( function ( ) {
84- cy . destroySession ( connection )
84+ cy . closeConnection ( connection )
8585 } )
8686
8787 // Echoes all message types but queries
@@ -135,9 +135,9 @@ describe('The session Api', function() {
135135 cy . uploadTestFile ( )
136136 . then ( id => {
137137 fileId = id
138- return cy . createTextSession ( fileId , { filePath } )
138+ return cy . openConnection ( { fileId, filePath } )
139139 } )
140- . then ( con => {
140+ . then ( ( { connection : con } ) => {
141141 connection = con
142142 } )
143143 } )
@@ -169,18 +169,18 @@ describe('The session Api', function() {
169169 documentState,
170170 manualSave : true ,
171171 } )
172- cy . createTextSession ( fileId , { filePath } )
173- . then ( con => {
172+ cy . openConnection ( { fileId, filePath } )
173+ . then ( ( { connection : con , data } ) => {
174174 joining = con
175- return joining
175+ return data
176176 } )
177- . its ( 'state. documentState' )
177+ . its ( 'documentState' )
178178 . should ( 'eql' , documentState )
179- . then ( ( ) => joining . close ( ) )
179+ cy . closeConnection ( joining )
180180 } )
181181
182182 afterEach ( function ( ) {
183- cy . destroySession ( connection )
183+ cy . closeConnection ( connection )
184184 } )
185185 } )
186186
@@ -204,15 +204,15 @@ describe('The session Api', function() {
204204 } )
205205 . then ( ( ) => cy . clearCookies ( ) )
206206 . then ( ( ) => {
207- return cy . createTextSession ( undefined , { filePath : '' , shareToken } )
208- . then ( con => {
207+ return cy . openConnection ( { filePath : '' , token : shareToken } )
208+ . then ( ( { connection : con } ) => {
209209 connection = con
210210 } )
211211 } )
212212 } )
213213
214214 afterEach ( function ( ) {
215- cy . destroySession ( connection )
215+ cy . closeConnection ( connection )
216216 } )
217217
218218 it ( 'starts empty public' , function ( ) {
@@ -243,14 +243,14 @@ describe('The session Api', function() {
243243 documentState,
244244 manualSave : true ,
245245 } )
246- cy . createTextSession ( undefined , { filePath : '' , shareToken } )
247- . then ( con => {
246+ cy . openConnection ( { filePath : '' , token : shareToken } )
247+ . then ( ( { connection : con , data } ) => {
248248 joining = con
249- return con
249+ return data
250250 } )
251- . its ( 'state. documentState' )
251+ . its ( 'documentState' )
252252 . should ( 'eql' , documentState )
253- . then ( ( ) => joining . close ( ) )
253+ cy . closeConnection ( joining )
254254 } )
255255
256256 } )
@@ -269,49 +269,48 @@ describe('The session Api', function() {
269269 cy . log ( token )
270270 shareToken = token
271271 cy . clearCookies ( )
272- cy . createTextSession ( undefined , { filePath : '' , shareToken } )
273- . then ( con => {
272+ cy . openConnection ( { filePath : '' , token : shareToken } )
273+ . then ( ( { connection : con } ) => {
274274 connection = con
275275 } )
276276 } )
277277 } )
278278
279279 it ( 'does not send initial content if other session is alive but did not push any steps' , function ( ) {
280280 let joining
281- cy . createTextSession ( undefined , { filePath : '' , shareToken } )
282- . then ( con => {
281+ cy . openConnection ( { filePath : '' , token : shareToken } )
282+ . then ( ( { connection : con , data } ) => {
283283 joining = con
284- return con
284+ return data
285285 } )
286- . its ( 'state.documentSource ' )
286+ . its ( 'content ' )
287287 . should ( 'eql' , '## Hello world\n' )
288- . then ( ( ) => cy . destroySession ( joining ) )
289- cy . destroySession ( connection )
288+ . then ( ( ) => cy . closeConnection ( joining ) )
289+ cy . closeConnection ( connection )
290290 } )
291291
292292 it ( 'does not send initial content if session is alive even without saved state' , function ( ) {
293293 let joining
294294 cy . pushSteps ( { connection, steps : [ messages . update ] , version } )
295295 . its ( 'version' )
296296 . should ( 'be.at.least' , 1 )
297- cy . createTextSession ( undefined , { filePath : '' , shareToken } )
298- . then ( con => {
297+ cy . openConnection ( { filePath : '' , token : shareToken } )
298+ . then ( ( { connection : con , data } ) => {
299299 joining = con
300- return con
300+ return data
301301 } )
302- . its ( 'state.documentSource ' )
302+ . its ( 'content ' )
303303 . should ( 'eql' , '## Hello world\n' )
304- . then ( ( ) => cy . destroySession ( joining ) )
305- cy . destroySession ( connection )
304+ . then ( ( ) => cy . closeConnection ( joining ) )
305+ cy . closeConnection ( connection )
306306 } )
307307
308308 it ( 'refuses create,push,sync,save with non-matching baseVersionEtag' , function ( ) {
309309 cy . failToCreateTextSession ( undefined , 'wrongBaseVersionEtag' , { filePath : '' , token : shareToken } )
310310 . its ( 'status' )
311311 . should ( 'eql' , 412 )
312312
313- connection . setBaseVersionEtag ( 'wrongBaseVersionEtag' )
314- connection . connection . baseVersionEtag = 'wrongBaseVersionEtag'
313+ connection . baseVersionEtag = 'wrongBaseVersionEtag'
315314
316315 cy . failToPushSteps ( { connection, steps : [ messages . update ] , version } )
317316 . its ( 'status' )
@@ -325,7 +324,7 @@ describe('The session Api', function() {
325324 . its ( 'status' )
326325 . should ( 'equal' , 412 )
327326
328- cy . destroySession ( connection )
327+ cy . closeConnection ( connection )
329328 } )
330329
331330 it ( 'recovers session even if last person leaves right after create' , function ( ) {
@@ -335,12 +334,12 @@ describe('The session Api', function() {
335334 . its ( 'version' )
336335 . should ( 'be.at.least' , 1 )
337336 cy . log ( 'Other user creates session' )
338- cy . createTextSession ( undefined , { filePath : '' , shareToken } )
339- . then ( con => {
337+ cy . openConnection ( { filePath : '' , token : shareToken } )
338+ . then ( ( { connection : con } ) => {
340339 joining = con
341340 } )
342341 cy . log ( 'Initial user closes session' )
343- cy . destroySession ( connection )
342+ cy . closeConnection ( connection )
344343 cy . log ( 'Other user still finds the steps' )
345344 . then ( ( ) => {
346345 cy . syncSteps ( joining , {
@@ -354,11 +353,12 @@ describe('The session Api', function() {
354353 // Skipped for now since the behaviour chanced by not cleaning up the state on close/create
355354 it . skip ( 'ignores steps stored after close cleaned up' , function ( ) {
356355 cy . pushAndClose ( { connection, steps : [ messages . update ] , version } )
357- cy . createTextSession ( undefined , { filePath : '' , shareToken } )
358- . then ( con => {
356+ cy . openConnection ( { filePath : '' , token : shareToken } )
357+ . then ( ( { connection : con , data } ) => {
359358 connection = con
359+ return data
360360 } )
361- . its ( 'state.documentSource ' )
361+ . its ( 'content ' )
362362 . should ( 'eql' , '## Hello world\n' )
363363 } )
364364
0 commit comments