Skip to content

Fix flaky E2E tests by adding proper async waiting #2105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

devin-ai-integration[bot]
Copy link
Contributor

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:

  • "Table node should be highlighted when clicked"
  • "Edge animation should be triggered when table node is clicked"
  • "Cardinality should be highlighted when table node is clicked"

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:

  1. Click table node → handleNodeClick
  2. Calls selectTablesetActiveTableName (async URL update)
  3. URL state change triggers React re-render
  4. highlightNodesAndEdges updates node/edge highlighting
  5. DOM elements get [data-erd="table-node-highlighted"] attributes and visibility changes

The race condition occurred because tests checked for DOM changes immediately after clicking, but the URL state updates are asynchronous.

Solution

  • Added await page.waitForTimeout(100) after each table node click to allow async state propagation
  • Added { timeout: 10000 } to all visibility and attribute assertions to provide proper waiting time
  • This ensures tests wait for the complete async state update cycle before making assertions

Changes Made

  • Modified frontend/internal-packages/e2e/tests/e2e/page.test.ts:
    • Added 100ms wait after clicks in all three failing tests
    • Added 10-second timeout to toBeVisible() and toHaveAttribute() assertions
    • No timeout increases to global configuration (as explicitly forbidden)

Testing

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

- Add waitForTimeout(100) after table node clicks to allow async URL state updates
- Add timeout: 10000 to visibility and attribute assertions for proper DOM waiting
- Fix timing race conditions in table highlighting, edge animation, and cardinality tests
- Addresses Mobile Safari test failures without increasing global timeouts

Co-Authored-By: hirotaka.miyagi@route06.co.jp <h.miyagi.cnw@gmail.com>
Copy link

changeset-bot bot commented Jun 20, 2025

⚠️ No Changeset found

Latest commit: 3f4766b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jun 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
liam-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 6:29am
liam-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 6:29am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
liam-docs ⬜️ Ignored (Inspect) Visit Preview Jun 20, 2025 6:29am
liam-erd-sample ⬜️ Skipped (Inspect) Jun 20, 2025 6:29am

Copy link

supabase bot commented Jun 20, 2025

Updates to Preview Branch (devin/1750399956-fix-flaky-e2e-tests) ↗︎

Deployments Status Updated
Database Fri, 20 Jun 2025 06:22:32 UTC
Services Fri, 20 Jun 2025 06:22:32 UTC
APIs Fri, 20 Jun 2025 06:22:32 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Fri, 20 Jun 2025 06:22:33 UTC
Migrations Fri, 20 Jun 2025 06:22:33 UTC
Seeding Fri, 20 Jun 2025 06:22:33 UTC
Edge Functions Fri, 20 Jun 2025 06:22:33 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

Co-Authored-By: hirotaka.miyagi@route06.co.jp <h.miyagi.cnw@gmail.com>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@MH4GF MH4GF closed this Jun 24, 2025
@MH4GF MH4GF deleted the devin/1750399956-fix-flaky-e2e-tests branch June 24, 2025 06:48
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.

1 participant