aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2025-02-20 20:39:18 +0100
committerskjnldsv <skjnldsv@protonmail.com>2025-02-20 20:58:52 +0100
commit11a5330214842c386495b97aae9e4716336203d3 (patch)
treee2e443059f3a6924c2df95325cc67ec338f0049d
parent3a9439d1e296dc51c58c7a1132709c59060c3341 (diff)
downloadnextcloud-server-11a5330214842c386495b97aae9e4716336203d3.tar.gz
nextcloud-server-11a5330214842c386495b97aae9e4716336203d3.zip
fix(cypress): action selector menu lookup
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
-rw-r--r--cypress/e2e/files/FilesUtils.ts24
-rw-r--r--cypress/e2e/files/files-actions.cy.ts4
2 files changed, 23 insertions, 5 deletions
diff --git a/cypress/e2e/files/FilesUtils.ts b/cypress/e2e/files/FilesUtils.ts
index d1e609713b6..fce23fc1463 100644
--- a/cypress/e2e/files/FilesUtils.ts
+++ b/cypress/e2e/files/FilesUtils.ts
@@ -15,11 +15,27 @@ export const getActionsForFile = (filename: string) => getRowForFile(filename).f
export const getActionButtonForFileId = (fileid: number) => getActionsForFileId(fileid).findByRole('button', { name: 'Actions' })
export const getActionButtonForFile = (filename: string) => getActionsForFile(filename).findByRole('button', { name: 'Actions' })
-export const getActionEntryForFileId = (fileid: number, actionId: string) => {
- return getRowForFileId(fileid).find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
+const searchForActionInRow = (row: JQuery<HTMLElement>, actionId: string): Cypress.Chainable<JQuery<HTMLElement>> => {
+ const action = row.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
+ if (action.length > 0) {
+ cy.log('Found action in row')
+ return cy.wrap(action)
+ }
+
+ // Else look in the action menu
+ const menuButtonId = row.find('button[aria-controls]').attr('aria-controls')
+ return cy.get(`#${menuButtonId} [data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
+}
+
+export const getActionEntryForFileId = (fileid: number, actionId: string): Cypress.Chainable<JQuery<HTMLElement>> => {
+ // If we cannot find the action in the row, it might be in the action menu
+ return getRowForFileId(fileid).should('be.visible')
+ .then(row => searchForActionInRow(row, actionId))
}
-export const getActionEntryForFile = (filename: string, actionId: string) => {
- return getRowForFile(filename).find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
+export const getActionEntryForFile = (filename: string, actionId: string): Cypress.Chainable<JQuery<HTMLElement>> => {
+ // If we cannot find the action in the row, it might be in the action menu
+ return getRowForFile(filename).should('be.visible')
+ .then(row => searchForActionInRow(row, actionId))
}
export const triggerActionForFileId = (fileid: number, actionId: string) => {
diff --git a/cypress/e2e/files/files-actions.cy.ts b/cypress/e2e/files/files-actions.cy.ts
index 8b0057e3042..597b1b90464 100644
--- a/cypress/e2e/files/files-actions.cy.ts
+++ b/cypress/e2e/files/files-actions.cy.ts
@@ -6,7 +6,7 @@
import type { User } from '@nextcloud/cypress'
import { FileAction } from '@nextcloud/files'
-import { getActionButtonForFileId, getActionEntryForFileId, getRowForFile, getSelectionActionButton, getSelectionActionEntry, selectRowForFile, triggerActionForFile, triggerActionForFileId } from './FilesUtils'
+import { getActionButtonForFileId, getActionEntryForFileId, getRowForFile, getSelectionActionButton, getSelectionActionEntry, selectRowForFile } from './FilesUtils'
import { ACTION_COPY_MOVE } from '../../../apps/files/src/actions/moveOrCopyAction'
import { ACTION_DELETE } from '../../../apps/files/src/actions/deleteAction'
import { ACTION_DETAILS } from '../../../apps/files/src/actions/sidebarAction'
@@ -53,6 +53,8 @@ describe('Files: Actions', { testIsolation: true }, () => {
getActionButtonForFileId(fileId).click({ force: true })
// Check the action is visible
getActionEntryForFileId(fileId, actionId).should('be.visible')
+ // Close the menu
+ cy.get('body').click({ force: true})
})
})