From 82242737b5dfd0aa6d0400340bbdb090f958df52 Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Fri, 23 Jan 2026 12:20:07 -0300 Subject: [PATCH 1/3] test: add waitForVaadin --- .../vaadin/addons/xterm/integration/AbstractViewTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/AbstractViewTest.java b/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/AbstractViewTest.java index ac7eb41..f3b7ad9 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/AbstractViewTest.java +++ b/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/AbstractViewTest.java @@ -2,7 +2,7 @@ * #%L * XTerm Console Addon * %% - * Copyright (C) 2020 - 2023 Flowing Code + * Copyright (C) 2020 - 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. @@ -70,6 +70,7 @@ public void setup() throws Exception { setDriver(TestBench.createDriver(new ChromeDriver())); } getDriver().get(getURL(route)); + getCommandExecutor().waitForVaadin(); } /** From c4571a598b8a8dba6b962446b7a2486ea36229e6 Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Fri, 23 Jan 2026 12:21:49 -0300 Subject: [PATCH 2/3] test: split SelectionFeatureIT into multiple tests --- .../xterm/integration/SelectionFeatureIT.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/SelectionFeatureIT.java b/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/SelectionFeatureIT.java index f08e3e1..5cf3947 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/SelectionFeatureIT.java +++ b/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/SelectionFeatureIT.java @@ -2,7 +2,7 @@ * #%L * XTerm Console Addon * %% - * Copyright (C) 2020 - 2023 Flowing Code + * Copyright (C) 2020 - 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. @@ -29,12 +29,11 @@ public class SelectionFeatureIT extends AbstractViewTest { @Test - public void testSelectionFeature() throws InterruptedException { + public void testSelectionFeature1() throws InterruptedException { XTermElement term = $(XTermElement.class).first(); - Position pos; term.write("abcd"); - pos = term.cursorPosition(); + Position pos = term.cursorPosition(); // select left, backspace term.sendKeys(Keys.SHIFT, Keys.ARROW_LEFT); @@ -69,9 +68,14 @@ public void testSelectionFeature() throws InterruptedException { term.sendKeys(Keys.BACK_SPACE); assertThat(term.currentLine(), isEmptyString()); assertThat(term.cursorPosition(), is(pos)); + } + + @Test + public void testSelectionFeature2() throws InterruptedException { + XTermElement term = $(XTermElement.class).first(); term.write("abcd"); - pos = term.cursorPosition(); + Position pos = term.cursorPosition(); // select to home, delete term.sendKeys(Keys.SHIFT, Keys.HOME); @@ -80,9 +84,16 @@ public void testSelectionFeature() throws InterruptedException { term.sendKeys(Keys.DELETE); assertThat(term.currentLine(), isEmptyString()); assertThat(term.cursorPosition(), is(pos.advance(-4, 0))); + } + + @Test + public void testSelectionFeature3() throws InterruptedException { + XTermElement term = $(XTermElement.class).first(); - // select to end, delete term.write("abcd"); + Position pos = term.cursorPosition(); + + // select to end, delete term.sendKeys(Keys.HOME); pos = term.cursorPosition(); term.sendKeys(Keys.SHIFT, Keys.END); @@ -91,7 +102,11 @@ public void testSelectionFeature() throws InterruptedException { term.sendKeys(Keys.DELETE); assertThat(term.currentLine(), isEmptyString()); assertThat(term.cursorPosition(), is(pos)); + } + @Test + public void testSelectionFeature4() throws InterruptedException { + XTermElement term = $(XTermElement.class).first(); String text = makeFullLine(term, true) + makeFullLine(term, false) + makeFullLine(term, false); // select to home, delete (wrapping) @@ -101,7 +116,12 @@ public void testSelectionFeature() throws InterruptedException { assertThat(term.getSelection(), is(text)); term.sendKeys(Keys.DELETE); assertThat(term.currentLine(), isEmptyString()); + } + @Test + public void testSelectionFeature5() throws InterruptedException { + XTermElement term = $(XTermElement.class).first(); + String text = makeFullLine(term, true) + makeFullLine(term, false) + makeFullLine(term, false); // select to end, delete (wrapping) term.write(text); assertThat(term.currentLine(), is(text)); @@ -110,7 +130,6 @@ public void testSelectionFeature() throws InterruptedException { assertThat(term.getSelection(), is(text)); term.sendKeys(Keys.DELETE); assertThat(term.currentLine(), isEmptyString()); - } } \ No newline at end of file From 7fe397421eeeb25f2c79d39163904299aeac1295 Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Fri, 23 Jan 2026 14:38:47 -0300 Subject: [PATCH 3/3] test: fix flaky SelectionFeatureIT test Close #107 --- .../vaadin/addons/xterm/integration/XTermElement.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/XTermElement.java b/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/XTermElement.java index b3bfae3..066d025 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/XTermElement.java +++ b/src/test/java/com/flowingcode/vaadin/addons/xterm/integration/XTermElement.java @@ -2,7 +2,7 @@ * #%L * XTerm Console Addon * %% - * Copyright (C) 2020 - 2023 Flowing Code + * Copyright (C) 2020 - 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. @@ -86,6 +86,11 @@ public void setPrompt(String value) { @Override public void sendKeys(CharSequence... keysToSend) { input.sendKeys(keysToSend); + // Wait for terminal to process writes by using a write callback + getCommandExecutor().getDriver().executeAsyncScript(""" + var callback = arguments[arguments.length - 1]; + arguments[0].terminal.write('', callback); + """, this); } @Override