Skip to content

Commit 853ca71

Browse files
committed
chore(test): conflict and sync with autoreload
Signed-off-by: Max <[email protected]>
1 parent 133e7fc commit 853ca71

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

cypress/e2e/conflict.spec.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,9 @@ variants.forEach(function ({ fixture, mime }) {
3636
cy.getContent().should('contain', 'Heading')
3737

3838
cy.uploadFile(fileName, mime, testName + '/' + fileName)
39-
cy.get('#editor-container .document-status', {
40-
timeout: 40000,
41-
}).should('contain', 'session has expired')
42-
43-
// Reload button works
44-
cy.get('#editor-container .document-status a.button')
45-
.contains('Reload')
46-
.click()
39+
cy.intercept({ method: 'POST', url: '**/session/*/push' }).as('push')
40+
cy.wait('@push', { timeout: 20_000 })
41+
// Autoreload works
4742
getWrapper().should('not.exist')
4843
cy.getContent().should('contain', 'Hello world')
4944
cy.getContent().should('not.contain', 'Heading')

cypress/e2e/sync.spec.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ describe('Sync', () => {
108108
'contain',
109109
'The document could not be loaded.',
110110
)
111+
cy.intercept('**/apps/text/session/*/create').as('create')
111112
cy.get('#editor-container .document-status').find('.button.primary').click()
113+
// let first attempt fail
114+
cy.wait('@create', { timeout: 10000 })
112115
cy.get('#editor-container .document-status', { timeout: 30000 }).should(
113116
'contain',
114117
'The document could not be loaded.',
@@ -117,13 +120,13 @@ describe('Sync', () => {
117120
cy.intercept('**/apps/text/session/*/*', (req) => {
118121
req.continue()
119122
}).as('alive')
120-
cy.intercept('**/apps/text/session/*/create').as('create')
121123
cy.get('#editor-container .document-status').find('.button.primary').click()
124+
// this is the create request... - now with the alive alias
122125
cy.wait('@alive', { timeout: 30000 })
123-
cy.wait('@create', { timeout: 10000 })
124126
.its('request.body')
125127
.should('have.property', 'baseVersionEtag')
126128
.should('not.be.empty')
129+
cy.getContent().should('contain', 'Hello world')
127130
})
128131

129132
it('recovers from a lost and closed connection', () => {
@@ -176,18 +179,9 @@ describe('Sync', () => {
176179
cy.wait('@save')
177180
cy.uploadTestFile('test.md')
178181

179-
cy.get('#editor-container .document-status', { timeout: 30000 }).should(
180-
'contain',
181-
'Editing session has expired.',
182-
)
183-
184-
// Reload button works
185-
cy.get('#editor-container .document-status a.button')
186-
.contains('Reload')
187-
.click()
188-
189-
cy.getContent()
190-
cy.get('#editor-container .document-status .notecard').should('not.exist')
182+
cy.getContent().should('not.exist')
183+
cy.getContent().find('h2').should('contain', 'Hello world')
184+
cy.getContent().find('li').should('not.exist') // was overwritten after the save
191185
})
192186

193187
it('passes the doc content from one session to the next', () => {

0 commit comments

Comments
 (0)