Skip to content

Commit

Permalink
added e2e test to delete and restore shared resource
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwolAmatya committed Mar 6, 2024
1 parent aa08e1f commit 082c8b5
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
53 changes: 48 additions & 5 deletions tests/e2e/cucumber/features/smoke/trashbinDelete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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
15 changes: 14 additions & 1 deletion tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@ Then(
}
)

Then(
'{string} restores the following resource from trashbin',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
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 (
Expand All @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,18 @@ export const getDisplayedResourcesFromShares = async (page): Promise<string[]> =
return files
}

export const getDisplayedResourcesFromTrashbin = async (page): Promise<string[]> => {
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'
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down

0 comments on commit 082c8b5

Please sign in to comment.