Repository: provectus/kafka-ui
Issue: [e2e] Clear entered queue check
Labels: scope/QA
scope/AQA

Autotest implementation for:
https://app.qase.io/project/KAFKAUI?case=276&previewMode=side&suite=8

Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/BasePage.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/BasePage.java
index fb2e0877e22..8bd7901a635 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/BasePage.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/BasePage.java
@@ -37,9 +37,13 @@ public abstract class BasePage extends WebUtils {
   protected String pageTitleFromHeader = "//h1[text()='%s']";
   protected String pagePathFromHeader = "//a[text()='%s']/../h1";
 
+  protected boolean isSpinnerVisible(int... timeoutInSeconds) {
+    return isVisible(loadingSpinner, timeoutInSeconds);
+  }
+
   protected void waitUntilSpinnerDisappear(int... timeoutInSeconds) {
     log.debug("\nwaitUntilSpinnerDisappear");
-    if (isVisible(loadingSpinner, timeoutInSeconds)) {
+    if (isSpinnerVisible(timeoutInSeconds)) {
       loadingSpinner.shouldBe(Condition.disappear, Duration.ofSeconds(60));
     }
   }
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlDbList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlDbList.java
index 7eb35d52f33..98980cef4d1 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlDbList.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlDbList.java
@@ -1,5 +1,6 @@
 package com.provectus.kafka.ui.pages.ksqldb;
 
+import static com.codeborne.selenide.Condition.visible;
 import static com.codeborne.selenide.Selenide.$;
 import static com.codeborne.selenide.Selenide.$x;
 import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KSQL_DB;
@@ -10,12 +11,12 @@
 import com.provectus.kafka.ui.pages.BasePage;
 import com.provectus.kafka.ui.pages.ksqldb.enums.KsqlMenuTabs;
 import io.qameta.allure.Step;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.List;
 import org.openqa.selenium.By;
 
 public class KsqlDbList extends BasePage {
-
   protected SelenideElement executeKsqlBtn = $x("//button[text()='Execute KSQL Request']");
   protected SelenideElement tablesTab = $x("//nav[@role='navigation']/a[text()='Tables']");
   protected SelenideElement streamsTab = $x("//nav[@role='navigation']/a[text()='Streams']");
@@ -76,9 +77,24 @@ public KsqlTablesGridItem(SelenideElement element) {
       this.element = element;
     }
 
+    private SelenideElement getNameElm() {
+      return element.$x("./td[1]");
+    }
+
     @Step
     public String getTableName() {
-      return element.$x("./td[1]").getText().trim();
+      return getNameElm().getText().trim();
+    }
+
+    @Step
+    public boolean isVisible() {
+      boolean isVisible = false;
+      try {
+        getNameElm().shouldBe(visible, Duration.ofMillis(500));
+        isVisible = true;
+      } catch (Throwable ignored) {
+      }
+      return isVisible;
     }
 
     @Step
@@ -110,9 +126,24 @@ public KsqlStreamsGridItem(SelenideElement element) {
       this.element = element;
     }
 
+    private SelenideElement getNameElm() {
+      return element.$x("./td[1]");
+    }
+
     @Step
     public String getStreamName() {
-      return element.$x("./td[1]").getText().trim();
+      return getNameElm().getText().trim();
+    }
+
+    @Step
+    public boolean isVisible() {
+      boolean isVisible = false;
+      try {
+        getNameElm().shouldBe(visible, Duration.ofMillis(500));
+        isVisible = true;
+      } catch (Throwable ignored) {
+      }
+      return isVisible;
     }
 
     @Step
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlQueryForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlQueryForm.java
index ab24cbe9abb..4ce282b6cc5 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlQueryForm.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlQueryForm.java
@@ -40,9 +40,14 @@ public KsqlQueryForm clickClearBtn() {
   }
 
   @Step
-  public KsqlQueryForm clickExecuteBtn() {
+  public String getEnteredQuery() {
+    return queryAreaValue.getText().trim();
+  }
+
+  @Step
+  public KsqlQueryForm clickExecuteBtn(String query) {
     clickByActions(executeBtn);
-    if (queryAreaValue.getText().contains("EMIT CHANGES;")) {
+    if (query.contains("EMIT CHANGES")) {
       loadingSpinner.shouldBe(Condition.visible);
     } else {
       waitUntilSpinnerDisappear();
@@ -66,19 +71,19 @@ public KsqlQueryForm clickClearResultsBtn() {
 
   @Step
   public KsqlQueryForm clickAddStreamProperty() {
-    clickByJavaScript(addStreamPropertyBtn);
+    clickByActions(addStreamPropertyBtn);
     return this;
   }
 
   @Step
   public KsqlQueryForm setQuery(String query) {
     queryAreaValue.shouldBe(Condition.visible).click();
-    queryArea.setValue(query);
+    sendKeysByActions(queryArea, query);
     return this;
   }
 
   @Step
-  public KsqlQueryForm.KsqlResponseGridItem getTableByName(String name) {
+  public KsqlQueryForm.KsqlResponseGridItem getItemByName(String name) {
     return initItems().stream()
         .filter(e -> e.getName().equalsIgnoreCase(name))
         .findFirst().orElseThrow();
@@ -114,16 +119,20 @@ public String getType() {
       return element.$x("./td[1]").getText().trim();
     }
 
+    private SelenideElement getNameElm() {
+      return element.$x("./td[2]");
+    }
+
     @Step
     public String getName() {
-      return element.$x("./td[2]").scrollTo().getText().trim();
+      return getNameElm().scrollTo().getText().trim();
     }
 
     @Step
     public boolean isVisible() {
       boolean isVisible = false;
       try {
-        element.$x("./td[2]").shouldBe(visible, Duration.ofMillis(500));
+        getNameElm().shouldBe(visible, Duration.ofMillis(500));
         isVisible = true;
       } catch (Throwable ignored) {
       }
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java
index fef5ef654a0..a1b1523aa51 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java
@@ -95,7 +95,7 @@ public static boolean isSelected(SelenideElement element, int... timeoutInSecond
     return isSelected;
   }
 
-  public static boolean selectElement(SelenideElement element, boolean select) {
+  public static void selectElement(SelenideElement element, boolean select) {
     if (select) {
       if (!element.isSelected()) {
         clickByJavaScript(element);
@@ -105,6 +105,5 @@ public static boolean selectElement(SelenideElement element, boolean select) {
         clickByJavaScript(element);
       }
     }
-    return true;
   }
 }


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SmokeBacklog.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SmokeBacklog.java
index b89a1d0cf76..d96bbb7f3a2 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SmokeBacklog.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SmokeBacklog.java
@@ -20,59 +20,52 @@ public class SmokeBacklog extends BaseManualTest {
   public void testCaseA() {
   }
 
-  @Automation(state = TO_BE_AUTOMATED)
-  @Suite(id = KSQL_DB_SUITE_ID)
-  @QaseId(276)
-  @Test
-  public void testCaseB() {
-  }
-
   @Automation(state = TO_BE_AUTOMATED)
   @Suite(id = KSQL_DB_SUITE_ID)
   @QaseId(277)
   @Test
-  public void testCaseC() {
+  public void testCaseB() {
   }
 
   @Automation(state = TO_BE_AUTOMATED)
   @Suite(id = KSQL_DB_SUITE_ID)
   @QaseId(278)
   @Test
-  public void testCaseD() {
+  public void testCaseC() {
   }
 
   @Automation(state = TO_BE_AUTOMATED)
   @Suite(id = KSQL_DB_SUITE_ID)
   @QaseId(284)
   @Test
-  public void testCaseE() {
+  public void testCaseD() {
   }
 
   @Automation(state = TO_BE_AUTOMATED)
   @Suite(id = BROKERS_SUITE_ID)
   @QaseId(331)
   @Test
-  public void testCaseF() {
+  public void testCaseE() {
   }
 
   @Automation(state = TO_BE_AUTOMATED)
   @Suite(id = BROKERS_SUITE_ID)
   @QaseId(332)
   @Test
-  public void testCaseG() {
+  public void testCaseF() {
   }
 
   @Automation(state = TO_BE_AUTOMATED)
   @Suite(id = TOPICS_PROFILE_SUITE_ID)
   @QaseId(335)
   @Test
-  public void testCaseH() {
+  public void testCaseG() {
   }
 
   @Automation(state = TO_BE_AUTOMATED)
   @Suite(id = TOPICS_PROFILE_SUITE_ID)
   @QaseId(336)
   @Test
-  public void testCaseI() {
+  public void testCaseH() {
   }
 }
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/ksqldb/KsqlDbTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/ksqldb/KsqlDbTest.java
index d8bda606dcd..c4bbe0def4c 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/ksqldb/KsqlDbTest.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/ksqldb/KsqlDbTest.java
@@ -1,14 +1,17 @@
 package com.provectus.kafka.ui.smokesuite.ksqldb;
 
 import static com.provectus.kafka.ui.pages.ksqldb.enums.KsqlQueryConfig.SHOW_TABLES;
+import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KSQL_DB;
 import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
 
 import com.provectus.kafka.ui.BaseTest;
 import com.provectus.kafka.ui.pages.ksqldb.models.Stream;
 import com.provectus.kafka.ui.pages.ksqldb.models.Table;
+import io.qameta.allure.Step;
 import io.qase.api.annotation.QaseId;
 import java.util.ArrayList;
 import java.util.List;
+import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -16,60 +19,71 @@
 
 public class KsqlDbTest extends BaseTest {
 
-  private static final Stream STREAM_FOR_CHECK_TABLES = new Stream()
-      .setName("STREAM_FOR_CHECK_TABLES_" + randomAlphabetic(4).toUpperCase())
-      .setTopicName("TOPIC_FOR_STREAM_" + randomAlphabetic(4).toUpperCase());
+  private static final Stream DEFAULT_STREAM = new Stream()
+      .setName("DEFAULT_STREAM_" + randomAlphabetic(4).toUpperCase())
+      .setTopicName("DEFAULT_TOPIC_" + randomAlphabetic(4).toUpperCase());
   private static final Table FIRST_TABLE = new Table()
-      .setName("FIRST_TABLE" + randomAlphabetic(4).toUpperCase())
-      .setStreamName(STREAM_FOR_CHECK_TABLES.getName());
+      .setName("FIRST_TABLE_" + randomAlphabetic(4).toUpperCase())
+      .setStreamName(DEFAULT_STREAM.getName());
   private static final Table SECOND_TABLE = new Table()
-      .setName("SECOND_TABLE" + randomAlphabetic(4).toUpperCase())
-      .setStreamName(STREAM_FOR_CHECK_TABLES.getName());
+      .setName("SECOND_TABLE_" + randomAlphabetic(4).toUpperCase())
+      .setStreamName(DEFAULT_STREAM.getName());
   private static final List<String> TOPIC_NAMES_LIST = new ArrayList<>();
 
   @BeforeClass(alwaysRun = true)
   public void beforeClass() {
     apiService
-        .createStream(STREAM_FOR_CHECK_TABLES)
+        .createStream(DEFAULT_STREAM)
         .createTables(FIRST_TABLE, SECOND_TABLE);
-    TOPIC_NAMES_LIST.addAll(List.of(STREAM_FOR_CHECK_TABLES.getTopicName(),
+    TOPIC_NAMES_LIST.addAll(List.of(DEFAULT_STREAM.getTopicName(),
         FIRST_TABLE.getName(), SECOND_TABLE.getName()));
   }
 
-  @QaseId(41)
+  @QaseId(86)
   @Test(priority = 1)
-  public void checkShowTablesRequestExecution() {
-    navigateToKsqlDb();
-    ksqlDbList
-        .clickExecuteKsqlRequestBtn();
-    ksqlQueryForm
-        .waitUntilScreenReady()
-        .setQuery(SHOW_TABLES.getQuery())
-        .clickExecuteBtn();
+  public void clearResultsForExecutedRequest() {
+    navigateToKsqlDbAndExecuteRequest(SHOW_TABLES.getQuery());
     SoftAssert softly = new SoftAssert();
     softly.assertTrue(ksqlQueryForm.areResultsVisible(), "areResultsVisible()");
-    softly.assertTrue(ksqlQueryForm.getTableByName(FIRST_TABLE.getName()).isVisible(), "getTableName()");
-    softly.assertTrue(ksqlQueryForm.getTableByName(SECOND_TABLE.getName()).isVisible(), "getTableName()");
+    softly.assertAll();
+    ksqlQueryForm
+        .clickClearResultsBtn();
+    softly.assertFalse(ksqlQueryForm.areResultsVisible(), "areResultsVisible()");
     softly.assertAll();
   }
 
-  @QaseId(86)
+  @QaseId(276)
   @Test(priority = 2)
-  public void clearResultsForExecutedRequest() {
-    navigateToKsqlDb();
-    ksqlDbList
-        .clickExecuteKsqlRequestBtn();
+  public void clearEnteredQueryCheck() {
+    navigateToKsqlDbAndExecuteRequest(SHOW_TABLES.getQuery());
+    Assert.assertFalse(ksqlQueryForm.getEnteredQuery().isEmpty(), "getEnteredQuery()");
     ksqlQueryForm
-        .waitUntilScreenReady()
-        .setQuery(SHOW_TABLES.getQuery())
-        .clickExecuteBtn();
+        .clickClearBtn();
+    Assert.assertTrue(ksqlQueryForm.getEnteredQuery().isEmpty(), "getEnteredQuery()");
+  }
+
+  @QaseId(41)
+  @Test(priority = 3)
+  public void checkShowTablesRequestExecution() {
+    navigateToKsqlDbAndExecuteRequest(SHOW_TABLES.getQuery());
     SoftAssert softly = new SoftAssert();
     softly.assertTrue(ksqlQueryForm.areResultsVisible(), "areResultsVisible()");
+    softly.assertTrue(ksqlQueryForm.getItemByName(FIRST_TABLE.getName()).isVisible(), "getItemByName()");
+    softly.assertTrue(ksqlQueryForm.getItemByName(SECOND_TABLE.getName()).isVisible(), "getItemByName()");
     softly.assertAll();
+  }
+
+  @Step
+  private void navigateToKsqlDbAndExecuteRequest(String query) {
+    naviSideBar
+        .openSideMenu(KSQL_DB);
+    ksqlDbList
+        .waitUntilScreenReady()
+        .clickExecuteKsqlRequestBtn();
     ksqlQueryForm
-        .clickClearResultsBtn();
-    softly.assertFalse(ksqlQueryForm.areResultsVisible(), "areResultsVisible()");
-    softly.assertAll();
+        .waitUntilScreenReady()
+        .setQuery(query)
+        .clickExecuteBtn(query);
   }
 
   @AfterClass(alwaysRun = true)
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/MessagesTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/MessagesTest.java
index 3bbc7e7cd3d..508a3b95be8 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/MessagesTest.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/MessagesTest.java
@@ -8,7 +8,6 @@
 
 import com.provectus.kafka.ui.BaseTest;
 import com.provectus.kafka.ui.models.Topic;
-import com.provectus.kafka.ui.pages.topics.TopicDetails;
 import io.qameta.allure.Issue;
 import io.qameta.allure.Step;
 import io.qase.api.annotation.QaseId;
@@ -140,24 +139,22 @@ public void checkPurgeMessagePossibility() {
     softly.assertAll();
   }
 
-  @Ignore
-  @Issue("https://github.com/provectus/kafka-ui/issues/2394")
   @QaseId(15)
   @Test(priority = 6)
   public void checkMessageFilteringByOffset() {
     navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName());
-    topicDetails
-        .openDetailsTab(MESSAGES);
-    TopicDetails.MessageGridItem secondMessage = topicDetails.getMessageByOffset(1);
+    int nextOffset = topicDetails
+        .openDetailsTab(MESSAGES)
+        .getAllMessages().stream()
+        .findFirst().orElseThrow().getOffset() + 1;
     topicDetails
         .selectSeekTypeDdlMessagesTab("Offset")
-        .setSeekTypeValueFldMessagesTab(String.valueOf(secondMessage.getOffset()))
+        .setSeekTypeValueFldMessagesTab(String.valueOf(nextOffset))
         .clickSubmitFiltersBtnMessagesTab();
     SoftAssert softly = new SoftAssert();
     topicDetails.getAllMessages().forEach(message ->
-        softly.assertTrue(message.getOffset() == secondMessage.getOffset()
-                || message.getOffset() > secondMessage.getOffset(),
-            String.format("Expected offset is: %s, but found: %s", secondMessage.getOffset(), message.getOffset())));
+        softly.assertTrue(message.getOffset() >= nextOffset,
+            String.format("Expected offset not less: %s, but found: %s", nextOffset, message.getOffset())));
     softly.assertAll();
   }
 
@@ -168,13 +165,11 @@ public void checkMessageFilteringByOffset() {
   @Test(priority = 7)
   public void checkMessageFilteringByTimestamp() {
     navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName());
-    topicDetails
-        .openDetailsTab(MESSAGES);
-    LocalDateTime firstTimestamp = topicDetails.getMessageByOffset(0).getTimestamp();
-    List<TopicDetails.MessageGridItem> nextMessages = topicDetails.getAllMessages().stream()
+    LocalDateTime firstTimestamp = topicDetails
+        .openDetailsTab(MESSAGES)
+        .getMessageByOffset(0).getTimestamp();
+    LocalDateTime nextTimestamp = topicDetails.getAllMessages().stream()
         .filter(message -> message.getTimestamp().getMinute() != firstTimestamp.getMinute())
-        .toList();
-    LocalDateTime nextTimestamp = nextMessages.stream()
         .findFirst().orElseThrow().getTimestamp();
     topicDetails
         .selectSeekTypeDdlMessagesTab("Timestamp")
@@ -183,8 +178,7 @@ public void checkMessageFilteringByTimestamp() {
         .clickSubmitFiltersBtnMessagesTab();
     SoftAssert softly = new SoftAssert();
     topicDetails.getAllMessages().forEach(message ->
-        softly.assertTrue(message.getTimestamp().isEqual(nextTimestamp)
-                || message.getTimestamp().isAfter(nextTimestamp),
+        softly.assertFalse(message.getTimestamp().isBefore(nextTimestamp),
             String.format("Expected that %s is not before %s.", message.getTimestamp(), nextTimestamp)));
     softly.assertAll();
   }
diff --git a/kafka-ui-e2e-checks/src/test/resources/regression.xml b/kafka-ui-e2e-checks/src/test/resources/regression.xml
index fe102bae3e3..c6461ea14ca 100644
--- a/kafka-ui-e2e-checks/src/test/resources/regression.xml
+++ b/kafka-ui-e2e-checks/src/test/resources/regression.xml
@@ -1,6 +1,6 @@
 <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
 <suite name="RegressionSuite">
-    <test name="RegressionTest" enabled="true" parallel="classes" thread-count="3">
+    <test name="RegressionTest" enabled="true" parallel="classes" thread-count="2">
         <packages>
             <package name="com.provectus.kafka.ui.smokesuite.*"/>
             <package name="com.provectus.kafka.ui.sanitysuite.*"/>
diff --git a/kafka-ui-e2e-checks/src/test/resources/sanity.xml b/kafka-ui-e2e-checks/src/test/resources/sanity.xml
index c6b9b060249..bb67922402c 100644
--- a/kafka-ui-e2e-checks/src/test/resources/sanity.xml
+++ b/kafka-ui-e2e-checks/src/test/resources/sanity.xml
@@ -1,6 +1,6 @@
 <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
 <suite name="SanitySuite">
-    <test name="SanityTest" enabled="true" parallel="classes" thread-count="3">
+    <test name="SanityTest" enabled="true" parallel="classes" thread-count="2">
         <packages>
             <package name="com.provectus.kafka.ui.sanitysuite.*"/>
         </packages>
diff --git a/kafka-ui-e2e-checks/src/test/resources/smoke.xml b/kafka-ui-e2e-checks/src/test/resources/smoke.xml
index ab2929ff340..db93607727f 100644
--- a/kafka-ui-e2e-checks/src/test/resources/smoke.xml
+++ b/kafka-ui-e2e-checks/src/test/resources/smoke.xml
@@ -1,6 +1,6 @@
 <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
 <suite name="SmokeSuite">
-    <test name="SmokeTest" enabled="true" parallel="classes" thread-count="3">
+    <test name="SmokeTest" enabled="true" parallel="classes" thread-count="2">
         <packages>
             <package name="com.provectus.kafka.ui.smokesuite.*"/>
         </packages>