Skip to content

Commit 62fabac

Browse files
committed
chore(ci): Make row action helpers atomic to avoid mid-render detachment
-e Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
1 parent 8887c97 commit 62fabac

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

cypress/e2e/files/FilesUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import { ACTION_COPY_MOVE } from '../../../apps/files/src/actions/moveOrCopyActi
99
export const getRowForFileId = (fileid: number) => cy.get(`[data-cy-files-list-row-fileid="${fileid}"]`)
1010
export const getRowForFile = (filename: string) => cy.get(`[data-cy-files-list-row-name="${CSS.escape(filename)}"]`)
1111

12-
export const getActionsForFileId = (fileid: number) => getRowForFileId(fileid).find('[data-cy-files-list-row-actions]')
13-
export const getActionsForFile = (filename: string) => getRowForFile(filename).find('[data-cy-files-list-row-actions]')
12+
// Atomic query so the lookup is retried as a whole when rows re-render
13+
// (chained .find() can fail with "subject no longer attached" mid-render).
14+
export const getActionsForFileId = (fileid: number) => cy.get(`[data-cy-files-list-row-fileid="${fileid}"] [data-cy-files-list-row-actions]`)
15+
export const getActionsForFile = (filename: string) => cy.get(`[data-cy-files-list-row-name="${CSS.escape(filename)}"] [data-cy-files-list-row-actions]`)
1416

1517
export const getActionButtonForFileId = (fileid: number) => getActionsForFileId(fileid).findByRole('button', { name: 'Actions' })
1618
export const getActionButtonForFile = (filename: string) => getActionsForFile(filename).findByRole('button', { name: 'Actions' })

cypress/e2e/files_sharing/share-status-action.cy.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ describe('files_sharing: Sharing status action', { testIsolation: true }, () =>
2222

2323
cy.visit('/apps/files')
2424

25-
getRowForFile('folder')
26-
.should('be.visible')
27-
.find('[data-cy-files-list-row-actions]')
25+
getRowForFile('folder').should('be.visible')
26+
getActionsForFile('folder')
2827
.findByRole('button', { name: 'Shared' })
2928
.should('not.exist')
3029
})
@@ -37,12 +36,11 @@ describe('files_sharing: Sharing status action', { testIsolation: true }, () =>
3736
cy.visit('/apps/files')
3837
})
3938

40-
getRowForFile('folder')
41-
.should('be.visible')
42-
.find('[data-cy-files-list-row-actions]')
39+
getRowForFile('folder').should('be.visible')
40+
getActionsForFile('folder')
4341
.findByRole('button', { name: /Sharing options/ })
4442
.should('be.visible')
45-
.click()
43+
.click({ force: true })
4644

4745
// check the click opened the sidebar
4846
cy.get('[data-cy-sidebar]')

0 commit comments

Comments
 (0)