@@ -73,34 +73,33 @@ describe('The session Api', function () {
7373 cy . closeConnection ( connection )
7474 } )
7575
76- // Echoes all message types but queries
77- Object . entries ( messages )
78- . filter ( ( [ key , _value ] ) => key !== 'query' )
79- . forEach ( ( [ type , sample ] ) => {
80- it ( `echos ${ type } messages` , function ( ) {
81- const steps = [ sample ]
82- const version = 0
83- cy . pushSteps ( { connection, steps, version } )
84- . its ( 'version' )
85- . should ( 'eql' , 0 )
86- cy . syncSteps ( connection )
87- . its ( 'steps[0].data' )
88- . should ( 'eql' , steps )
89- } )
76+ // Echoes updates and responses
77+ ; [ 'update' , 'response' ] . forEach ( ( type ) => {
78+ it ( `echos ${ type } messages` , function ( ) {
79+ const steps = [ messages [ type ] ]
80+ const version = 0
81+ cy . pushSteps ( { connection, steps, version } )
82+ . its ( 'version' )
83+ . should ( 'eql' , 0 )
84+ cy . syncSteps ( connection ) . its ( 'steps[0].data' ) . should ( 'eql' , steps )
9085 } )
86+ } )
9187
92- it ( 'responds to queries' , function ( ) {
88+ it ( 'responds to queries with updates and responses ' , function ( ) {
9389 const version = 0
9490 Object . entries ( messages ) . forEach ( ( [ type , sample ] ) => {
9591 cy . pushSteps ( { connection, steps : [ sample ] , version } )
9692 } )
9793 cy . pushSteps ( { connection, steps : [ messages . query ] , version } ) . then (
9894 ( response ) => {
9995 cy . wrap ( response ) . its ( 'version' ) . should ( 'eql' , 0 )
100- cy . wrap ( response ) . its ( 'steps.length' ) . should ( 'eql' , 1 )
96+ cy . wrap ( response ) . its ( 'steps.length' ) . should ( 'eql' , 2 )
10197 cy . wrap ( response )
10298 . its ( 'steps[0].data' )
10399 . should ( 'eql' , [ messages . update ] )
100+ cy . wrap ( response )
101+ . its ( 'steps[1].data' )
102+ . should ( 'eql' , [ messages . response ] )
104103 } ,
105104 )
106105 } )
@@ -111,7 +110,6 @@ describe('The session Api', function () {
111110 let connection
112111 let fileId
113112 let filePath
114- let joining
115113
116114 beforeEach ( function ( ) {
117115 cy . testName ( ) . then ( ( name ) => {
@@ -155,13 +153,10 @@ describe('The session Api', function () {
155153 manualSave : true ,
156154 } )
157155 cy . openConnection ( { fileId, filePath } )
158- . then ( ( { connection : con , data } ) => {
159- joining = con
160- return data
161- } )
162- . its ( 'documentState' )
156+ . as ( 'joining' )
157+ . its ( 'data.documentState' )
163158 . should ( 'eql' , documentState )
164- cy . closeConnection ( joining )
159+ cy . get ( '@ joining' ) . its ( 'connection' ) . then ( cy . closeConnection )
165160 } )
166161
167162 afterEach ( function ( ) {
@@ -174,7 +169,6 @@ describe('The session Api', function () {
174169 let connection
175170 let filePath
176171 let shareToken
177- let joining
178172
179173 beforeEach ( function ( ) {
180174 cy . testName ( ) . then ( ( name ) => {
@@ -230,13 +224,10 @@ describe('The session Api', function () {
230224 manualSave : true ,
231225 } )
232226 cy . openConnection ( { filePath : '' , token : shareToken } )
233- . then ( ( { connection : con , data } ) => {
234- joining = con
235- return data
236- } )
237- . its ( 'documentState' )
227+ . as ( 'joining' )
228+ . its ( 'data.documentState' )
238229 . should ( 'eql' , documentState )
239- cy . closeConnection ( joining )
230+ cy . get ( '@ joining' ) . its ( 'connection' ) . then ( cy . closeConnection )
240231 } )
241232 } )
242233
0 commit comments