chore(ci): Make row action helpers atomic to avoid mid-render detachment

-e
Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
This commit is contained in:
Peter Ringelmann 2026-05-11 13:15:18 +02:00 committed by Peter R.
parent 622e06117d
commit 819798f02e
2 changed files with 12 additions and 14 deletions

View file

@ -10,8 +10,10 @@ const ACTION_COPY_MOVE = 'move-copy'
export const getRowForFileId = (fileid: string | number) => cy.get(`[data-cy-files-list-row-fileid="${fileid}"]`)
export const getRowForFile = (filename: string) => cy.get(`[data-cy-files-list-row-name="${CSS.escape(filename)}"]`)
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]')
// Atomic query so the lookup is retried as a whole when rows re-render
// (chained .find() can fail with "subject no longer attached" mid-render).
export const getActionsForFileId = (fileid: number) => cy.get(`[data-cy-files-list-row-fileid="${fileid}"] [data-cy-files-list-row-actions]`)
export const getActionsForFile = (filename: string) => cy.get(`[data-cy-files-list-row-name="${CSS.escape(filename)}"] [data-cy-files-list-row-actions]`)
export const getActionButtonForFileId = (fileid: number) => getActionsForFileId(fileid).findByRole('button', { name: 'Actions' })
export const getActionButtonForFile = (filename: string) => getActionsForFile(filename).findByRole('button', { name: 'Actions' })
@ -48,8 +50,7 @@ export function getActionEntryForFile(file: string, actionId: string) {
* @param actionId
*/
export function getInlineActionEntryForFileId(fileid: number, actionId: string) {
return getActionsForFileId(fileid)
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
return cy.get(`[data-cy-files-list-row-fileid="${fileid}"] [data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
}
/**
@ -58,8 +59,7 @@ export function getInlineActionEntryForFileId(fileid: number, actionId: string)
* @param actionId
*/
export function getInlineActionEntryForFile(file: string, actionId: string) {
return getActionsForFile(file)
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
return cy.get(`[data-cy-files-list-row-name="${CSS.escape(file)}"] [data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
}
/**

View file

@ -4,7 +4,7 @@
*/
import type { User } from '@nextcloud/e2e-test-server/cypress'
import { closeSidebar, enableGridMode, getActionButtonForFile, getInlineActionEntryForFile, getRowForFile } from '../files/FilesUtils.ts'
import { closeSidebar, enableGridMode, getActionButtonForFile, getActionsForFile, getInlineActionEntryForFile, getRowForFile } from '../files/FilesUtils.ts'
import { createShare } from './FilesSharingUtils.ts'
describe('files_sharing: Sharing status action', { testIsolation: true }, () => {
@ -23,9 +23,8 @@ describe('files_sharing: Sharing status action', { testIsolation: true }, () =>
cy.visit('/apps/files')
getRowForFile('folder')
.should('be.visible')
.find('[data-cy-files-list-row-actions]')
getRowForFile('folder').should('be.visible')
getActionsForFile('folder')
.findByRole('button', { name: 'Shared' })
.should('not.exist')
})
@ -38,12 +37,11 @@ describe('files_sharing: Sharing status action', { testIsolation: true }, () =>
cy.visit('/apps/files')
})
getRowForFile('folder')
.should('be.visible')
.find('[data-cy-files-list-row-actions]')
getRowForFile('folder').should('be.visible')
getActionsForFile('folder')
.findByRole('button', { name: /Sharing options/ })
.should('be.visible')
.click()
.click({ force: true })
// check the click opened the sidebar
cy.get('[data-cy-sidebar]')