Skip to content

Commit e5fa2a9

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 <max@nextcloud.com>
1 parent 2c29a86 commit e5fa2a9

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

cypress/e2e/attachments.spec.js

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

106+
// ensure the image is not hidden behind the menu bar.
107+
cy.wrap($el).scrollIntoView({ offset: { top: -50, left: 0 } })
108+
106109
cy.wrap($el)
107110
.should('be.visible')
108111
.find('img')
@@ -220,6 +223,7 @@ describe('Test all attachment insertion methods', () => {
220223

221224
return waitForRequestAndCheckAttachment(requestAlias)
222225
})
226+
cy.closeFile()
223227
})
224228

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

237241
return waitForRequestAndCheckAttachment(requestAlias)
238242
})
243+
cy.closeFile()
239244
})
240245

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

253258
return waitForRequestAndCheckAttachment(requestAlias, undefined, false)
254259
})
260+
cy.closeFile()
255261
})
256262

257263
it('Upload image files with the same name', () => {
@@ -280,8 +286,9 @@ describe('Test all attachment insertion methods', () => {
280286
assertImage(index).then(resolve, reject)
281287
})
282288
})
283-
return cy.getEditor().find('[data-component="image-view"]')
289+
cy.getEditor().find('[data-component="image-view"]')
284290
.should('have.length', 3)
291+
cy.closeFile()
285292
})
286293

287294
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)