-
Notifications
You must be signed in to change notification settings - Fork 23
fix: Fix click count in TestBenchElement#click() #2120
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
Merged
+172
−22
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5d62c4f
Add ButtonView with click and focus event handling
TatuLund cf3118c
Add ButtonIT integration tests for single and double clicks
TatuLund 673d510
Update click handling to use MouseEvent dispatch
TatuLund e1a00b5
Format
TatuLund 695e9bd
Format
TatuLund f5d9425
Format
TatuLund 5172c5f
Refactor ButtonView to extend Div
TatuLund 10ea0b9
Rename route from 'button-view' to 'ButtonView'
TatuLund 1660493
Add import for ButtonView in ButtonIT test
TatuLund 84ddbfb
Refactor button tests to use findElement method
TatuLund c2fd101
Add Selenium By import to ButtonIT test class
TatuLund b7947b1
Add import for assertEquals in ButtonIT test
TatuLund d43710d
Reorder import statements in ButtonIT.java
TatuLund f824bf1
Add import statements for JUnit and Component
TatuLund 98ea6ea
Merge branch 'main' into fix-click-count
TatuLund 919eb96
Refactor click method and add isElementInViewport
TatuLund 5dbd395
Enhance scrollIntoView to use parameters
TatuLund 5445317
Fix formatting
TatuLund c604c7f
Refactor scrollIntoView to accept parameters
TatuLund e98532d
Improve scrollIntoView method docs
TatuLund 7c724af
Merge branch 'main' into fix-click-count
mcollovati File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
vaadin-testbench-integration-tests/src/main/java/com/vaadin/testUI/ButtonView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * Copyright (C) 2000-2026 Vaadin Ltd | ||
| * | ||
| * This program is available under Vaadin Commercial License and Service Terms. | ||
| * | ||
| * See <https://vaadin.com/commercial-license-and-service-terms> for the full | ||
| * license. | ||
| */ | ||
| package com.vaadin.testUI; | ||
|
|
||
| import com.vaadin.flow.component.html.Div; | ||
| import com.vaadin.flow.component.html.NativeButton; | ||
| import com.vaadin.flow.component.html.Span; | ||
| import com.vaadin.flow.router.Route; | ||
|
|
||
| @Route("ButtonView") | ||
| public class ButtonView extends Div { | ||
|
|
||
| public ButtonView() { | ||
| NativeButton button = new NativeButton("Click me"); | ||
| button.setId("test-button"); | ||
| button.addSingleClickListener(event -> { | ||
| Span newSpan = new Span( | ||
| "Button single clicked: " + event.getClickCount()); | ||
| newSpan.setId("single-click"); | ||
| add(newSpan); | ||
| }); | ||
| button.addDoubleClickListener(event -> { | ||
| Span newSpan = new Span( | ||
| "Button double clicked: " + event.getClickCount()); | ||
| newSpan.setId("double-click"); | ||
| add(newSpan); | ||
| }); | ||
| button.addFocusListener(event -> { | ||
| Span newSpan = new Span("Button focused"); | ||
| newSpan.setId("focus-event"); | ||
| add(newSpan); | ||
| }); | ||
| add(button); | ||
| } | ||
|
|
||
| } |
51 changes: 51 additions & 0 deletions
51
vaadin-testbench-integration-tests/src/test/java/com/vaadin/tests/elements/ButtonIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * Copyright (C) 2000-2026 Vaadin Ltd | ||
| * | ||
| * This program is available under Vaadin Commercial License and Service Terms. | ||
| * | ||
| * See <https://vaadin.com/commercial-license-and-service-terms> for the full | ||
| * license. | ||
| */ | ||
| package com.vaadin.tests.elements; | ||
|
|
||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.openqa.selenium.By; | ||
|
|
||
| import com.vaadin.flow.component.Component; | ||
| import com.vaadin.testUI.ButtonView; | ||
| import com.vaadin.tests.AbstractTB6Test; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| public class ButtonIT extends AbstractTB6Test { | ||
|
|
||
| @Override | ||
| protected Class<? extends Component> getTestView() { | ||
| return ButtonView.class; | ||
| } | ||
|
|
||
| @Before | ||
| public void openAndFindElement() { | ||
| openTestURL(); | ||
| } | ||
|
|
||
| @Test | ||
| public void buttonClick_singleClick() { | ||
| $(NativeButtonElement.class).id("test-button").click(); | ||
| assertEquals("Button single clicked: 1", | ||
| findElement(By.id("single-click")).getText()); | ||
| assertEquals("Button focused", | ||
| findElement(By.id("focus-event")).getText()); | ||
| } | ||
|
|
||
| @Test | ||
| public void buttonClick_doubleClick() { | ||
| $(NativeButtonElement.class).id("test-button").doubleClick(); | ||
| assertEquals("Button double clicked: 2", | ||
| findElement(By.id("double-click")).getText()); | ||
| assertEquals("Button focused", | ||
| findElement(By.id("focus-event")).getText()); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.