Skip to content

Commit 3288448

Browse files
committed
fix(cypress): close attachments file before proceeding
Deleting the file later on failed because the file still was locked. Signed-off-by: Max <[email protected]>
1 parent 2c29a86 commit 3288448

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

cypress/e2e/attachments.spec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ const checkAttachment = (documentId, fileName, fileId, index, isImage = true) =>
104104
const srcFileNameParam = isImage ? 'imageFileName' : 'mediaFileName'
105105

106106
cy.wrap($el)
107+
// ensure the image is not hidden behind the menu bar.
108+
.scrollIntoView({ offset: { top: -50, left: 0 } })
107109
.should('be.visible')
108110
.find('img')
109111
.should('have.attr', 'src')
@@ -220,6 +222,7 @@ describe('Test all attachment insertion methods', () => {
220222

221223
return waitForRequestAndCheckAttachment(requestAlias)
222224
})
225+
cy.closeFile()
223226
})
224227

225228
it('Upload a local image file (table.png)', () => {
@@ -236,6 +239,7 @@ describe('Test all attachment insertion methods', () => {
236239

237240
return waitForRequestAndCheckAttachment(requestAlias)
238241
})
242+
cy.closeFile()
239243
})
240244

241245
it('Upload a local media file (file.txt.gz)', () => {
@@ -252,6 +256,7 @@ describe('Test all attachment insertion methods', () => {
252256

253257
return waitForRequestAndCheckAttachment(requestAlias, undefined, false)
254258
})
259+
cy.closeFile()
255260
})
256261

257262
it('Upload image files with the same name', () => {
@@ -280,8 +285,9 @@ describe('Test all attachment insertion methods', () => {
280285
assertImage(index).then(resolve, reject)
281286
})
282287
})
283-
return cy.getEditor().find('[data-component="image-view"]')
288+
cy.getEditor().find('[data-component="image-view"]')
284289
.should('have.length', 3)
290+
cy.closeFile()
285291
})
286292

287293
it('test if attachment files are in the attachment folder', () => {

cypress/support/commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ Cypress.Commands.add('openFileInShare', fileName => {
306306
cy.wait(250)
307307
})
308308

309-
Cypress.Commands.add('closeFile', (fileName, params = {}) => {
309+
Cypress.Commands.add('closeFile', (params = {}) => {
310310
cy.intercept({ method: 'POST', url: '**/apps/text/session/close' })
311311
.as('close')
312312
cy.get('#viewer .modal-header button.header-close').click(params)

0 commit comments

Comments
 (0)