Repository: provectus/kafka-ui
Issue: [e2e]Checking Clearing results for already executed KSQL Request
Labels: scope/QA
scope/AQA

**Autotest implementation for:**

https://app.qase.io/case/KAFKAUI-86

**Description:**
Checking Clearing results for already executed KSQL Request

**Pre-conditions:**

- Login to system

- Navigate to KSQL DB

- Execute KSQL Request

**Steps:**
1. Press the "Clear results"
**Expected result:**
All the data should disappear &&
"Clear results" button should become inactive

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/ksqlDb/KsqlQueryForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlQueryForm.java
index e34fbedb1cb..30ac1007fdb 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
@@ -1,144 +1,155 @@
 package com.provectus.kafka.ui.pages.ksqlDb;
 
-import static com.codeborne.selenide.Condition.visible;
-import static com.codeborne.selenide.Selenide.$$x;
-import static com.codeborne.selenide.Selenide.$x;
-
 import com.codeborne.selenide.CollectionCondition;
 import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.ElementsCollection;
 import com.codeborne.selenide.SelenideElement;
 import com.provectus.kafka.ui.pages.BasePage;
 import io.qameta.allure.Step;
+
 import java.time.Duration;
 import java.util.ArrayList;
 import java.util.List;
 
+import static com.codeborne.selenide.Condition.visible;
+import static com.codeborne.selenide.Selenide.$$x;
+import static com.codeborne.selenide.Selenide.$x;
+
 public class KsqlQueryForm extends BasePage {
-  protected SelenideElement pageTitle = $x("//h1[text()='Query']");
-  protected SelenideElement clearBtn = $x("//div/button[text()='Clear']");
-  protected SelenideElement executeBtn = $x("//div/button[text()='Execute']");
-  protected SelenideElement stopQueryBtn = $x("//div/button[text()='Stop query']");
-  protected SelenideElement clearResultsBtn = $x("//div/button[text()='Clear results']");
-  protected SelenideElement addStreamPropertyBtn = $x("//button[text()='Add Stream Property']");
-  protected SelenideElement queryAreaValue = $x("//div[@class='ace_content']");
-  protected SelenideElement queryArea = $x("//div[@id='ksql']/textarea[@class='ace_text-input']");
-  protected ElementsCollection ksqlGridItems = $$x("//tbody//tr");
-  protected ElementsCollection keyField = $$x("//input[@aria-label='key']");
-  protected ElementsCollection valueField = $$x("//input[@aria-label='value']");
-
-  @Step
-  public KsqlQueryForm waitUntilScreenReady() {
-    waitUntilSpinnerDisappear();
-    pageTitle.shouldBe(Condition.visible);
-    return this;
-  }
-
-  @Step
-  public KsqlQueryForm clickClearBtn() {
-    clickByJavaScript(clearBtn);
-    return this;
-  }
-
-  @Step
-  public KsqlQueryForm clickExecuteBtn() {
-    clickByJavaScript(executeBtn);
-    if (queryAreaValue.getText().contains("EMIT CHANGES;")) {
-      loadingSpinner.shouldBe(Condition.visible);
-    } else {
-      waitUntilSpinnerDisappear();
+    protected SelenideElement pageTitle = $x("//h1[text()='Query']");
+    protected SelenideElement clearBtn = $x("//div/button[text()='Clear']");
+    protected SelenideElement executeBtn = $x("//div/button[text()='Execute']");
+    protected SelenideElement stopQueryBtn = $x("//div/button[text()='Stop query']");
+    protected SelenideElement clearResultsBtn = $x("//div/button[text()='Clear results']");
+    protected SelenideElement addStreamPropertyBtn = $x("//button[text()='Add Stream Property']");
+    protected SelenideElement queryAreaValue = $x("//div[@class='ace_content']");
+    protected SelenideElement queryArea = $x("//div[@id='ksql']/textarea[@class='ace_text-input']");
+    protected ElementsCollection ksqlGridItems = $$x("//tbody//tr");
+    protected ElementsCollection keyField = $$x("//input[@aria-label='key']");
+    protected ElementsCollection valueField = $$x("//input[@aria-label='value']");
+
+    @Step
+    public KsqlQueryForm waitUntilScreenReady() {
+        waitUntilSpinnerDisappear();
+        pageTitle.shouldBe(Condition.visible);
+        return this;
     }
-    return this;
-  }
-
-  @Step
-  public KsqlQueryForm clickStopQueryBtn() {
-    clickByJavaScript(stopQueryBtn);
-    waitUntilSpinnerDisappear();
-    return this;
-  }
-
-  @Step
-  public KsqlQueryForm clickClearResultsBtn() {
-    clickByJavaScript(clearResultsBtn);
-    waitUntilSpinnerDisappear();
-    return this;
-  }
-
-  @Step
-  public KsqlQueryForm clickAddStreamProperty() {
-    clickByJavaScript(addStreamPropertyBtn);
-    return this;
-  }
-
-  @Step
-  public KsqlQueryForm setQuery(String query) {
-    queryAreaValue.shouldBe(Condition.visible).click();
-    queryArea.setValue(query);
-    return this;
-  }
-
-  private List<KsqlQueryForm.KsqlResponseGridItem> initItems() {
-    List<KsqlQueryForm.KsqlResponseGridItem> gridItemList = new ArrayList<>();
-    ksqlGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0))
-        .forEach(item -> gridItemList.add(new KsqlQueryForm.KsqlResponseGridItem(item)));
-    return gridItemList;
-  }
-
-  @Step
-  public KsqlQueryForm.KsqlResponseGridItem getTableByName(String name) {
-    return initItems().stream()
-        .filter(e -> e.getName().equalsIgnoreCase(name))
-        .findFirst().orElseThrow();
-  }
-
-  public static class KsqlResponseGridItem extends BasePage {
-
-    private final SelenideElement element;
-
-    private KsqlResponseGridItem(SelenideElement element) {
-      this.element = element;
+
+    @Step
+    public KsqlQueryForm clickClearBtn() {
+        clickByJavaScript(clearBtn);
+        return this;
     }
 
     @Step
-    public String getType() {
-      return element.$x("./td[1]").getText().trim();
+    public KsqlQueryForm clickExecuteBtn() {
+        clickByActions(executeBtn);
+        if (queryAreaValue.getText().contains("EMIT CHANGES;")) {
+            loadingSpinner.shouldBe(Condition.visible);
+        } else {
+            waitUntilSpinnerDisappear();
+        }
+        return this;
     }
 
     @Step
-    public String getName() {
-      return element.$x("./td[2]").scrollTo().getText().trim();
+    public KsqlQueryForm clickStopQueryBtn() {
+        clickByActions(stopQueryBtn);
+        waitUntilSpinnerDisappear();
+        return this;
     }
 
     @Step
-    public boolean isVisible() {
-      boolean isVisible = false;
-      try {
-        element.$x("./td[2]").shouldBe(visible, Duration.ofMillis(500));
-        isVisible = true;
-      } catch (Throwable ignored) {
-      }
-      return isVisible;
+    public KsqlQueryForm clickClearResultsBtn() {
+        clickByActions(clearResultsBtn);
+        waitUntilSpinnerDisappear();
+        return this;
     }
 
     @Step
-    public String getTopic() {
-      return element.$x("./td[3]").getText().trim();
+    public KsqlQueryForm clickAddStreamProperty() {
+        clickByJavaScript(addStreamPropertyBtn);
+        return this;
     }
 
     @Step
-    public String getKeyFormat() {
-      return element.$x("./td[4]").getText().trim();
+    public KsqlQueryForm setQuery(String query) {
+        queryAreaValue.shouldBe(Condition.visible).click();
+        queryArea.setValue(query);
+        return this;
     }
 
     @Step
-    public String getValueFormat() {
-      return element.$x("./td[5]").getText().trim();
+    public KsqlQueryForm.KsqlResponseGridItem getTableByName(String name) {
+        return initItems().stream()
+                .filter(e -> e.getName().equalsIgnoreCase(name))
+                .findFirst().orElseThrow();
     }
 
     @Step
-    public String getIsWindowed() {
-      return element.$x("./td[6]").getText().trim();
+    public boolean areResultsVisible() {
+        boolean visible = false;
+        try {
+            visible = initItems().size() > 0;
+        } catch (Throwable ignored) {
+        }
+        return visible;
+    }
+
+    private List<KsqlQueryForm.KsqlResponseGridItem> initItems() {
+        List<KsqlQueryForm.KsqlResponseGridItem> gridItemList = new ArrayList<>();
+        ksqlGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0))
+                .forEach(item -> gridItemList.add(new KsqlQueryForm.KsqlResponseGridItem(item)));
+        return gridItemList;
+    }
+
+    public static class KsqlResponseGridItem extends BasePage {
+
+        private final SelenideElement element;
+
+        private KsqlResponseGridItem(SelenideElement element) {
+            this.element = element;
+        }
+
+        @Step
+        public String getType() {
+            return element.$x("./td[1]").getText().trim();
+        }
+
+        @Step
+        public String getName() {
+            return element.$x("./td[2]").scrollTo().getText().trim();
+        }
+
+        @Step
+        public boolean isVisible() {
+            boolean isVisible = false;
+            try {
+                element.$x("./td[2]").shouldBe(visible, Duration.ofMillis(500));
+                isVisible = true;
+            } catch (Throwable ignored) {
+            }
+            return isVisible;
+        }
+
+        @Step
+        public String getTopic() {
+            return element.$x("./td[3]").getText().trim();
+        }
+
+        @Step
+        public String getKeyFormat() {
+            return element.$x("./td[4]").getText().trim();
+        }
+
+        @Step
+        public String getValueFormat() {
+            return element.$x("./td[5]").getText().trim();
+        }
+
+        @Step
+        public String getIsWindowed() {
+            return element.$x("./td[6]").getText().trim();
+        }
     }
-  }
 }


Test patch:
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 8689c0abde3..be847b00a7a 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
@@ -39,7 +39,7 @@ public void beforeClass() {
     @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
     @AutomationStatus(status = Status.AUTOMATED)
     @CaseId(41)
-    @Test
+    @Test(priority = 1)
     public void checkShowTablesRequestExecution() {
         naviSideBar
                 .openSideMenu(KSQL_DB);
@@ -51,8 +51,32 @@ public void checkShowTablesRequestExecution() {
                 .setQuery(SHOW_TABLES.getQuery())
                 .clickExecuteBtn();
         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();
     }
+
+    @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+    @AutomationStatus(status = Status.AUTOMATED)
+    @CaseId(86)
+    @Test(priority = 2)
+    public void clearResultsForExecutedRequest() {
+        naviSideBar
+                .openSideMenu(KSQL_DB);
+        ksqlDbList
+                .waitUntilScreenReady()
+                .clickExecuteKsqlRequestBtn();
+        ksqlQueryForm
+                .waitUntilScreenReady()
+                .setQuery(SHOW_TABLES.getQuery())
+                .clickExecuteBtn();
+        SoftAssert softly = new SoftAssert();
+        softly.assertTrue(ksqlQueryForm.areResultsVisible(), "areResultsVisible()");
+        softly.assertAll();
+        ksqlQueryForm
+                .clickClearResultsBtn();
+        softly.assertFalse(ksqlQueryForm.areResultsVisible(), "areResultsVisible()");
+        softly.assertAll();
+    }
 }