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
2 changes: 1 addition & 1 deletion .woodpecker.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The version of OpenCloud to use in pipelines
OPENCLOUD_COMMITID=4eeee6c337653a84a7223f29f17005a999d03e8a
OPENCLOUD_COMMITID=d209c29239e2cb95e901293723784f58c8d55d7d
OPENCLOUD_BRANCH=main
40 changes: 40 additions & 0 deletions tests/e2e/cucumber/features/smoke/trashbinDelete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,43 @@ Feature: Trashbin delete
| lorem.txt |
And "Brian" logs out
And "Alice" logs out


Scenario: empty trashbin using quick action
Given "Admin" assigns following roles to the users using API
| id | role |
| Brian | Space Admin |
And "Brian" creates the following project space using API
| name | id |
| sales | sales |
| hr | hr |
And "Brian" creates the following folder in space "sales" using API
| name |
| f1 |
And "Brian" logs in

When "Brian" navigates to the project space "sales"
And "Brian" deletes the following resources using the sidebar panel
| resource |
| f1 |

And "Brian" navigates to the trashbin
Then following resources should be displayed in the trashbin for user "Brian"
| resource |
| Personal |
| sales |
| hr |
And "Brian" should see disabled empty trashbin button for space "Personal"

When "Brian" disables the option to show empty trashbins
Then following resources should not be displayed in the trashbin for user "Brian"
| resource |
| Personal |
| hr |
And "Brian" should see the text "3 trash bins in total (including 2 empty)" at the footer of the trashbin page
When "Brian" empties the trashbin for space "sales" using quick action
Then following resources should not be displayed in the trashbin for user "Brian"
| resource |
| sales |
And "Brian" logs out

42 changes: 42 additions & 0 deletions tests/e2e/cucumber/steps/ui/trashbin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { When, Then } from '@cucumber/cucumber'
import { World } from '../../environment'
import { objects } from '../../../support'
import { expect } from '@playwright/test'

When(
'{string} enables/disables the option to show empty trashbins',
async function (this: World, stepUser: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const trashbinObject = new objects.applicationFiles.Trashbin({ page })
await trashbinObject.showEmptyTrashbins()
}
)

Then(
'{string} should see disabled empty trashbin button for space {string}',
async function (this: World, stepUser: string, space: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const trashbinObject = new objects.applicationFiles.Trashbin({ page })
const emptyTrashbinBtn = await trashbinObject.getEmptyTrashbinLocator(space)
await expect(emptyTrashbinBtn).toBeDisabled()
}
)

When(
'{string} empties the trashbin for space {string} using quick action',
async function (this: World, stepUser: string, space: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const trashbinObject = new objects.applicationFiles.Trashbin({ page })
await trashbinObject.emptyTrashbinUsingQuickAction(space)
}
)

Then(
'{string} should see the text {string} at the footer of the trashbin page',
async function (this: World, stepUser: string, expectedText: string) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const trashbinObject = new objects.applicationFiles.Trashbin({ page })
const actualText = await trashbinObject.getTrashbinListFooterText()
expect(actualText).toContain(expectedText)
}
)
48 changes: 47 additions & 1 deletion tests/e2e/support/objects/app-files/trashbin/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { Page } from '@playwright/test'
import { Page, Locator } from '@playwright/test'
import util from 'util'

const spaceIdSelector = '//tr[@data-item-id="%s"]//*[contains(@class, "oc-resource-details")]//a'
const showEmptyTrashbinsButton = '//*[@data-testid="files-switch-projects-show-disabled"]//button'
const filesViewOptionButton = '#files-view-options-btn'
const emptyTrashbinQuickActionBtn =
'//*[@data-test-resource-name="%s"]//ancestor::tr//button[@aria-label="Empty trash bin"]'
const actionConfirmButton = '.oc-modal-body-actions-confirm'
const footerTextSelector = '.oc-table-footer-row'

export interface openTrashBinArgs {
id: string
page: Page
Expand All @@ -10,3 +17,42 @@ export const openTrashbin = async (args: openTrashBinArgs): Promise<void> => {
const { id, page } = args
await page.locator(util.format(spaceIdSelector, id)).click()
}

export const showEmptyTrashbins = async (page: Page): Promise<void> => {
await page.locator(filesViewOptionButton).click()
await page.locator(showEmptyTrashbinsButton).click()
await page.locator(filesViewOptionButton).click()
}

export const getEmptyTrashbinLocator = async ({
page,
space
}: {
page: Page
space: string
}): Promise<Locator> => {
return await page.locator(util.format(emptyTrashbinQuickActionBtn, space))
}

export const emptyTrashbinUsingQuickAction = async ({
page,
space
}: {
page: Page
space: string
}): Promise<void> => {
await page.locator(util.format(emptyTrashbinQuickActionBtn, space)).click()
await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes('trash-bin') &&
resp.status() === 204 &&
resp.request().method() === 'DELETE'
),
page.locator(actionConfirmButton).click()
])
}

export const getTrashbinListFooterText = ({ page }: { page: Page }): Promise<string> => {
return page.locator(footerTextSelector).textContent()
}
18 changes: 17 additions & 1 deletion tests/e2e/support/objects/app-files/trashbin/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page } from '@playwright/test'
import { Page, Locator } from '@playwright/test'
import * as po from './actions'
import { SpacesEnvironment } from '../../../environment'

Expand All @@ -15,4 +15,20 @@ export class Trashbin {
const { id } = this.#spacesEnvironment.getSpace({ key })
await po.openTrashbin({ page: this.#page, id })
}

async showEmptyTrashbins(): Promise<void> {
await po.showEmptyTrashbins(this.#page)
}

async getEmptyTrashbinLocator(space: string): Promise<Locator> {
return await po.getEmptyTrashbinLocator({ page: this.#page, space })
}

async emptyTrashbinUsingQuickAction(space: string): Promise<void> {
await po.emptyTrashbinUsingQuickAction({ page: this.#page, space })
}

getTrashbinListFooterText(): Promise<string> {
return po.getTrashbinListFooterText({ page: this.#page })
}
}