Fix flaky E2E tests by adding proper async waiting #2105
Closed
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.
Fix Flaky E2E Tests by Adding Proper Async Waiting
Problem
Three E2E tests were failing intermittently on Mobile Safari due to timing/race condition issues:
The tests were expecting immediate DOM updates after clicking table nodes, but the underlying state management uses asynchronous URL query state updates via
useQueryState
.Root Cause Analysis
The state flow involves async operations:
handleNodeClick
selectTable
→setActiveTableName
(async URL update)highlightNodesAndEdges
updates node/edge highlighting[data-erd="table-node-highlighted"]
attributes and visibility changesThe race condition occurred because tests checked for DOM changes immediately after clicking, but the URL state updates are asynchronous.
Solution
await page.waitForTimeout(100)
after each table node click to allow async state propagation{ timeout: 10000 }
to all visibility and attribute assertions to provide proper waiting timeChanges Made
frontend/internal-packages/e2e/tests/e2e/page.test.ts
:toBeVisible()
andtoHaveAttribute()
assertionsTesting
The fix addresses the timing issues without increasing global timeouts, ensuring tests wait appropriately for DOM state changes after async operations complete.
Link to Devin run: https://app.devin.ai/sessions/a751b16eb29548548d35d09b56627bef
Requested by: hirotaka.miyagi@route06.co.jp