diff --git a/cypress/e2e/files/FilesUtils.ts b/cypress/e2e/files/FilesUtils.ts index 70767b5ecf1..8bc5ffc7067 100644 --- a/cypress/e2e/files/FilesUtils.ts +++ b/cypress/e2e/files/FilesUtils.ts @@ -9,8 +9,10 @@ import { ACTION_COPY_MOVE } from '../../../apps/files/src/actions/moveOrCopyActi export const getRowForFileId = (fileid: 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' }) diff --git a/cypress/e2e/files_sharing/share-status-action.cy.ts b/cypress/e2e/files_sharing/share-status-action.cy.ts index f02ec676573..4c07a635900 100644 --- a/cypress/e2e/files_sharing/share-status-action.cy.ts +++ b/cypress/e2e/files_sharing/share-status-action.cy.ts @@ -4,7 +4,7 @@ */ import type { User } from '@nextcloud/cypress' import { createShare } from './FilesSharingUtils.ts' -import { closeSidebar, enableGridMode, getActionButtonForFile, getInlineActionEntryForFile, getRowForFile } from '../files/FilesUtils.ts' +import { closeSidebar, enableGridMode, getActionButtonForFile, getActionsForFile, getInlineActionEntryForFile, getRowForFile } from '../files/FilesUtils.ts' describe('files_sharing: Sharing status action', { testIsolation: true }, () => { /** @@ -22,9 +22,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') }) @@ -37,12 +36,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]')