Skip to content

chore: re-query before clicks to prevent detached-DOM flakiness#96

Merged
jtroup merged 1 commit intostacklet/integrationfrom
elmo/fix-e2e-redux
Mar 10, 2026
Merged

chore: re-query before clicks to prevent detached-DOM flakiness#96
jtroup merged 1 commit intostacklet/integrationfrom
elmo/fix-e2e-redux

Conversation

@jtroup
Copy link

@jtroup jtroup commented Mar 7, 2026

what

Fix the detached-DOM anti-pattern across all Cypress e2e tests: split
every chained .should(...).action() call into separate queries — one
statement for the assertion, a fresh cy.get() for the action.

why

When .should() and an action (.click(), .type(), etc.) are chained
on the same element reference, React can re-render between those two
Cypress commands, replacing the original DOM node. Cypress then tries to
act on the now-detached reference and times out.

The immediate trigger was Table - renders all cell types failing in CI
with CypressError: cy.click() failed because this element is detached from the DOM on the jvi-toggle span (confirmed in CI logs).
A sweep of all spec files found the same pattern in 12 other places,
including the LogOutButton (inside a just-opened dropdown),
EditTagsButton (text-content assertion on a stateful button), the
NewVisualization button (after async query execution), and the
ExecuteButton (9 occurrences across visualization and query specs).

Re-querying with a fresh cy.get() before each action ensures Cypress
holds a live DOM reference and re-activates its built-in actionability
retry loop, making the interaction self-healing if a re-render occurs.

testing

Diagnosed from CI e2e test output. Fix aligns with the standard Cypress
guidance for detached-DOM errors:
https://on.cypress.io/element-has-detached-from-dom

docs

No docs needed.


🤖 Generated with Claude Code

Copy link

@Ahmore Ahmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks @jtroup

@jtroup jtroup merged commit a757a58 into stacklet/integration Mar 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants