@@ -36,9 +36,9 @@ Cypress.Commands.add('createTextSession', (fileId, options = {}) => {
3636 return api . open ( { fileId } )
3737} )
3838
39- Cypress . Commands . add ( 'failToCreateTextSession' , ( fileId ) => {
40- const api = new SessionApi ( )
41- return api . open ( { fileId } )
39+ Cypress . Commands . add ( 'failToCreateTextSession' , ( fileId , baseVersionEtag = null , options = { } ) => {
40+ const api = new SessionApi ( options )
41+ return api . open ( { fileId, baseVersionEtag } )
4242 . then ( ( response ) => {
4343 throw new Error ( 'Expected request to fail - but it succeeded!' )
4444 } )
@@ -50,16 +50,40 @@ Cypress.Commands.add('pushSteps', ({ connection, steps, version, awareness = ''
5050 . then ( response => response . data )
5151} )
5252
53+ Cypress . Commands . add ( 'failToPushSteps' , ( { connection, steps, version, awareness = '' } ) => {
54+ return connection . push ( { steps, version, awareness } )
55+ . then ( ( response ) => {
56+ throw new Error ( 'Expected request to fail - but it succeeded!' )
57+ } )
58+ . catch ( ( err ) => err . response )
59+ } )
60+
5361Cypress . Commands . add ( 'syncSteps' , ( connection , options = { version : 0 } ) => {
5462 return connection . sync ( options )
5563 . then ( response => response . data )
5664} )
5765
66+ Cypress . Commands . add ( 'failToSyncSteps' , ( connection , options = { version : 0 } ) => {
67+ return connection . sync ( options )
68+ . then ( ( response ) => {
69+ throw new Error ( 'Expected request to fail - but it succeeded!' )
70+ } )
71+ . catch ( ( err ) => err . response )
72+ } )
73+
5874Cypress . Commands . add ( 'save' , ( connection , options = { version : 0 } ) => {
5975 return connection . save ( options )
6076 . then ( response => response . data )
6177} )
6278
79+ Cypress . Commands . add ( 'failToSave' , ( connection , options = { version : 0 } ) => {
80+ return connection . save ( options )
81+ . then ( ( response ) => {
82+ throw new Error ( 'Expected request to fail - but it succeeded!' )
83+ } )
84+ . catch ( ( err ) => err . response )
85+ } )
86+
6387// Used to test for race conditions between the last push and the close request
6488Cypress . Commands . add ( 'pushAndClose' , ( { connection, steps, version, awareness = '' } ) => {
6589 cy . log ( 'Race between push and close' )
0 commit comments