aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2025-02-20 21:50:01 +0100
committerskjnldsv <skjnldsv@protonmail.com>2025-02-21 09:53:11 +0100
commitfc88c7862e059d0ca6c796c2f7f5e6c04040f845 (patch)
treeb8f95a3c57bfc62abffa0a21a0c5e6659f965d15
parent18e6fe22ba34f3c917693ac3697eb011f7352ba9 (diff)
downloadnextcloud-server-fc88c7862e059d0ca6c796c2f7f5e6c04040f845.tar.gz
nextcloud-server-fc88c7862e059d0ca6c796c2f7f5e6c04040f845.zip
fix(cypress): action selector menu lookup
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
-rw-r--r--cypress/e2e/files/FilesUtils.ts43
1 files changed, 36 insertions, 7 deletions
diff --git a/cypress/e2e/files/FilesUtils.ts b/cypress/e2e/files/FilesUtils.ts
index 79607989d50..be866a3f255 100644
--- a/cypress/e2e/files/FilesUtils.ts
+++ b/cypress/e2e/files/FilesUtils.ts
@@ -26,23 +26,52 @@ export const getRowForFile = (filename: string) => cy.get(`[data-cy-files-list-r
export const getActionsForFileId = (fileid: number) => getRowForFileId(fileid).find('[data-cy-files-list-row-actions]')
export const getActionsForFile = (filename: string) => getRowForFile(filename).find('[data-cy-files-list-row-actions]')
-export const getActionButtonForFileId = (fileid: number) => getActionsForFileId(fileid).find('button[aria-label="Actions"]')
-export const getActionButtonForFile = (filename: string) => getActionsForFile(filename).find('button[aria-label="Actions"]')
+export const getActionButtonForFileId = (fileid: number) => getActionsForFileId(fileid).findByRole('button', { name: 'Actions' })
+export const getActionButtonForFile = (filename: string) => getActionsForFile(filename).findByRole('button', { name: 'Actions' })
+
+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): 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) => {
- getActionButtonForFileId(fileid).click()
- cy.get(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"] > button`).should('exist').click()
+ // Even if it's inline, we open the action menu to get all actions visible
+ getActionButtonForFileId(fileid).click({ force: true })
+ getActionEntryForFileId(fileid, actionId)
+ .find('button').last()
+ .should('exist').click({ force: true })
}
export const triggerActionForFile = (filename: string, actionId: string) => {
- getActionButtonForFile(filename).click()
- cy.get(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"] > button`).should('exist').click()
+ // Even if it's inline, we open the action menu to get all actions visible
+ getActionButtonForFile(filename).click({ force: true })
+ getActionEntryForFile(filename, actionId)
+ .find('button').last()
+ .should('exist').click({ force: true })
}
export const triggerInlineActionForFileId = (fileid: number, actionId: string) => {
getActionsForFileId(fileid).find(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`).should('exist').click()
}
export const triggerInlineActionForFile = (filename: string, actionId: string) => {
- getActionsForFile(filename).get(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`).should('exist').click()
+ getActionsForFile(filename).find(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`).should('exist').click()
}
export const createFolder = (folderName: string) => {