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 9, 2024
1 parent 01bc6d0 commit ae5b184
Show file tree
Hide file tree
Showing 7 changed files with 114 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
40 changes: 40 additions & 0 deletions tests/e2e/cucumber/features/smoke/trashbinDelete.feature
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 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,25 @@ 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 })
}
)

When(
'{string} empties the trashbin',
async function (this: World, stepUser: string): Promise<void> {
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 (
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
36 changes: 36 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 @@ -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,
Expand Down Expand Up @@ -1084,6 +1086,11 @@ export interface deleteResourceTrashbinArgs {
resource: string
}

export interface deleteTrashbinMultipleResourcesArgs
extends Omit<deleteResourceTrashbinArgs, 'resource'> {
resources: string[]
}

export const deleteResourceTrashbin = async (args: deleteResourceTrashbinArgs): Promise<string> => {
const { page, resource } = args
const resourceCheckbox = page.locator(
Expand All @@ -1103,6 +1110,35 @@ 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 emptyTrashbin = async ({ page }): Promise<void> => {
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<void> => {
Expand Down
14 changes: 14 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,20 @@ 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 emptyTrashbin({ page }): Promise<void> {
const startUrl = this.#page.url()
await po.emptyTrashbin({ page })
await this.#page.goto(startUrl)
}

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

0 comments on commit ae5b184

Please sign in to comment.