diff --git a/.woodpecker.env b/.woodpecker.env index f10634a5d4..a08970705f 100644 --- a/.woodpecker.env +++ b/.woodpecker.env @@ -1,3 +1,3 @@ # The version of OpenCloud to use in pipelines -OPENCLOUD_COMMITID=4eeee6c337653a84a7223f29f17005a999d03e8a +OPENCLOUD_COMMITID=d209c29239e2cb95e901293723784f58c8d55d7d OPENCLOUD_BRANCH=main diff --git a/tests/e2e/cucumber/features/smoke/trashbinDelete.feature b/tests/e2e/cucumber/features/smoke/trashbinDelete.feature index ee0e5d1b64..25c3ab1315 100644 --- a/tests/e2e/cucumber/features/smoke/trashbinDelete.feature +++ b/tests/e2e/cucumber/features/smoke/trashbinDelete.feature @@ -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 + \ No newline at end of file diff --git a/tests/e2e/cucumber/steps/ui/trashbin.ts b/tests/e2e/cucumber/steps/ui/trashbin.ts new file mode 100644 index 0000000000..89115d6282 --- /dev/null +++ b/tests/e2e/cucumber/steps/ui/trashbin.ts @@ -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 { + 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 { + 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 { + 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) + } +) diff --git a/tests/e2e/support/objects/app-files/trashbin/actions.ts b/tests/e2e/support/objects/app-files/trashbin/actions.ts index 897e0aa4a8..e78ecb23b3 100644 --- a/tests/e2e/support/objects/app-files/trashbin/actions.ts +++ b/tests/e2e/support/objects/app-files/trashbin/actions.ts @@ -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 @@ -10,3 +17,42 @@ export const openTrashbin = async (args: openTrashBinArgs): Promise => { const { id, page } = args await page.locator(util.format(spaceIdSelector, id)).click() } + +export const showEmptyTrashbins = async (page: Page): Promise => { + 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 => { + return await page.locator(util.format(emptyTrashbinQuickActionBtn, space)) +} + +export const emptyTrashbinUsingQuickAction = async ({ + page, + space +}: { + page: Page + space: string +}): Promise => { + 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 => { + return page.locator(footerTextSelector).textContent() +} diff --git a/tests/e2e/support/objects/app-files/trashbin/index.ts b/tests/e2e/support/objects/app-files/trashbin/index.ts index e8831c19b8..2abb938516 100644 --- a/tests/e2e/support/objects/app-files/trashbin/index.ts +++ b/tests/e2e/support/objects/app-files/trashbin/index.ts @@ -1,4 +1,4 @@ -import { Page } from '@playwright/test' +import { Page, Locator } from '@playwright/test' import * as po from './actions' import { SpacesEnvironment } from '../../../environment' @@ -15,4 +15,20 @@ export class Trashbin { const { id } = this.#spacesEnvironment.getSpace({ key }) await po.openTrashbin({ page: this.#page, id }) } + + async showEmptyTrashbins(): Promise { + await po.showEmptyTrashbins(this.#page) + } + + async getEmptyTrashbinLocator(space: string): Promise { + return await po.getEmptyTrashbinLocator({ page: this.#page, space }) + } + + async emptyTrashbinUsingQuickAction(space: string): Promise { + await po.emptyTrashbinUsingQuickAction({ page: this.#page, space }) + } + + getTrashbinListFooterText(): Promise { + return po.getTrashbinListFooterText({ page: this.#page }) + } }