Skip to content

fix: flaky "element detached from DOM" in sessions test - #929

Merged
mergify[bot] merged 1 commit into
mainfrom
fix-flaky-e2e-session-click
Mar 17, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
fix-flaky-e2e-session-click

Conversation

@mprpic

@mprpic mprpic commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Wait for the sessions list API response before clicking the new session button, ensuring React has finished re-rendering with the fetched data.

Example failed test:
https://github.com/ambient-code/platform/actions/runs/23146894542/job/67237433020

@coderabbitai

coderabbitai Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1b80449e-f393-40de-8d44-4ac89fc56f26

📥 Commits

Reviewing files that changed from the base of the PR and between b64dc64 and d90d899.

📒 Files selected for processing (1)
  • e2e/cypress/e2e/sessions.cy.ts

Walkthrough

The Cypress e2e test was changed to intercept GET /api/projects/*/agentic-sessions*, revisit the workspace to trigger that request, wait for the intercepted sessionsList response (15s timeout), confirm the new-session button is visible, then click it to avoid DOM-detached errors during React re-renders.

Changes

Cohort / File(s) Summary
E2E Test Stabilization
e2e/cypress/e2e/sessions.cy.ts
Add intercept for GET /api/projects/*/agentic-sessions*, re-visit workspace to trigger fetch, wait on sessionsList (15s timeout), assert new-session button visibility, then click. Replaces direct click with API-synchronized interaction to prevent "element detached from DOM" errors.

Sequence Diagram(s)

sequenceDiagram
  participant Test as Cypress Test
  participant Browser as React App (Browser)
  participant API as Server API

  Test->>Browser: visit /workspace (with intercept registered)
  Browser->>API: GET /api/projects/*/agentic-sessions*
  API-->>Browser: sessions list response
  Test-->>API: wait for intercepted "sessionsList" (15s timeout)
  Test->>Browser: assert new-session button visible
  Test->>Browser: click new-session button
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a flaky test by addressing 'element detached from DOM' errors in the sessions test.
Description check ✅ Passed The description is directly related to the changeset, explaining the fix (waiting for sessions list API response) and providing context with a failed test example.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-flaky-e2e-session-click
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@e2e/cypress/e2e/sessions.cy.ts`:
- Around line 84-85: The intercept for sessions ('cy.intercept' with alias
'sessionsList') is registered but no network request is triggered before
'cy.wait('@sessionsList')', so insert a 'cy.visit(...)' to navigate to the
workspace page that triggers the sessions GET request immediately after the
intercept registration and before calling 'cy.wait('@sessionsList')'; ensure the
visited route is the app's workspace/ project page that performs the sessions
fetch so the wait can observe the request.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 04ad1170-7a95-42ef-8b0e-b98c419d376f

📥 Commits

Reviewing files that changed from the base of the PR and between c18ddbb and 8689b44.

📒 Files selected for processing (1)
  • e2e/cypress/e2e/sessions.cy.ts

Comment thread e2e/cypress/e2e/sessions.cy.ts Resolved
@mprpic
mprpic force-pushed the fix-flaky-e2e-session-click branch 2 times, most recently from 07a1c07 to b64dc64 Compare March 16, 2026 17:03
Wait for the sessions list API response before clicking the new session
button, ensuring React has finished re-rendering with the fetched data.

Example failed test:
https://github.com/ambient-code/platform/actions/runs/23146894542/job/67237433020

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Martin Prpič <mprpic@redhat.com>
@mprpic
mprpic force-pushed the fix-flaky-e2e-session-click branch from b64dc64 to d90d899 Compare March 16, 2026 17:58
@ambient-code ambient-code Bot added this to the Review Queue milestone Mar 17, 2026
@Gkrumbach07

Copy link
Copy Markdown
Contributor

@Mergifyio queue

@mergify

mergify Bot commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 18 seconds in the queue, including 2 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Mar 17, 2026
mergify Bot added a commit that referenced this pull request Mar 17, 2026
@mergify
mergify Bot merged commit da4285c into main Mar 17, 2026
12 checks passed
@mergify
mergify Bot deleted the fix-flaky-e2e-session-click branch March 17, 2026 13:50
@mergify mergify Bot removed the queued label Mar 17, 2026
@ambient-code ambient-code Bot removed this from the Review Queue milestone Mar 17, 2026
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