diff --git a/cypress/e2e/groupfolders.cy.ts b/cypress/e2e/groupfolders.cy.ts index 4c5766b2b..6a160c030 100644 --- a/cypress/e2e/groupfolders.cy.ts +++ b/cypress/e2e/groupfolders.cy.ts @@ -26,7 +26,9 @@ import { createGroupFolder, deleteGroupFolder, deleteFile, + deleteFileFromTrashbin, deleteFolder, + deleteFolderFromTrashbin, enableACLPermissions, enterFolder, enterFolderInTrashbin, @@ -276,4 +278,42 @@ describe('Groupfolders ACLs and trashbin behavior', () => { cy.visit('/apps/files/trashbin') fileOrFolderDoesNotExistInTrashbin('file1.txt') }) + + it('ACL, delete and delete from trash', () => { + // Create two subfolders and two files as manager + cy.login(managerUser) + cy.mkdir(managerUser, `/${groupFolderName}/subfolder1`) + cy.mkdir(managerUser, `/${groupFolderName}/subfolder1/subfolder2`) + cy.uploadContent(managerUser, new Blob(['Content of the file']), 'text/plain', `/${groupFolderName}/subfolder1/file1.txt`) + cy.uploadContent(managerUser, new Blob(['Content of the file']), 'text/plain', `/${groupFolderName}/subfolder1/subfolder2/file2.txt`) + + // Set ACL permissions + setACLPermissions(groupFolderId, '/subfolder1', [`+${PERMISSION_READ}`,`-${PERMISSION_WRITE}`], undefined, user1.userId) + setACLPermissions(groupFolderId, '/subfolder1', [`-${PERMISSION_READ}`], undefined, user2.userId) + + // Delete files + cy.log('Deleting the files') + cy.logout() + cy.login(managerUser) + cy.visit('/apps/files') + enterFolder(groupFolderName) + enterFolder('subfolder1') + deleteFile('file1.txt') + cy.visit('/apps/files') + enterFolder(groupFolderName) + enterFolder('subfolder1') + deleteFolder('subfolder2') + + // Delete files from trash + cy.log('Deleting the files permanently') + cy.logout() + cy.login(managerUser) + cy.visit('/apps/files/trashbin') + fileOrFolderExistsInTrashbin('file1.txt') + deleteFileFromTrashbin('file1.txt') + fileOrFolderExistsInTrashbin('subfolder2') + deleteFolderFromTrashbin('subfolder2') + fileOrFolderDoesNotExistInTrashbin('file1.txt') + fileOrFolderDoesNotExistInTrashbin('subfolder2') + }) }) diff --git a/cypress/e2e/groupfoldersUtils.ts b/cypress/e2e/groupfoldersUtils.ts index 050536a9e..57a02b3b1 100644 --- a/cypress/e2e/groupfoldersUtils.ts +++ b/cypress/e2e/groupfoldersUtils.ts @@ -119,6 +119,15 @@ export function deleteFolder(name: string) { cy.wait('@delete').its('response.statusCode').should('eq', 204) } +export function deleteFolderFromTrashbin(name: string) { + cy.intercept({ times: 1, method: 'DELETE', url: `**/dav/trashbin/**/${name}.d*` }).as('delete') + cy.get(`[data-cy-files-list] [data-cy-files-list-row-name^="${name}.d"] [data-cy-files-list-row-actions] button:not([data-cy-files-list-row-action])`).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 @@ -135,6 +144,22 @@ export function deleteFile(name: string) { cy.wait('@delete').its('response.statusCode').should('eq', 204) } +export function deleteFileFromTrashbin(name: string) { + cy.intercept({ times: 1, method: 'DELETE', url: `**/dav/trashbin/**/${name}.d*` }).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}.d"] .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}.d"] [data-cy-files-list-row-actions] button:not([data-cy-files-list-row-action])`).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 restoreFile(name: string) { cy.get(`[data-cy-files-list] [data-cy-files-list-row-name^="${name}.d"] [data-cy-files-list-row-action="restore"]`).click() }