Skip to content

Conversation

@TatuLund
Copy link
Contributor

No description provided.

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

This PR adjusts how TestBenchElement#click() triggers click events so that Flow click listeners receive the correct click count, and adds an integration test view plus tests to verify single and double click behavior and focus.

Changes:

  • Update TestBenchElement.click() to dispatch a custom MouseEvent('click') with an explicit detail value instead of calling the element’s click method via callFunction("click").
  • Introduce a ButtonView test route that exposes a native button with single-click, double-click, and focus listeners reflecting click count and focus state in the DOM.
  • Add ButtonIT integration tests to validate single-click and double-click behavior (including click count and focus) via NativeButtonElement.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
vaadin-testbench-shared/src/main/java/com/vaadin/testbench/TestBenchElement.java Changes click() to use an inline JavaScript text block that dispatches a MouseEvent('click', { detail: 1, ... }) on the element, preserving focus and existing fallback behavior.
vaadin-testbench-integration-tests/src/test/java/com/vaadin/tests/elements/ButtonIT.java Adds JUnit integration tests that exercise NativeButtonElement.click() and .doubleClick() and assert correct click count and focus side effects.
vaadin-testbench-integration-tests/src/main/java/com/vaadin/testUI/ButtonView.java Adds a Flow @Route view with a native button wired with single-click, double-click, and focus listeners that update spans used by the new tests.

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

@TatuLund TatuLund requested a review from mcollovati January 27, 2026 06:24
mcollovati added a commit to vaadin/flow-components that referenced this pull request Jan 30, 2026
Adds a test that ensures Testbench is able to simulate
a click on a cell that needs scrolling to be visible.

Related to vaadin/testbench#2120
@mcollovati
Copy link
Contributor

I created a branch on flow-components to simulate the issue with double-click throwing an exception with Grid when the clicked cell is not visible without scrolling.

The test fails with the current implementation. However, it passes with this change, but only if I reaplce scrollIntoView() method in autoScrollIntoView() with the following

Map<String, Object> params = Map.of("block", "end", "inline", "end");
callFunction("scrollIntoView", params);

@TatuLund
Copy link
Contributor Author

TatuLund commented Feb 2, 2026

The test fails with the current implementation. However, it passes with this change, but only if I reaplce scrollIntoView() method in autoScrollIntoView() with the following

I incorporated the change in the PR. Your test in Flow components looks ok to me.

@mcollovati
Copy link
Contributor

To avoid potential incompatibilities, I would not change the scrollIntoView method. What about adding a new one that takes the options Map as a parameter?

Updated scrollIntoView method to accept parameters for scrolling behavior.
@TatuLund
Copy link
Contributor Author

TatuLund commented Feb 2, 2026

What about adding a new one that takes the options Map as a parameter?

Ok. Done that.

Updated the scrollIntoView method to use 'options' parameter instead of 'params' and added additional documentation.
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.

3 participants