Skip to content

Commit a82c877

Browse files
Anna Larchmiaulalala
authored andcommitted
fix(cypress): use atomic selectors to avoid stale DOM in action menu queries
getActionEntryForFile/Id chained .find() off a cy.get() result inside a .then() callback. After the actions button click triggers a Vue re-render, the stored element reference goes stale before .find() executes, causing intermittent "subject no longer attached to DOM" failures in files-sidebar, public-share/download, and version_naming specs. Collapse the two-step get+find into a single combined CSS selector so Cypress retries the whole query atomically on re-render. Same fix applied to the alias-then-find pattern in version_naming.cy.ts. Signed-off-by: Anna Larch <anna@larch.dev> AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
1 parent 54609da commit a82c877

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

cypress/e2e/files/FilesUtils.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ export const getActionButtonForFile = (filename: string) => getActionsForFile(fi
2626
export function getActionEntryForFileId(fileid: number, actionId: string) {
2727
return getActionButtonForFileId(fileid)
2828
.should('have.attr', 'aria-controls')
29-
.then((menuId) => cy.get(`#${menuId}`)
30-
.should('exist')
31-
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
29+
.then((menuId) => cy.get(`#${menuId} [data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
3230
}
3331

3432
/**
@@ -39,9 +37,7 @@ export function getActionEntryForFileId(fileid: number, actionId: string) {
3937
export function getActionEntryForFile(file: string, actionId: string) {
4038
return getActionButtonForFile(file)
4139
.should('have.attr', 'aria-controls')
42-
.then((menuId) => cy.get(`#${menuId}`)
43-
.should('exist')
44-
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
40+
.then((menuId) => cy.get(`#${menuId} [data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
4541
}
4642

4743
/**

cypress/e2e/files_versions/version_naming.cy.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,10 @@ describe('Versions naming', () => {
7676
navigateToFolder('share')
7777
openVersionsPanel(randomFileName)
7878

79-
cy.get('[data-files-versions-version]')
80-
.eq(0)
81-
.as('firstVersion')
82-
.find('.action-item__menutoggle')
83-
.should('not.exist')
84-
cy.get('@firstVersion')
85-
.find('[data-cy-version-action="label"]')
86-
.should('not.exist')
79+
cy.get('[data-files-versions-version]').eq(0).within(() => {
80+
cy.get('.action-item__menutoggle').should('not.exist')
81+
cy.get('[data-cy-version-action="label"]').should('not.exist')
82+
})
8783

8884
doesNotHaveAction(1, 'label')
8985
doesNotHaveAction(2, 'label')

0 commit comments

Comments
 (0)