From 082c8b55a76aec6ebbd97b8d4d1fa43115fabfd0 Mon Sep 17 00:00:00 2001 From: prajwol Date: Wed, 6 Mar 2024 13:07:24 +0545 Subject: [PATCH] added e2e test to delete and restore shared resource --- .../features/smoke/trashbinDelete.feature | 53 +++++++++++++++++-- tests/e2e/cucumber/steps/ui/resources.ts | 15 +++++- .../objects/app-files/resource/actions.ts | 12 +++++ .../objects/app-files/resource/index.ts | 2 + 4 files changed, 76 insertions(+), 6 deletions(-) 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 073346ae5ba..90cef23f061 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -1387,6 +1387,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..8c335a94221 100644 --- a/tests/e2e/support/objects/app-files/resource/index.ts +++ b/tests/e2e/support/objects/app-files/resource/index.ts @@ -189,6 +189,8 @@ export class Resource { return po.getDisplayedResourcesFromSearch(this.#page) } else if (args.keyword === 'Shares') { return po.getDisplayedResourcesFromShares(this.#page) + } else if (args.keyword === 'trashbin') { + return po.getDisplayedResourcesFromTrashbin(this.#page) } else { throw new Error('Unknown keyword') }