From 6801666c1ca5582f3f36b6a969a9fffb08e40d11 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya <83579989+PrajwolAmatya@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:05:02 +0545 Subject: [PATCH] [test-only][full-ci] added e2e test to delete and restore file inside a shared folder (#10550) * delete webUI test scenario related to delete and restore shared resource * added e2e test to delete and restore shared resource --- ...-failures-with-ocis-server-ocis-storage.md | 4 -- .../trashbinRestore.feature | 17 ------ .../features/smoke/trashbinDelete.feature | 53 +++++++++++++++++-- tests/e2e/cucumber/steps/ui/resources.ts | 15 +++++- .../objects/app-files/resource/actions.ts | 14 ++++- .../objects/app-files/resource/index.ts | 19 ++++--- 6 files changed, 86 insertions(+), 36 deletions(-) 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 2669428e6f4..6cbe18daaa3 100644 --- a/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md +++ b/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md @@ -13,10 +13,6 @@ Other free text and markdown formatting can be used elsewhere in the document if - [webUILogin/openidLogin.feature:50](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUILogin/openidLogin.feature#L50) - [webUILogin/openidLogin.feature:60](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUILogin/openidLogin.feature#L60) -### [restoring a file deleted from a received shared folder is not possible](https://github.com/owncloud/ocis/issues/1124) - -- [webUITrashbinRestore/trashbinRestore.feature:176](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUITrashbinRestore/trashbinRestore.feature#L176) - ### [empty subfolder inside a folder to be uploaded is not created on the server](https://github.com/owncloud/web/issues/6348) - [webUIUpload/upload.feature:36](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIUpload/upload.feature#L36) diff --git a/tests/acceptance/features/webUITrashbinRestore/trashbinRestore.feature b/tests/acceptance/features/webUITrashbinRestore/trashbinRestore.feature index d066dd75ec6..ba22de7afb0 100644 --- a/tests/acceptance/features/webUITrashbinRestore/trashbinRestore.feature +++ b/tests/acceptance/features/webUITrashbinRestore/trashbinRestore.feature @@ -172,23 +172,6 @@ Feature: Restore deleted files/folders Then folder "lorem.txt" should be listed on the webUI And file "lorem.txt" should not be listed on the webUI - @issue-ocis-1124 - Scenario: delete and restore a file inside a received shared folder - Given the administrator has set the default folder for received shares to "Shares" in the server - And user "Carol" has been created with default attributes and without skeleton files in the server - And user "Carol" has created folder "folder-to-share" in the server - And user "Carol" has uploaded file with content "does-not-matter" to "folder-to-share/fileToShare.txt" in the server - And user "Carol" has shared folder "folder-to-share" with user "Alice" in the server - And the user has reloaded the current page of the webUI - When the user opens folder "Shares" using the webUI - And the user opens folder "folder-to-share" using the webUI - And the user deletes file "fileToShare.txt" using the webUI - And the user browses to the trashbin page - Then as "Alice" file "fileToShare.txt" should exist in the trashbin in the server - When the user restores file "…/folder-to-share/fileToShare.txt" from the trashbin using the webUI - Then the "success" message with header "fileToShare.txt was restored successfully" should be displayed on the webUI - And as "Alice" file "/Shares/folder-to-share/fileToShare.txt" should exist in the server - @issue-1502 Scenario: Delete and restore folders with dot in the name Given user "Alice" has created the following folders in the server diff --git a/tests/e2e/cucumber/features/smoke/trashbinDelete.feature b/tests/e2e/cucumber/features/smoke/trashbinDelete.feature index 640f844fef1..7cbaf895f23 100644 --- a/tests/e2e/cucumber/features/smoke/trashbinDelete.feature +++ b/tests/e2e/cucumber/features/smoke/trashbinDelete.feature @@ -3,14 +3,16 @@ Feature: Trashbin delete 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 + Background: + Given "Admin" creates following user using API | id | | Alice | + | Brian | And "Alice" logs in - And "Alice" creates the following resources + + + Scenario: delete files and folders from trashbin + Given "Alice" creates the following resources | resource | type | | FOLDER | folder | | PARENT/CHILD | folder | @@ -38,3 +40,44 @@ Feature: Trashbin delete | PARENT | And "Alice" empties the trashbin And "Alice" logs out + + + Scenario: delete and restore a file inside a received shared folder + Given "Alice" creates the following resources + | resource | type | + | folderToShare | folder | + And "Alice" uploads the following resource + | resource | to | + | lorem.txt | folderToShare | + And "Alice" shares the following resource using the sidebar panel + | resource | recipient | type | role | resourceType | + | folderToShare | Brian | user | Can edit | folder | + And "Brian" logs in + And "Brian" navigates to the shared with me page + And "Brian" opens folder "folderToShare" + When "Brian" deletes the following resources using the sidebar panel + | resource | + | lorem.txt | + And "Brian" navigates to the trashbin + Then following resources should not be displayed in the trashbin for user "Brian" + | resource | + | folderToShare/lorem.txt | + And "Alice" navigates to the trashbin + And following resources should be displayed in the trashbin for user "Alice" + | resource | + | folderToShare/lorem.txt | + And "Alice" restores the following resource from trashbin + | resource | + | folderToShare/lorem.txt | + And "Alice" opens the "files" app + And "Alice" opens folder "folderToShare" + And following resources should be displayed in the files list for user "Alice" + | resource | + | lorem.txt | + And "Brian" navigates to the shared with me page + And "Brian" opens folder "folderToShare" + And following resources should be displayed in the files list for user "Brian" + | resource | + | lorem.txt | + And "Brian" logs out + And "Alice" logs out diff --git a/tests/e2e/cucumber/steps/ui/resources.ts b/tests/e2e/cucumber/steps/ui/resources.ts index 82b0a8606ba..1545527a522 100644 --- a/tests/e2e/cucumber/steps/ui/resources.ts +++ b/tests/e2e/cucumber/steps/ui/resources.ts @@ -298,6 +298,19 @@ Then( } ) +Then( + '{string} restores the following resource from trashbin', + async function (this: World, stepUser: string, stepTable: DataTable): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const resourceObject = new objects.applicationFiles.Resource({ page }) + for (const info of stepTable.hashes()) { + const message = await resourceObject.restoreTrashBin({ resource: info.resource }) + const paths = info.resource.split('/') + expect(message).toBe(`${paths[paths.length - 1]} was restored successfully`) + } + } +) + When( /^"([^"]*)" searches "([^"]*)" using the global search(?: and the "([^"]*)" filter)?( and presses enter)?$/, async function ( @@ -320,7 +333,7 @@ When( ) Then( - /^following resources (should|should not) be displayed in the (search list|files list|Shares) for user "([^"]*)"$/, + /^following resources (should|should not) be displayed in the (search list|files list|Shares|trashbin) for user "([^"]*)"$/, async function ( this: World, actionType: string, diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index bb723a88f1c..e5dcfb1b807 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -1341,7 +1341,7 @@ export const searchResourceGlobalSearch = async ( } } -export type displayedResourceType = 'search list' | 'files list' +export type displayedResourceType = 'search list' | 'files list' | 'Shares' | 'trashbin' export interface getDisplayedResourcesArgs { keyword: displayedResourceType @@ -1382,6 +1382,18 @@ export const getDisplayedResourcesFromShares = async (page): Promise = return files } +export const getDisplayedResourcesFromTrashbin = async (page): Promise => { + const files = [] + const result = await page.locator('[data-test-resource-path]') + + const count = await result.count() + for (let i = 0; i < count; i++) { + files.push(await result.nth(i).getAttribute('data-test-resource-name')) + } + + return files +} + export interface switchViewModeArgs { page: Page target: 'resource-table' | 'resource-tiles' diff --git a/tests/e2e/support/objects/app-files/resource/index.ts b/tests/e2e/support/objects/app-files/resource/index.ts index dce63168cfb..06360da719c 100644 --- a/tests/e2e/support/objects/app-files/resource/index.ts +++ b/tests/e2e/support/objects/app-files/resource/index.ts @@ -183,14 +183,17 @@ export class Resource { } getDisplayedResources(args: Omit): Promise { - if (args.keyword === 'files list') { - return po.getDisplayedResourcesFromFilesList(this.#page) - } else if (args.keyword === 'search list') { - return po.getDisplayedResourcesFromSearch(this.#page) - } else if (args.keyword === 'Shares') { - return po.getDisplayedResourcesFromShares(this.#page) - } else { - throw new Error('Unknown keyword') + switch (args.keyword) { + case 'files list': + return po.getDisplayedResourcesFromFilesList(this.#page) + case 'search list': + return po.getDisplayedResourcesFromSearch(this.#page) + case 'Shares': + return po.getDisplayedResourcesFromShares(this.#page) + case 'trashbin': + return po.getDisplayedResourcesFromTrashbin(this.#page) + default: + throw new Error('Unknown keyword') } }