From 1f633d6410e7fffc729b3f7d921f1e2bb18835eb Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Fri, 20 Jun 2025 11:43:54 +0200 Subject: [PATCH] detect and delete unused steps --- package.json | 3 +- tests/e2e/cucumber/steps/api.ts | 39 ------------------- tests/e2e/cucumber/steps/ui/adminSettings.ts | 9 ----- tests/e2e/cucumber/steps/ui/links.ts | 31 --------------- tests/e2e/cucumber/steps/ui/public.ts | 31 --------------- tests/e2e/cucumber/steps/ui/resources.ts | 23 ----------- tests/e2e/cucumber/steps/ui/session.ts | 4 -- tests/e2e/cucumber/steps/ui/shares.ts | 9 ----- .../support/objects/app-files/link/actions.ts | 20 ---------- .../support/objects/app-files/link/index.ts | 9 ----- .../support/objects/app-files/page/public.ts | 10 ----- .../objects/app-files/page/shares/withMe.ts | 12 ------ .../objects/app-files/resource/actions.ts | 37 ------------------ .../objects/app-files/resource/index.ts | 12 ------ .../support/objects/app-files/share/index.ts | 6 +-- .../support/objects/app-files/share/utils.ts | 20 ---------- 16 files changed, 3 insertions(+), 272 deletions(-) diff --git a/package.json b/package.json index 9f479efeb5..3dbdfedd89 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "licenses:save": "license-checker-rseidelsohn --relativeLicensePath --out /dev/null --files ./third-party-licenses/third-party-licenses", "vite": "vue-demi-fix && vite", "check:types": "pnpm build:tokens && vue-tsc --noEmit", - "check:all": "pnpm check:types && pnpm lint --fix && pnpm format:write && pnpm test:unit" + "check:all": "pnpm check:types && pnpm lint --fix && pnpm format:write && pnpm test:unit", + "check:unused-steps": "TS_NODE_PROJECT=./tests/e2e/cucumber/tsconfig.json cucumber-js --profile=e2e --format usage --dry-run tests/e2e/cucumber/features/*/*.feature" }, "browserslist": [ "last 1 year", diff --git a/tests/e2e/cucumber/steps/api.ts b/tests/e2e/cucumber/steps/api.ts index ca927a6c22..3eb820d9d9 100644 --- a/tests/e2e/cucumber/steps/api.ts +++ b/tests/e2e/cucumber/steps/api.ts @@ -214,26 +214,6 @@ Given( } ) -Given( - '{string} creates {int} file(s) in space {string} using API', - async function ( - this: World, - stepUser: string, - numberOfFiles: number, - space: string - ): Promise { - const user = this.usersEnvironment.getCreatedUser({ key: stepUser }) - for (let i = 1; i <= numberOfFiles; i++) { - await api.dav.uploadFileInsideSpaceBySpaceName({ - user, - pathToFile: `testfile${i}.txt`, - spaceName: space, - content: `This is a test file${i}` - }) - } - } -) - Given( '{string} creates the following folder(s) in space {string} using API', async function ( @@ -253,25 +233,6 @@ Given( } ) -Given( - '{string} creates {int} folders(s) in space {string} using API', - async function ( - this: World, - stepUser: string, - numberOfFolders: number, - space: string - ): Promise { - const user = this.usersEnvironment.getCreatedUser({ key: stepUser }) - for (let i = 1; i <= numberOfFolders; i++) { - await api.dav.createFolderInsideSpaceBySpaceName({ - user, - folder: `testFolder${i}`, - spaceName: space - }) - } - } -) - Given( '{string} adds the following member(s) to the space {string} using API', async function ( diff --git a/tests/e2e/cucumber/steps/ui/adminSettings.ts b/tests/e2e/cucumber/steps/ui/adminSettings.ts index 8da95ca21e..e59acd42ac 100644 --- a/tests/e2e/cucumber/steps/ui/adminSettings.ts +++ b/tests/e2e/cucumber/steps/ui/adminSettings.ts @@ -155,15 +155,6 @@ When( } ) -When( - '{string} navigates to the general management page', - async function (this: World, stepUser: string): Promise { - const { page } = this.actorsEnvironment.getActor({ key: stepUser }) - const pageObject = new objects.applicationAdminSettings.page.General({ page }) - await pageObject.navigate() - } -) - When( '{string} changes the quota of the user {string} to {string} using the sidebar panel', async function (this: World, stepUser: string, key: string, value: string): Promise { diff --git a/tests/e2e/cucumber/steps/ui/links.ts b/tests/e2e/cucumber/steps/ui/links.ts index 83f3e6c5a8..5a06d82e0e 100644 --- a/tests/e2e/cucumber/steps/ui/links.ts +++ b/tests/e2e/cucumber/steps/ui/links.ts @@ -166,28 +166,6 @@ When( } ) -Then( - 'public link named {string} should be visible to {string}', - async function (this: World, linkName: string, stepUser: any): Promise { - const { page } = this.actorsEnvironment.getActor({ key: stepUser }) - const expectedPublicLink = this.linksEnvironment.getLink({ name: linkName }) - const linkObject = new objects.applicationFiles.Link({ page }) - const actualPublicLink = await linkObject.getPublicLinkUrl({ linkName, space: true }) - expect(actualPublicLink).toBe(expectedPublicLink) - } -) - -Then( - 'public link named {string} of the resource {string} should be visible to {string}', - async function (this: World, linkName: string, resource: string, stepUser: any): Promise { - const { page } = this.actorsEnvironment.getActor({ key: stepUser }) - const expectedPublicLink = this.linksEnvironment.getLink({ name: linkName }) - const linkObject = new objects.applicationFiles.Link({ page }) - const actualPublicLink = await linkObject.getPublicLinkUrl({ linkName, resource }) - expect(actualPublicLink).toBe(expectedPublicLink) - } -) - Then( /^"([^"]*)" (should|should not) be able to edit the public link named "([^"]*)"$/, async function ( @@ -223,15 +201,6 @@ When( } ) -When( - '{string} opens shared-with-me page from the internal link', - async function (this: World, stepUser: string): Promise { - const actor = this.actorsEnvironment.getActor({ key: stepUser }) - const pageObject = new objects.applicationFiles.page.shares.WithMe({ page: actor.page }) - await pageObject.openShareWithMeFromInternalLink(actor) - } -) - When( '{string} copies the link {string} of resource {string}', async function ( diff --git a/tests/e2e/cucumber/steps/ui/public.ts b/tests/e2e/cucumber/steps/ui/public.ts index e495e68da1..3184d10cdf 100644 --- a/tests/e2e/cucumber/steps/ui/public.ts +++ b/tests/e2e/cucumber/steps/ui/public.ts @@ -165,28 +165,6 @@ When( } ) -When( - '{string} uploads the following resource(s) in internal link named {string}', - async function ( - this: World, - stepUser: string, - link: string, - stepTable: DataTable - ): Promise { - const { page } = this.actorsEnvironment.getActor({ key: stepUser }) - const pageObject = new objects.applicationFiles.page.Public({ page }) - const { url } = this.linksEnvironment.getLink({ name: link }) - for (const info of stepTable.hashes()) { - await pageObject.uploadInternal({ - to: info.to, - resources: [this.filesEnvironment.getFile({ name: info.resource })], - option: info.option, - link: url - }) - } - } -) - Then( '{string} should not be able to open the old link {string}', async function (this: World, stepUser: string, name: string): Promise { @@ -210,12 +188,3 @@ When( await processDelete(stepTable, pageObject, actionType) } ) - -Then( - 'for {string} file {string} should be selected', - async function (this: World, stepUser: string, fileName: string): Promise { - const { page } = this.actorsEnvironment.getActor({ key: stepUser }) - const resourceObject = new objects.applicationFiles.Resource({ page }) - await resourceObject.expectFileToBeSelected({ fileName: fileName }) - } -) diff --git a/tests/e2e/cucumber/steps/ui/resources.ts b/tests/e2e/cucumber/steps/ui/resources.ts index f235ac403e..441099302d 100644 --- a/tests/e2e/cucumber/steps/ui/resources.ts +++ b/tests/e2e/cucumber/steps/ui/resources.ts @@ -731,29 +731,6 @@ When( } ) -Then( - '{string} should not see the version of the file(s)', - async function (this: World, stepUser: string, stepTable: DataTable): Promise { - const { page } = this.actorsEnvironment.getActor({ key: stepUser }) - const resourceObject = new objects.applicationFiles.Resource({ page }) - const fileInfo = stepTable.hashes().reduce>((acc, stepRow) => { - const { to, resource } = stepRow - - if (!acc[to]) { - acc[to] = [] - } - - acc[to].push(this.filesEnvironment.getFile({ name: resource })) - - return acc - }, {}) - - for (const folder of Object.keys(fileInfo)) { - await resourceObject.checkThatFileVersionIsNotAvailable({ folder, files: fileInfo[folder] }) - } - } -) - Then( '{string} should not see the version panel for the file(s)', async function (this: World, stepUser: string, stepTable: DataTable): Promise { diff --git a/tests/e2e/cucumber/steps/ui/session.ts b/tests/e2e/cucumber/steps/ui/session.ts index 5f2bdcedd3..600e16c6f5 100644 --- a/tests/e2e/cucumber/steps/ui/session.ts +++ b/tests/e2e/cucumber/steps/ui/session.ts @@ -40,8 +40,6 @@ async function LogInUser(this: World, stepUser: string): Promise { await page.locator('#web-content').waitFor() } -Given('{string} has logged in', LogInUser) - When('{string} logs in', LogInUser) async function LogOutUser(this: World, stepUser: string): Promise { @@ -53,8 +51,6 @@ async function LogOutUser(this: World, stepUser: string): Promise { await actor.close() } -Given('{string} has logged out', LogOutUser) - When('{string} logs out', LogOutUser) Then('{string} fails to log in', async function (this: World, stepUser: string): Promise { diff --git a/tests/e2e/cucumber/steps/ui/shares.ts b/tests/e2e/cucumber/steps/ui/shares.ts index e062e57aae..a943afd55b 100644 --- a/tests/e2e/cucumber/steps/ui/shares.ts +++ b/tests/e2e/cucumber/steps/ui/shares.ts @@ -195,15 +195,6 @@ When( } ) -When( - '{string} should not be able to open the folder/file {string}', - async function (this: World, stepUser: string, resource: string): Promise { - const { page } = this.actorsEnvironment.getActor({ key: stepUser }) - const shareObject = new objects.applicationFiles.Share({ page }) - expect(await shareObject.resourceIsNotOpenable(resource)).toBe(true) - } -) - When( /"([^"]*)" (should|should not) see a sync status for the (?:folder|file) "([^"]*)"?$/, async function ( diff --git a/tests/e2e/support/objects/app-files/link/actions.ts b/tests/e2e/support/objects/app-files/link/actions.ts index a58c577c55..78dbe9d701 100644 --- a/tests/e2e/support/objects/app-files/link/actions.ts +++ b/tests/e2e/support/objects/app-files/link/actions.ts @@ -69,7 +69,6 @@ const publicLinkEditRoleButton = `//span[contains(@class, "files-links-name") an const addPublicLinkButton = '#files-file-link-add' const publicLinkNameList = '//div[@id="oc-files-file-link"]//ul//span[contains(@class, "files-links-name")]' -const publicLink = `//ul//h4[text()='%s']/following-sibling::div//p` const publicLinkCurrentRole = '//button[contains(@class,"link-role-dropdown-toggle")]//span[contains(@class,"link-current-role")]' const linkUpdateDialog = '//div[contains(@class,"oc-notification-message-title")]' @@ -306,25 +305,6 @@ export const deleteLink = async (args: deleteLinkArgs): Promise => { expect(message.trim()).toBe('Link was deleted successfully') } -export const getPublicLinkVisibility = async ( - args: publicLinkAndItsEditButtonVisibilityArgs -): Promise => { - const { page, linkName, resource, space } = args - let shareType = 'space-share' - let resourceName = null - if (!space) { - shareType = 'sharing' - const resourcePaths = resource.split('/') - resourceName = resourcePaths.pop() - if (resourcePaths.length) { - await clickResource({ page: page, path: resourcePaths.join('/') }) - } - } - await sidebar.open({ page: page, resource: resourceName }) - await sidebar.openPanel({ page: page, name: shareType }) - return await page.locator(util.format(publicLink, linkName)).textContent() -} - export const getLinkEditButtonVisibility = async ( args: publicLinkAndItsEditButtonVisibilityArgs ): Promise => { diff --git a/tests/e2e/support/objects/app-files/link/index.ts b/tests/e2e/support/objects/app-files/link/index.ts index 0950c6e6d3..40c4b992e1 100644 --- a/tests/e2e/support/objects/app-files/link/index.ts +++ b/tests/e2e/support/objects/app-files/link/index.ts @@ -81,15 +81,6 @@ export class Link { await this.#page.goto(startUrl) } - getPublicLinkUrl( - args: Omit - ): Promise { - return po.getPublicLinkVisibility({ - ...args, - page: this.#page - }) - } - async islinkEditButtonVisibile(linkName: string): Promise { return await po.getLinkEditButtonVisibility({ page: this.#page, linkName }) } diff --git a/tests/e2e/support/objects/app-files/page/public.ts b/tests/e2e/support/objects/app-files/page/public.ts index 781a6aa048..ef0f7bfefd 100644 --- a/tests/e2e/support/objects/app-files/page/public.ts +++ b/tests/e2e/support/objects/app-files/page/public.ts @@ -66,16 +66,6 @@ export class Public { await this.#page.locator('body').click() } - async uploadInternal( - args: Omit & { link: string } - ): Promise { - // link is the public link url - const { link } = args - delete args.link - await po.uploadResource({ ...args, page: this.#page }) - await this.#page.goto(link) - } - async delete(args: Omit): Promise { const startUrl = this.#page.url() await po.deleteResource({ ...args, page: this.#page, isPublicLink: true }) diff --git a/tests/e2e/support/objects/app-files/page/shares/withMe.ts b/tests/e2e/support/objects/app-files/page/shares/withMe.ts index 774beacfe4..17bdac7e86 100644 --- a/tests/e2e/support/objects/app-files/page/shares/withMe.ts +++ b/tests/e2e/support/objects/app-files/page/shares/withMe.ts @@ -1,9 +1,6 @@ import { Page } from '@playwright/test' -import { Actor } from '../../../../../support/types' const sharesNavSelector = '//a[@data-nav-name="files-shares"]' -const openShareWithMeButton = `//a/span[text()='Open "Shared with me"']` -const shareWithMeNavSelector = '//a/span[text()="Shared with me"]' export class WithMe { #page: Page @@ -15,13 +12,4 @@ export class WithMe { async navigate(): Promise { await this.#page.locator(sharesNavSelector).click() } - - async openShareWithMeFromInternalLink(actor: Actor): Promise { - const [newTab] = await Promise.all([ - this.#page.waitForEvent('popup'), - this.#page.locator(openShareWithMeButton).click() - ]) - await newTab.locator(shareWithMeNavSelector).waitFor() - actor.savePage(newTab) - } } diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 4a3e14d0d1..a88b85b275 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -90,7 +90,6 @@ const tagInInputForm = '//span[contains(@class, "tags-select-tag")]//span[text()="%s"]//ancestor::span//button[contains(@class, "vs__deselect")]' const tagFormInput = '//*[@data-testid="tags"]//input' const resourcesAsTiles = '#files-view .oc-tiles' -const fileVersionSidebar = '#oc-file-versions-sidebar' const versionsPanelSelect = '//*[@data-testid="sidebar-panel-versions-select"]' const noLinkMessage = '#web .oc-link-resolve-error-message' const listItemPageSelector = '//*[contains(@class,"oc-pagination-list-item-page") and text()="%s"]' @@ -1869,27 +1868,6 @@ export const previewMediaFromSidebarPanel = async ({ await page.locator(util.format(sideBarActionButton, 'Preview')).first().click() } -export const checkThatFileVersionIsNotAvailable = async ( - args: resourceVersionArgs -): Promise => { - const { page, files, folder } = args - const fileName = files.map((file) => path.basename(file.name)) - await clickResource({ page, path: folder }) - - await Promise.all([ - page.waitForResponse( - (resp) => - resp.url().includes('dav/meta') && - resp.status() === 403 && - resp.request().method() === 'PROPFIND' - ), - sidebar.open({ page, resource: fileName[0] }) - ]) - - await sidebar.openPanel({ page, name: 'versions' }) - await expect(page.locator(fileVersionSidebar)).toHaveText('No versions available for this file') -} - export const checkThatFileVersionPanelIsNotAvailable = async ( args: resourceVersionArgs ): Promise => { @@ -1969,21 +1947,6 @@ export const expectPageNumberNotToBeVisible = async ({ page }: { page: Page }): await expect(page.locator(filesPaginationNavSelector)).not.toBeVisible() } -export interface expectFileToBeSelectedArgs { - page: Page - fileName: string -} - -export const expectFileToBeSelected = async ({ - page, - fileName -}: { - page: Page - fileName: string -}): Promise => { - await expect(page.locator(util.format(checkBox, fileName))).toBeChecked() -} - export const createShotcut = async (args: shortcutArgs): Promise => { const { page, resource, name, type } = args await page.locator(addNewResourceButton).click() diff --git a/tests/e2e/support/objects/app-files/resource/index.ts b/tests/e2e/support/objects/app-files/resource/index.ts index 04c0db790e..f71632a255 100644 --- a/tests/e2e/support/objects/app-files/resource/index.ts +++ b/tests/e2e/support/objects/app-files/resource/index.ts @@ -273,14 +273,6 @@ export class Resource { return po.createSpaceFromAll({ page: this.#page, spaceName }) } - async checkThatFileVersionIsNotAvailable( - args: Omit - ): Promise { - const startUrl = this.#page.url() - await po.checkThatFileVersionIsNotAvailable({ ...args, page: this.#page }) - await this.#page.goto(startUrl) - } - async checkThatFileVersionPanelIsNotAvailable( args: Omit ): Promise { @@ -309,10 +301,6 @@ export class Resource { await po.expectPageNumberNotToBeVisible({ page: this.#page }) } - async expectFileToBeSelected(args: Omit): Promise { - await po.expectFileToBeSelected({ ...args, page: this.#page }) - } - async createShotcut(args: Omit): Promise { const startUrl = this.#page.url() await po.createShotcut({ ...args, page: this.#page }) diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts index 0b050c7a6f..0539777ee7 100644 --- a/tests/e2e/support/objects/app-files/share/index.ts +++ b/tests/e2e/support/objects/app-files/share/index.ts @@ -1,6 +1,6 @@ import { Page, Locator } from '@playwright/test' import * as po from './actions' -import { resourceIsNotOpenable, isAcceptedSharePresent, resourceIsSynced } from './utils' +import { isAcceptedSharePresent, resourceIsSynced } from './utils' import { ICollaborator, IAccessDetails } from './collaborator' import { User } from '../../../types' export class Share { @@ -51,10 +51,6 @@ export class Share { return await isAcceptedSharePresent({ page: this.#page, resource, owner }) } - async resourceIsNotOpenable(resource: string): Promise { - return await resourceIsNotOpenable({ page: this.#page, resource }) - } - async resourceIsSynced(resource: string): Promise { return await resourceIsSynced({ page: this.#page, resource }) } diff --git a/tests/e2e/support/objects/app-files/share/utils.ts b/tests/e2e/support/objects/app-files/share/utils.ts index 9513388e1f..5c3a10f96b 100644 --- a/tests/e2e/support/objects/app-files/share/utils.ts +++ b/tests/e2e/support/objects/app-files/share/utils.ts @@ -3,29 +3,9 @@ import util from 'util' const acceptedShareItem = '//*[@data-test-resource-name="%s"]/ancestor::tr//span[@data-test-user-name="%s"]' -const itemSelector = '.files-table [data-test-resource-name="%s"]' const syncEnabled = '//*[@data-test-resource-name="%s"]//ancestor::tr//span[contains(@class, "sync-enabled")]' -export const resourceIsNotOpenable = async ({ - page, - resource -}: { - page: Page - resource: string -}): Promise => { - const resourceLocator = page.locator(util.format(itemSelector, resource)) - try { - await Promise.all([ - page.waitForRequest((req) => req.method() === 'PROPFIND', { timeout: 500 }), - resourceLocator.click() - ]) - return false - } catch { - return true - } -} - export const resourceIsSynced = ({ page, resource