From ae5b184b404282785954a918fd5f498e1f9e4151 Mon Sep 17 00:00:00 2001 From: prajwol Date: Wed, 7 Feb 2024 17:08:55 +0545 Subject: [PATCH] delete multiple resources from trashbin --- ...-failures-with-ocis-server-ocis-storage.md | 5 --- .../trashbinDelete.feature | 22 ---------- .../features/smoke/trashbinDelete.feature | 40 +++++++++++++++++++ tests/e2e/cucumber/steps/ui/resources.ts | 19 +++++++++ tests/e2e/cucumber/steps/ui/spaces.ts | 8 ++-- .../objects/app-files/resource/actions.ts | 36 +++++++++++++++++ .../objects/app-files/resource/index.ts | 14 +++++++ 7 files changed, 114 insertions(+), 30 deletions(-) create mode 100644 tests/e2e/cucumber/features/smoke/trashbinDelete.feature diff --git a/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md b/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md index f33c5ab6072..b808f0986f2 100644 --- a/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md +++ b/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md @@ -17,11 +17,6 @@ Other free text and markdown formatting can be used elsewhere in the document if - [webUITrashbinRestore/trashbinRestore.feature:176](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUITrashbinRestore/trashbinRestore.feature#L176) -### [Deletion of a recursive folder from trashbin is not possible](https://github.com/owncloud/product/issues/188) - -- [webUITrashbinDelete/trashbinDelete.feature:51](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUITrashbinDelete/trashbinDelete.feature#L51) -- [webUITrashbinDelete/trashbinDelete.feature:65](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUITrashbinDelete/trashbinDelete.feature#L65) - ### [Saving public share is not possible](https://github.com/owncloud/web/issues/5321) - [webUISharingPublicManagement/shareByPublicLink.feature:24](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingPublicManagement/shareByPublicLink.feature#L24) diff --git a/tests/acceptance/features/webUITrashbinDelete/trashbinDelete.feature b/tests/acceptance/features/webUITrashbinDelete/trashbinDelete.feature index b2ecc756059..082a66f0ce9 100644 --- a/tests/acceptance/features/webUITrashbinDelete/trashbinDelete.feature +++ b/tests/acceptance/features/webUITrashbinDelete/trashbinDelete.feature @@ -46,28 +46,6 @@ Feature: files and folders can be deleted from the trashbin And file "lorem.txt" should not be listed on the webUI And file "lorem-big.txt" should not be listed on the webUI - @skipOnOC10 @issue-product-188 - # after the issue is fixed delete this scenario and use the one above - Scenario: Select all except for some files and delete from trashbin in a batch (ocis bug demonstration) - When the user marks all files for batch action using the webUI - And the user unmarks these files for batch action using the webUI - | name | - | lorem.txt | - | lorem-big.txt | - And the user batch deletes the marked files permanently using the webUI - Then file "lorem.txt" should be listed on the webUI - And file "lorem-big.txt" should be listed on the webUI - But folder "simple-folder" should be listed on the webUI - And file "data.zip" should not be listed on the webUI - - @skipOnOC10 @issue-product-188 - # after the issue is fixed delete this scenario and use the one above - Scenario: Select all files and delete from trashbin in a batch (ocis bug demonstration) - When the user marks all files for batch action using the webUI - And the user batch deletes the marked files permanently using the webUI - Then file "lorem.txt" should not be listed on the webUI - But folder "simple-folder" should be listed on the webUI - @issue-4437 Scenario: Delete single file from deleted files list When the user deletes the file "lorem.txt" from the deleted files list diff --git a/tests/e2e/cucumber/features/smoke/trashbinDelete.feature b/tests/e2e/cucumber/features/smoke/trashbinDelete.feature new file mode 100644 index 00000000000..640f844fef1 --- /dev/null +++ b/tests/e2e/cucumber/features/smoke/trashbinDelete.feature @@ -0,0 +1,40 @@ +Feature: Trashbin delete + As a user + I want to delete files and folders from the trashbin + So that I can control my trashbin space and which files are kept in that space + + + Scenario: delete files and folders from trashbin + Given "Admin" logs in + And "Admin" creates following user using API + | id | + | Alice | + And "Alice" logs in + And "Alice" creates the following resources + | resource | type | + | FOLDER | folder | + | PARENT/CHILD | folder | + And "Alice" uploads the following resources + | resource | to | + | new-lorem.txt | FOLDER | + | PARENT/parent.txt | PARENT | + | PARENT/simple.pdf | PARENT | + | PARENT/CHILD/child.txt | PARENT/CHILD | + | data.tar.gz | | + | lorem.txt | | + | lorem-big.txt | | + And "Alice" opens the "files" app + And "Alice" deletes the following resources using the batch action + | resource | + | FOLDER | + | PARENT | + | data.tar.gz | + | lorem.txt | + | lorem-big.txt | + And "Alice" navigates to the trashbin + When "Alice" deletes the following resources from trashbin using the batch action + | resource | + | lorem.txt | + | PARENT | + And "Alice" empties the trashbin + And "Alice" logs out diff --git a/tests/e2e/cucumber/steps/ui/resources.ts b/tests/e2e/cucumber/steps/ui/resources.ts index fbde77b1853..ff5019fcccc 100644 --- a/tests/e2e/cucumber/steps/ui/resources.ts +++ b/tests/e2e/cucumber/steps/ui/resources.ts @@ -230,6 +230,25 @@ When( } ) +When( + '{string} deletes the following resources from trashbin using the batch action', + async function (this: World, stepUser: string, stepTable: DataTable): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const resourceObject = new objects.applicationFiles.Resource({ page }) + const resources = [].concat(...stepTable.rows()) + await resourceObject.deleteTrashbinMultipleResources({ resources }) + } +) + +When( + '{string} empties the trashbin', + async function (this: World, stepUser: string): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const resourceObject = new objects.applicationFiles.Resource({ page }) + await resourceObject.emptyTrashbin({ page }) + } +) + Then( /^"([^"]*)" (should|should not) be able to delete following resource(?:s)? from the trashbin?$/, async function ( diff --git a/tests/e2e/cucumber/steps/ui/spaces.ts b/tests/e2e/cucumber/steps/ui/spaces.ts index a86a2696c50..19b85f4521f 100644 --- a/tests/e2e/cucumber/steps/ui/spaces.ts +++ b/tests/e2e/cucumber/steps/ui/spaces.ts @@ -154,13 +154,15 @@ When( ) When( - '{string} navigates to the trashbin of the project space {string}', + /^"([^"]*)" navigates to the trashbin(| of the project space "([^"]*)")$/, async function (this: World, stepUser: string, key: string): Promise { const { page } = this.actorsEnvironment.getActor({ key: stepUser }) const pageObject = new objects.applicationFiles.page.trashbin.Overview({ page }) await pageObject.navigate() - const trashbinObject = new objects.applicationFiles.Trashbin({ page }) - await trashbinObject.open(key) + if (key) { + const trashbinObject = new objects.applicationFiles.Trashbin({ page }) + await trashbinObject.open(key) + } } ) diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 671d6e40121..20b79e98705 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -20,6 +20,7 @@ const deleteButtonBatchAction = '.oc-files-actions-delete-trigger' const createSpaceFromResourceAction = '.oc-files-actions-create-space-from-resource-trigger' const checkBox = `//*[@data-test-resource-name="%s"]//ancestor::tr//input` const checkBoxForTrashbin = `//*[@data-test-resource-path="%s"]//ancestor::tr//input` +const filesSelector = '//*[@data-test-resource-name="%s"]' export const fileRow = '//ancestor::*[(contains(@class, "oc-tile-card") or contains(@class, "oc-tbody-tr"))]' export const resourceNameSelector = @@ -110,6 +111,7 @@ const onlyOfficeCanvasCursorSelector = '#id_target_cursor' const collaboraCanvasEditorSelector = '.leaflet-layer' const filesContextMenuAction = 'div[id^="context-menu-drop"] button.oc-files-actions-%s-trigger' const highlightedFileRowSelector = '#files-space-table tr.oc-table-highlighted' +const emptyTrashbinButtonSelector = '.oc-files-actions-empty-trash-bin-trigger' export const clickResource = async ({ page, @@ -1084,6 +1086,11 @@ export interface deleteResourceTrashbinArgs { resource: string } +export interface deleteTrashbinMultipleResourcesArgs + extends Omit { + resources: string[] +} + export const deleteResourceTrashbin = async (args: deleteResourceTrashbinArgs): Promise => { const { page, resource } = args const resourceCheckbox = page.locator( @@ -1103,6 +1110,35 @@ export const deleteResourceTrashbin = async (args: deleteResourceTrashbinArgs): return message.trim().toLowerCase() } +export const deleteTrashbinMultipleResources = async ( + args: deleteTrashbinMultipleResourcesArgs +): Promise => { + const { page, resources } = args + for (const resource of resources) { + await page.locator(util.format(checkBox, resource)).click() + } + + await page.locator(permanentDeleteButton).first().click() + await Promise.all([ + page.waitForResponse((resp) => resp.status() === 204 && resp.request().method() === 'DELETE'), + page.locator(util.format(actionConfirmationButton, 'Delete')).click() + ]) + + for (const resource of resources) { + await expect(page.locator(util.format(filesSelector, resource))).not.toBeVisible() + } +} + +export const emptyTrashbin = async ({ page }): Promise => { + await page.locator(emptyTrashbinButtonSelector).click() + await Promise.all([ + page.waitForResponse((resp) => resp.status() === 204 && resp.request().method() === 'DELETE'), + page.locator(util.format(actionConfirmationButton, 'Delete')).click() + ]) + const message = await page.locator(notificationMessageDialog).textContent() + expect(message).toBe('All deleted files were removed') +} + export const expectThatDeleteButtonIsNotVisible = async ( args: deleteResourceTrashbinArgs ): Promise => { diff --git a/tests/e2e/support/objects/app-files/resource/index.ts b/tests/e2e/support/objects/app-files/resource/index.ts index dfb17427c1c..30a640ee6fa 100644 --- a/tests/e2e/support/objects/app-files/resource/index.ts +++ b/tests/e2e/support/objects/app-files/resource/index.ts @@ -130,6 +130,20 @@ export class Resource { return message } + async deleteTrashbinMultipleResources( + args: Omit + ): Promise { + const startUrl = this.#page.url() + await po.deleteTrashbinMultipleResources({ ...args, page: this.#page }) + await this.#page.goto(startUrl) + } + + async emptyTrashbin({ page }): Promise { + const startUrl = this.#page.url() + await po.emptyTrashbin({ page }) + await this.#page.goto(startUrl) + } + async expectThatDeleteTrashBinButtonIsNotVisible( args: Omit ): Promise {