Skip to content

Commit d69b8cb

Browse files
javier-godoypaodb
authored andcommitted
test: fix column toggle test for Vaadin 25
Close #159
1 parent 3a97b64 commit d69b8cb

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
<dependency>
129129
<groupId>com.flowingcode.vaadin.test</groupId>
130130
<artifactId>testbench-rpc</artifactId>
131-
<version>1.4.0</version>
131+
<version>1.5.0</version>
132132
<scope>test</scope>
133133
</dependency>
134134
<dependency>

src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/ColumnToggleIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* Grid Helpers Add-on
44
* %%
5-
* Copyright (C) 2022 - 2024 Flowing Code
5+
* Copyright (C) 2022 - 2026 Flowing Code
66
* %%
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
@@ -41,7 +41,8 @@ public ColumnToggleIT() {
4141
@Override
4242
public void setup() throws Exception {
4343
super.setup();
44-
grid = new GridHelperElement($(GridElement.class).waitForFirst());
44+
grid = new GridHelperElement($(GridElement.class).waitForFirst())
45+
.withVersion($server.getVersion());
4546
}
4647

4748
@Test

src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/GridHelperElement.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* Grid Helpers Add-on
44
* %%
5-
* Copyright (C) 2022 - 2025 Flowing Code
5+
* Copyright (C) 2022 - 2026 Flowing Code
66
* %%
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
@@ -19,24 +19,39 @@
1919
*/
2020
package com.flowingcode.vaadin.addons.gridhelpers.it;
2121

22+
import com.flowingcode.vaadin.testbench.rpc.Version;
2223
import com.vaadin.flow.component.checkbox.testbench.CheckboxElement;
2324
import com.vaadin.flow.component.grid.testbench.GridElement;
2425
import com.vaadin.flow.component.menubar.testbench.MenuBarElement;
2526
import com.vaadin.testbench.ElementQuery;
27+
import com.vaadin.testbench.ElementQuery.AttributeMatch.Comparison;
2628
import com.vaadin.testbench.TestBenchElement;
2729
import java.util.Arrays;
2830
import java.util.Collections;
2931
import java.util.List;
3032
import java.util.NoSuchElementException;
3133
import java.util.Optional;
34+
import lombok.NonNull;
3235
import org.openqa.selenium.By;
3336
import org.openqa.selenium.TimeoutException;
3437
import org.openqa.selenium.WebElement;
3538

3639
public class GridHelperElement extends MyGridElement {
3740

41+
private Version version;
42+
43+
private GridHelperElement(GridHelperElement e, Version version) {
44+
init(e.getWrappedElement(), e.getCommandExecutor());
45+
this.version = version;
46+
}
47+
3848
public GridHelperElement(GridElement e) {
3949
init(e.getWrappedElement(), e.getCommandExecutor());
50+
version = null;
51+
}
52+
53+
public GridHelperElement withVersion(@NonNull Version version) {
54+
return new GridHelperElement(this, version);
4055
}
4156

4257
@Override
@@ -63,8 +78,15 @@ public TestBenchElement getColumnToggleButton() {
6378

6479
public List<CheckboxElement> getColumnToggleElements() {
6580
try {
66-
return new ElementQuery<>(TestBenchElement.class,
67-
"vaadin-context-menu-overlay, vaadin-menu-bar-overlay")
81+
ElementQuery<TestBenchElement> query;
82+
if (version == null || version.getMajorVersion() < 25) {
83+
query = new ElementQuery<>(TestBenchElement.class,
84+
"vaadin-context-menu-overlay, vaadin-menu-bar-overlay");
85+
} else {
86+
query = new ElementQuery<>(TestBenchElement.class, "vaadin-menu-bar")
87+
.withAttribute("theme", "gridHelperToggle", Comparison.CONTAINS_WORD);
88+
}
89+
return query
6890
.context(getDriver())
6991
.waitForFirst(100)
7092
.$(CheckboxElement.class).all();

src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationView.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.flowingcode.vaadin.jsonmigration.InstrumentedRoute;
2727
import com.flowingcode.vaadin.jsonmigration.LegacyClientCallable;
2828
import com.flowingcode.vaadin.testbench.rpc.JsonArrayList;
29+
import com.flowingcode.vaadin.testbench.rpc.Version;
2930
import com.vaadin.flow.component.grid.Grid;
3031
import com.vaadin.flow.component.grid.Grid.Column;
3132
import com.vaadin.flow.component.grid.Grid.SelectionMode;
@@ -82,6 +83,11 @@ public IntegrationView() {
8283
return IntegrationViewCallables.super.$call(invocation);
8384
}
8485

86+
@Override
87+
public Version getVersion() {
88+
return new Version();
89+
}
90+
8591
private List<Person> getItems() {
8692
return grid.getListDataView().getItems().collect(Collectors.toList());
8793
}

src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationViewCallables.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* Grid Helpers Add-on
44
* %%
5-
* Copyright (C) 2022 - 2024 Flowing Code
5+
* Copyright (C) 2022 - 2026 Flowing Code
66
* %%
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
@@ -21,10 +21,13 @@
2121

2222
import com.flowingcode.vaadin.testbench.rpc.JsonArrayList;
2323
import com.flowingcode.vaadin.testbench.rpc.RmiCallable;
24+
import com.flowingcode.vaadin.testbench.rpc.Version;
2425
import com.vaadin.flow.component.grid.Grid.SelectionMode;
2526

2627
public interface IntegrationViewCallables extends RmiCallable {
2728

29+
Version getVersion();
30+
2831
void setColumnToggleVisible(boolean value);
2932

3033
void setSelectOnClick(boolean value);

0 commit comments

Comments
 (0)