Skip to content

Commit

Permalink
fix(ci): Wait for preview to load to avoid 423 errors when deleting file
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Feb 5, 2024
1 parent db33f9b commit 54b3478
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cypress/e2e/groupfolders.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
createGroupFolder,
deleteGroupFolder,
deleteFile,
deleteFolder,
enableACLPermissions,
enterFolder,
enterFolderInTrashbin,
Expand Down Expand Up @@ -126,7 +127,7 @@ describe('Groupfolders ACLs and trashbin behavior', () => {
cy.visit('/apps/files')
enterFolder(groupFolderName)
enterFolder('subfolder1')
deleteFile('subfolder2')
deleteFolder('subfolder2')

// User1 sees it in trash
cy.logout()
Expand Down Expand Up @@ -186,7 +187,7 @@ describe('Groupfolders ACLs and trashbin behavior', () => {
cy.login(managerUser)
cy.visit('/apps/files')
enterFolder(groupFolderName)
deleteFile('subfolder1')
deleteFolder('subfolder1')

// User1 sees it in trash
cy.login(user1)
Expand Down
16 changes: 16 additions & 0 deletions cypress/e2e/groupfoldersUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,24 @@ export function enterFolderInTrashbin(name: string) {
cy.wait('@propFindFolder')
}

export function deleteFolder(name: string) {
cy.intercept({ times: 1, method: 'DELETE', url: `**/dav/files/**/${name}` }).as('delete')
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${name}"] [data-cy-files-list-row-actions]`).click()
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="delete"]`).should('be.visible')
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="delete"]`).scrollIntoView()
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="delete"]`).click()
cy.wait('@delete').its('response.statusCode').should('eq', 204)
}

export function deleteFile(name: string) {
cy.intercept({ times: 1, method: 'DELETE', url: `**/dav/files/**/${name}` }).as('delete')
// For files wait for preview to load and release lock
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${name}"] .files-list__row-icon img`)
.should('be.visible')
.and(($img) => {
// "naturalWidth" and "naturalHeight" are set when the image loads
expect($img[0].naturalWidth, 'image has natural width').to.be.greaterThan(0)
})
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${name}"] [data-cy-files-list-row-actions]`).click()
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="delete"]`).should('be.visible')
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="delete"]`).scrollIntoView()
Expand Down

0 comments on commit 54b3478

Please sign in to comment.