Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cypress): close attachments file before proceeding #4734

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion cypress/e2e/attachments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ const checkAttachment = (documentId, fileName, fileId, index, isImage = true) =>
const srcPathEnd = isImage ? 'image' : 'mediaPreview'
const srcFileNameParam = isImage ? 'imageFileName' : 'mediaFileName'

// ensure the image is not hidden behind the menu bar.
cy.wrap($el).scrollIntoView({ offset: { top: -50, left: 0 } })

cy.wrap($el)
.should('be.visible')
.find('img')
Expand Down Expand Up @@ -220,6 +223,7 @@ describe('Test all attachment insertion methods', () => {

return waitForRequestAndCheckAttachment(requestAlias)
})
cy.closeFile()
})

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

return waitForRequestAndCheckAttachment(requestAlias)
})
cy.closeFile()
})

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

return waitForRequestAndCheckAttachment(requestAlias, undefined, false)
})
cy.closeFile()
})

it('Upload image files with the same name', () => {
Expand Down Expand Up @@ -280,8 +286,9 @@ describe('Test all attachment insertion methods', () => {
assertImage(index).then(resolve, reject)
})
})
return cy.getEditor().find('[data-component="image-view"]')
cy.getEditor().find('[data-component="image-view"]')
.should('have.length', 3)
cy.closeFile()
})

it('test if attachment files are in the attachment folder', () => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Cypress.Commands.add('openFileInShare', fileName => {
cy.wait(250)
})

Cypress.Commands.add('closeFile', (fileName, params = {}) => {
Cypress.Commands.add('closeFile', (params = {}) => {
cy.intercept({ method: 'POST', url: '**/apps/text/session/close' })
.as('close')
cy.get('#viewer .modal-header button.header-close').click(params)
Expand All @@ -321,7 +321,7 @@ Cypress.Commands.add('getFile', fileName => {

Cypress.Commands.add('deleteFile', fileName => {
cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] .files-list__row-actions button`).click()
cy.get('.files-list__row-action-delete button').click()
cy.get('.files-list__row-action-delete:visible button').click()
cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"]`).should('not.exist')
})

Expand Down