Skip to content

Commit 12389ff

Browse files
pringelmannbackportbot[bot]
authored andcommitted
chore(ci): Make row action helpers atomic to avoid mid-render detachment -e Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
chore(ci): Make row action helpers atomic to avoid mid-render detachment -e Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com> [skip ci]
1 parent c298ce0 commit 12389ff

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

cypress/e2e/files/FilesUtils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ const ACTION_COPY_MOVE = 'move-copy'
1010
export const getRowForFileId = (fileid: string | number) => cy.get(`[data-cy-files-list-row-fileid="${fileid}"]`)
1111
export const getRowForFile = (filename: string) => cy.get(`[data-cy-files-list-row-name="${CSS.escape(filename)}"]`)
1212

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

1618
export const getActionButtonForFileId = (fileid: number) => getActionsForFileId(fileid).findByRole('button', { name: 'Actions' })
1719
export const getActionButtonForFile = (filename: string) => getActionsForFile(filename).findByRole('button', { name: 'Actions' })
@@ -48,8 +50,7 @@ export function getActionEntryForFile(file: string, actionId: string) {
4850
* @param actionId
4951
*/
5052
export function getInlineActionEntryForFileId(fileid: number, actionId: string) {
51-
return getActionsForFileId(fileid)
52-
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
53+
return cy.get(`[data-cy-files-list-row-fileid="${fileid}"] [data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
5354
}
5455

5556
/**
@@ -58,8 +59,7 @@ export function getInlineActionEntryForFileId(fileid: number, actionId: string)
5859
* @param actionId
5960
*/
6061
export function getInlineActionEntryForFile(file: string, actionId: string) {
61-
return getActionsForFile(file)
62-
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
62+
return cy.get(`[data-cy-files-list-row-name="${CSS.escape(file)}"] [data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
6363
}
6464

6565
/**

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
import type { User } from '@nextcloud/e2e-test-server/cypress'
66

7-
import { closeSidebar, enableGridMode, getActionButtonForFile, getInlineActionEntryForFile, getRowForFile } from '../files/FilesUtils.ts'
7+
import { closeSidebar, enableGridMode, getActionButtonForFile, getActionsForFile, getInlineActionEntryForFile, getRowForFile } from '../files/FilesUtils.ts'
88
import { createShare } from './FilesSharingUtils.ts'
99

1010
describe('files_sharing: Sharing status action', { testIsolation: true }, () => {
@@ -23,9 +23,8 @@ describe('files_sharing: Sharing status action', { testIsolation: true }, () =>
2323

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

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

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

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

0 commit comments

Comments
 (0)