Skip to content

fix: use JS .click() for delete flow E2E tests#33

Merged
adnaan merged 1 commit intomainfrom
fix-24-delete-flow
Mar 14, 2026
Merged

fix: use JS .click() for delete flow E2E tests#33
adnaan merged 1 commit intomainfrom
fix-24-delete-flow

Conversation

@adnaan
Copy link
Contributor

@adnaan adnaan commented Mar 14, 2026

Summary

  • Replace chromedp.Click with chromedp.Evaluate + JS .click() for all lvt-click button interactions in delete flow E2E tests
  • Use e2etest.WaitFor for reliable DOM change detection instead of chromedp.Sleep
  • Add proper assertions (t.Errorf/t.Error) for todo count decrease and deletion verification

Root Cause

chromedp.Click sends CDP input events that don't reliably trigger event delegation handlers in headless Chrome. LiveTemplate uses lvt-click attribute-based event delegation, which requires actual DOM click events (not CDP-level input simulation).

Tests affected

  • TestTodosComponentsE2E/Delete_Confirmation_Modal_Appears
  • TestTodosComponentsE2E/Cancel_Delete_Modal
  • TestTodosComponentsE2E/Confirm_Delete_Modal_Deletes_Todo
  • TestBrowserDeleteFlow

Closes #24

🤖 Generated with Claude Code

chromedp.Click doesn't reliably trigger event delegation handlers in
headless Chrome. Replace with chromedp.Evaluate + JS .click() and use
e2etest.WaitFor for reliable DOM change detection.

Closes #24

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 14, 2026 19:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the todos-components E2E delete-flow tests to more reliably trigger LiveTemplate’s lvt-click delegated handlers in headless Chrome by using DOM-level JS clicks and condition-based waits.

Changes:

  • Replaced chromedp.Click with chromedp.Evaluate(... .click()) for delete-flow lvt-click interactions.
  • Replaced fixed chromedp.Sleep waits with e2etest.WaitFor conditions for modal/todo-count changes.
  • Tightened assertions for modal visibility, modal positioning, and successful deletion (todo count decreases + deleted todo absent).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +306 to 309
chromedp.Run(modalCtx,
chromedp.Evaluate(`document.querySelector('button[lvt-click="confirm_delete"]').click()`, nil),
e2etest.WaitFor(`document.querySelector('[data-modal="delete_confirm"]') !== null`, 5*time.Second),
)
@adnaan adnaan merged commit dff42b9 into main Mar 14, 2026
12 checks passed
@adnaan adnaan deleted the fix-24-delete-flow branch March 14, 2026 19:59
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.

bug: todos-components delete flow not working in E2E test

2 participants