From 54b347849eab9ae8a5b361281a425c60a056cb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 5 Feb 2024 15:34:48 +0100 Subject: [PATCH] fix(ci): Wait for preview to load to avoid 423 errors when deleting file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- cypress/e2e/groupfolders.cy.ts | 5 +++-- cypress/e2e/groupfoldersUtils.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/groupfolders.cy.ts b/cypress/e2e/groupfolders.cy.ts index 5b5b73c39..4c5766b2b 100644 --- a/cypress/e2e/groupfolders.cy.ts +++ b/cypress/e2e/groupfolders.cy.ts @@ -26,6 +26,7 @@ import { createGroupFolder, deleteGroupFolder, deleteFile, + deleteFolder, enableACLPermissions, enterFolder, enterFolderInTrashbin, @@ -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() @@ -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) diff --git a/cypress/e2e/groupfoldersUtils.ts b/cypress/e2e/groupfoldersUtils.ts index dfd79485a..bff57883f 100644 --- a/cypress/e2e/groupfoldersUtils.ts +++ b/cypress/e2e/groupfoldersUtils.ts @@ -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()