fix(cypress): use atomic cy.get() selectors to prevent detached DOM flakiness#60324
Draft
skjnldsv wants to merge 1 commit into
Draft
fix(cypress): use atomic cy.get() selectors to prevent detached DOM flakiness#60324skjnldsv wants to merge 1 commit into
skjnldsv wants to merge 1 commit into
Conversation
…lakiness
All file-list helper functions now use a single cy.get() with a compound
CSS selector from the document root instead of chaining .find() /
.findByRole() on an intermediate subject.
When Vue re-renders the file list (e.g. while opening the sharing sidebar)
Cypress throws "subject no longer attached to the DOM" on any chained
.find() call — the engine cannot re-query through a chained command.
A single cy.get() with a compound selector is re-executed from scratch
on every assertion retry, making it immune to mid-render detachment.
Changes:
- getActionButtonForFile/Id: use button[aria-label="Actions"] atomic selector
(NcActions default ariaLabel is t('Actions') per @nextcloud/vue source)
- getActionEntryForFile/Id: combine #menuId + descendant in one cy.get()
instead of cy.get('#id').find(child)
- triggerActionForFile/Id: single trigger click + atomic
[role="menu"] [data-cy-files-list-row-action="id"] > button query;
removes duplicate getActionButtonForFile() call; adds force:true on
menu item click for animation/overlay robustness
- triggerInlineActionForFile/Id: atomic row selector instead of
getActionsFor*().find()
- selectRowForFile: atomic row+checkbox input selector
- renameFile: atomic row+name-cell+input selector
- navigateToFolder: atomic row+name-link selector
Fixes the recurring CI failures in:
cypress/e2e/files/files-renaming.cy.ts
cypress/e2e/files_sharing/note-to-recipient.cy.ts
cypress/e2e/files/favorites.cy.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c61113c to
9a43669
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.find()/.findByRole()calls on file-list row subjects with single atomiccy.get()compound selectors.find()— the engine cannot re-query through a chained command; a root-levelcy.get()is re-executed from scratch on every retrygetActionButtonForFile()call intriggerActionForFile/Id; addsforce: trueon menu item click for animation robustnessKey changes in
cypress/e2e/files/FilesUtils.tsgetActionButtonForFile/IdgetActionsFor*().findByRole('button', { name: 'Actions' })cy.get('... button[aria-label="Actions"]')getActionEntryForFile/Idcy.get('#id').should('exist').find(child)cy.get('#id child')combined selectortriggerActionForFile/IdgetActionEntryForFile().find('button')cy.get('[role="menu"] [data-cy-...] > button')triggerInlineActionFor*getActionsFor*().find('button[data-cy...]')cy.get()selectRowForFilegetRowForFile().find().findByRole()cy.get('... input[type="checkbox"]')renameFilegetRowForFile().find('[data-cy-files-list-row-name] input')cy.get()navigateToFoldergetRowForFile().find('[data-cy-files-list-row-name-link]')cy.get()Note:
NcActionsdefaultariaLabelist('Actions')(confirmed in@nextcloud/vuesource).aria-controlsis only set while the menu is open —getActionEntryForFile/Id(which use it) are only called by tests that explicitly open the menu first, so they remain correct.Fixes recurring CI failures in
cypress/e2e/files/files-renaming.cy.ts— "shows warning on extension change", "shows warning on extension removal", "does not show warning on folder renaming with a dot"cypress/e2e/files_sharing/note-to-recipient.cy.ts— "displays the note to the sharee even if the file list is empty", "shows an existing note when editing a share"cypress/e2e/files/favorites.cy.ts— "See favorite folders in navigation", "Mark file as favorite using the sidebar"Test plan
cypress/e2e/files/files-renaming.cy.tsmultiple times — no "subject no longer attached" errorscypress/e2e/files_sharing/note-to-recipient.cy.ts— all tests passcypress/e2e/files/favorites.cy.ts— all tests passcypress/e2e/files/files-actions.cy.ts—getActionEntryForFileIdstill works (opens menu first)cypress/e2e/files_sharing/files-download.cy.ts—getActionEntryForFilestill works for.should('not.exist')assertions🤖 Generated with Claude Code