diff --git a/pom.xml b/pom.xml index 48c6f41..3292c53 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ com.flowingcode.vaadin.test testbench-rpc - 1.4.0 + 1.5.0 test diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/ColumnToggleIT.java b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/ColumnToggleIT.java index 1d31767..4366562 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/ColumnToggleIT.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/ColumnToggleIT.java @@ -2,7 +2,7 @@ * #%L * Grid Helpers Add-on * %% - * Copyright (C) 2022 - 2024 Flowing Code + * Copyright (C) 2022 - 2026 Flowing Code * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,8 @@ public ColumnToggleIT() { @Override public void setup() throws Exception { super.setup(); - grid = new GridHelperElement($(GridElement.class).waitForFirst()); + grid = new GridHelperElement($(GridElement.class).waitForFirst()) + .withVersion($server.getVersion()); } @Test diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/GridHelperElement.java b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/GridHelperElement.java index d194526..ad44b82 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/GridHelperElement.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/GridHelperElement.java @@ -2,7 +2,7 @@ * #%L * Grid Helpers Add-on * %% - * Copyright (C) 2022 - 2025 Flowing Code + * Copyright (C) 2022 - 2026 Flowing Code * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,24 +19,39 @@ */ package com.flowingcode.vaadin.addons.gridhelpers.it; +import com.flowingcode.vaadin.testbench.rpc.Version; import com.vaadin.flow.component.checkbox.testbench.CheckboxElement; import com.vaadin.flow.component.grid.testbench.GridElement; import com.vaadin.flow.component.menubar.testbench.MenuBarElement; import com.vaadin.testbench.ElementQuery; +import com.vaadin.testbench.ElementQuery.AttributeMatch.Comparison; import com.vaadin.testbench.TestBenchElement; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.NoSuchElementException; import java.util.Optional; +import lombok.NonNull; import org.openqa.selenium.By; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebElement; public class GridHelperElement extends MyGridElement { + private Version version; + + private GridHelperElement(GridHelperElement e, Version version) { + init(e.getWrappedElement(), e.getCommandExecutor()); + this.version = version; + } + public GridHelperElement(GridElement e) { init(e.getWrappedElement(), e.getCommandExecutor()); + version = null; + } + + public GridHelperElement withVersion(@NonNull Version version) { + return new GridHelperElement(this, version); } @Override @@ -63,8 +78,15 @@ public TestBenchElement getColumnToggleButton() { public List getColumnToggleElements() { try { - return new ElementQuery<>(TestBenchElement.class, - "vaadin-context-menu-overlay, vaadin-menu-bar-overlay") + ElementQuery query; + if (version == null || version.getMajorVersion() < 25) { + query = new ElementQuery<>(TestBenchElement.class, + "vaadin-context-menu-overlay, vaadin-menu-bar-overlay"); + } else { + query = new ElementQuery<>(TestBenchElement.class, "vaadin-menu-bar") + .withAttribute("theme", "gridHelperToggle", Comparison.CONTAINS_WORD); + } + return query .context(getDriver()) .waitForFirst(100) .$(CheckboxElement.class).all(); diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationView.java b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationView.java index 885094d..4c1a53d 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationView.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationView.java @@ -26,6 +26,7 @@ import com.flowingcode.vaadin.jsonmigration.InstrumentedRoute; import com.flowingcode.vaadin.jsonmigration.LegacyClientCallable; import com.flowingcode.vaadin.testbench.rpc.JsonArrayList; +import com.flowingcode.vaadin.testbench.rpc.Version; import com.vaadin.flow.component.grid.Grid; import com.vaadin.flow.component.grid.Grid.Column; import com.vaadin.flow.component.grid.Grid.SelectionMode; @@ -82,6 +83,11 @@ public IntegrationView() { return IntegrationViewCallables.super.$call(invocation); } + @Override + public Version getVersion() { + return new Version(); + } + private List getItems() { return grid.getListDataView().getItems().collect(Collectors.toList()); } diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationViewCallables.java b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationViewCallables.java index ee8590c..bf4df45 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationViewCallables.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/it/IntegrationViewCallables.java @@ -2,7 +2,7 @@ * #%L * Grid Helpers Add-on * %% - * Copyright (C) 2022 - 2024 Flowing Code + * Copyright (C) 2022 - 2026 Flowing Code * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,13 @@ import com.flowingcode.vaadin.testbench.rpc.JsonArrayList; import com.flowingcode.vaadin.testbench.rpc.RmiCallable; +import com.flowingcode.vaadin.testbench.rpc.Version; import com.vaadin.flow.component.grid.Grid.SelectionMode; public interface IntegrationViewCallables extends RmiCallable { + Version getVersion(); + void setColumnToggleVisible(boolean value); void setSelectOnClick(boolean value);