Skip to content

Commit

Permalink
delete multiple resources from trashbin
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwolAmatya committed Feb 8, 2024
1 parent ee0ff0c commit 0c150a6
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions tests/e2e/cucumber/features/smoke/trashbinDelete.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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 |
| lorem-big.txt |
And "Alice" deletes the following resources from trashbin using the batch action
| resource |
| FOLDER |
| PARENT |
| data.tar.gz |
And "Alice" logs out
10 changes: 10 additions & 0 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ When(
}
)

When(
'{string} deletes the following resources from trashbin using the batch action',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
const resources = [].concat(...stepTable.rows())
await resourceObject.deleteTrashbinMultipleResources({ resources })
}
)

Then(
/^"([^"]*)" (should|should not) be able to delete following resource(?:s)? from the trashbin?$/,
async function (
Expand Down
8 changes: 5 additions & 3 deletions tests/e2e/cucumber/steps/ui/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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)
}
}
)

Expand Down
25 changes: 25 additions & 0 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -1081,6 +1082,11 @@ export interface deleteResourceTrashbinArgs {
resource: string
}

export interface deleteTrashbinMultipleResourcesArgs {
page: Page
resources: string[]
}

export const deleteResourceTrashbin = async (args: deleteResourceTrashbinArgs): Promise<string> => {
const { page, resource } = args
const resourceCheckbox = page.locator(
Expand All @@ -1100,6 +1106,25 @@ export const deleteResourceTrashbin = async (args: deleteResourceTrashbinArgs):
return message.trim().toLowerCase()
}

export const deleteTrashbinMultipleResources = async (
args: deleteTrashbinMultipleResourcesArgs
): Promise<void> => {
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 expectThatDeleteButtonIsNotVisible = async (
args: deleteResourceTrashbinArgs
): Promise<void> => {
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ export class Resource {
return message
}

async deleteTrashbinMultipleResources(
args: Omit<po.deleteTrashbinMultipleResourcesArgs, 'page'>
): Promise<void> {
const startUrl = this.#page.url()
await po.deleteTrashbinMultipleResources({ ...args, page: this.#page })
await this.#page.goto(startUrl)
}

async expectThatDeleteTrashBinButtonIsNotVisible(
args: Omit<po.deleteResourceTrashbinArgs, 'page'>
): Promise<void> {
Expand Down

0 comments on commit 0c150a6

Please sign in to comment.