diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2021-08-18 11:23:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-18 11:23:25 +0300 |
commit | 029f47f1faaa9fd421e01b3b7fc664faf0fcae8f (patch) | |
tree | 76243eb072818ffb6a51125176425e417a24c208 /uitest/src | |
parent | f0f9b27c67065b4555c9b6e213e02cf24988eb81 (diff) | |
download | vaadin-framework-029f47f1faaa9fd421e01b3b7fc664faf0fcae8f.tar.gz vaadin-framework-029f47f1faaa9fd421e01b3b7fc664faf0fcae8f.zip |
Ensure visible tab search only covers existing tabs. (#12373)
Fixes #11673
Diffstat (limited to 'uitest/src')
2 files changed, 77 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetScrolledRemoveAllButLast.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetScrolledRemoveAllButLast.java new file mode 100644 index 0000000000..64ac3542a6 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetScrolledRemoveAllButLast.java @@ -0,0 +1,48 @@ +package com.vaadin.tests.components.tabsheet; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; + +public class TabSheetScrolledRemoveAllButLast extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final TabSheet tabSheet = new TabSheet(); + tabSheet.setWidth("300px"); + + for (int i = 0; i < 10; i++) { + String caption = "Tab #" + (i + 1); + tabSheet.addTab(new Label(caption), caption); + } + // scroll + tabSheet.setSelectedTab(5); + + addComponent(tabSheet); + + Button button = new Button("Close all except last"); + button.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent clickEvent) { + int tabsCount = tabSheet.getComponentCount(); + for (int i = 0; i < tabsCount - 1; i++) { + TabSheet.Tab tab = tabSheet.getTab(0); + tabSheet.removeTab(tab); + } + } + }); + addComponent(button); + } + + @Override + protected String getTestDescription() { + return "Closing tabs shouldn't cause a client-side exception."; + } + + @Override + protected Integer getTicketNumber() { + return 11673; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetScrolledRemoveAllButLastTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetScrolledRemoveAllButLastTest.java new file mode 100644 index 0000000000..2825330519 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetScrolledRemoveAllButLastTest.java @@ -0,0 +1,29 @@ +package com.vaadin.tests.components.tabsheet; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TabSheetScrolledRemoveAllButLastTest + extends MultiBrowserTest { + + @Test + public void closeTabs() { + openTestURL("debug"); + WebElement firstTab = findElement( + By.className("v-tabsheet-tabitemcell-first")); + assertNotEquals( + "Tab bar should be scrolled, unexpected first visible tab", + "Tab #1", firstTab.getText()); + + $(ButtonElement.class).first().click(); + assertEquals("Unexpected error notification(s),", 0, + findElements(By.className("v-Notification-error")).size()); + } +} |