Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions tests/e2e/cucumber/features/file-action/delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,54 @@ Feature: Delete
| resource |
| textfile.txt |
And "Alice" logs out


Scenario: quick restore deleted files
Given "Admin" assigns following roles to the users using API
| id | role |
| Alice | Space Admin |
And "Alice" creates the following folder in personal space using API
| name |
| my-folder |
And "Alice" uploads the following local file into personal space using API
| localFile | to |
| testavatar.jpg | testavatar.jpg |
| simple.pdf | my-folder/simple.pdf |
And "Alice" creates the following project spaces using API
| name | id |
| mySpace | mySpace |
And "Alice" creates the following folder in space "mySpace" using API
| name |
| spaceFolder |
And "Alice" creates the following file in space "mySpace" using API
| name | content |
| spaceFile.txt | test content |

When "Alice" logs in
And "Alice" deletes and immediately undoes the following resource using "undo button"
| resource |
| testavatar.jpg |
And "Alice" deletes and immediately undoes the following resources using "keyboard"
| resource |
| testavatar.jpg |
| my-folder |
And following resources should be displayed in the files list for user "Alice"
| resource |
| testavatar.jpg |
| my-folder |

And "Alice" navigates to the project space "mySpace"
And "Alice" deletes and immediately undoes the following resources using "undo button"
| resource |
| spaceFile.txt |
| spaceFolder |

And "Alice" deletes and immediately undoes the following resources using "keyboard"
| resource |
| spaceFile.txt |
| spaceFolder |
And following resources should be displayed in the files list for user "Alice"
| resource |
| spaceFile.txt |
| spaceFolder |
And "Alice" logs out
22 changes: 22 additions & 0 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1122,3 +1122,25 @@ When(
await resourceObject.openResourcePanel(panel as PanelType, resource)
}
)

When(
'{string} deletes and immediately undoes the following resource(s) using {string}',
async function (
this: World,
stepUser: string,
method: 'keyboard' | 'undo button',
stepTable: DataTable
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
const resources = stepTable.hashes().map((row) => ({
name: row.resource
}))

await resourceObject.deleteAndUndoResource({
method,
resourcesWithInfo: resources,
via: 'BATCH_ACTION'
})
}
)
37 changes: 36 additions & 1 deletion tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const contextMenuAction = '//*[@id="oc-files-context-actions-context"]//span[tex
const openWithAction = '.oc-files-actions-%s-trigger'
const openWithButton = '//*[@id="oc-files-context-actions-context"]//span[text()="Open with..."]'
const tilesSlider = '#tiles-size-slider'
const undoBtn = 'action-handler'

export const clickResource = async ({
page,
Expand Down Expand Up @@ -742,7 +743,7 @@ export const cancelResourceUpload = async (page: Page): Promise<void> => {

/**/

interface resourceArgs {
export interface resourceArgs {
name: string
type?: string
}
Expand Down Expand Up @@ -2306,3 +2307,37 @@ export const openResourcePanel = async ({
await sidebar.open({ page, resource })
await sidebar.openPanel({ page, name: panel })
}

export const deleteAndUndo = async ({
page,
method,
resourcesWithInfo,
via,
folder
}: {
page: Page
method: 'keyboard' | 'undo button'
resourcesWithInfo: resourceArgs[]
via: ActionViaType
folder?: string
}): Promise<void> => {
await deleteResource({
page,
resourcesWithInfo,
via,
folder
})

const undoButton = page.getByTestId(undoBtn)
await expect(undoButton.first()).toBeVisible()

const responsePromise = page.waitForResponse(
(resp) => resp.request().method() === 'MOVE' && resp.status() === 201
)
if (method === 'keyboard') {
await page.keyboard.press('ControlOrMeta+z')
} else {
await undoButton.first().click()
}
await responsePromise
}
16 changes: 15 additions & 1 deletion tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class Resource {
const startUrl = this.#page.url()
const downloads = await po.downloadResources({ ...args, page: this.#page })
await this.#page.goto(startUrl)

return downloads
}

Expand Down Expand Up @@ -417,4 +416,19 @@ export class Resource {
async openResourcePanel(panel: PanelType, resource: string): Promise<void> {
await po.openResourcePanel({ page: this.#page, resource, panel })
}

async deleteAndUndoResource(args: {
method: 'keyboard' | 'undo button'
resourcesWithInfo: po.resourceArgs[]
via: po.ActionViaType
folder?: string
}): Promise<void> {
await po.deleteAndUndo({
page: this.#page,
method: args.method,
resourcesWithInfo: args.resourcesWithInfo,
via: args.via,
folder: args.folder
})
}
}
Loading