Repository: provectus/kafka-ui
Issue: [e2e]Checking applying saved filter within Topic/Messages
Labels: scope/QA
scope/AQA

Autotest implementation for:

https://app.qase.io/case/KAFKAUI-14

Description:
Checking applying saved filter within Messages/Topic profile

Pre-conditions:
- Login to Kafka-ui application
- Open the 'Local' section
- Select the 'Topics'
- Open the Topic profile
- Turn to Messages tab

Post-conditions:
Empty value

Steps:
1. Press '+Add Filters' button
Expected result:
'Add Filter' pop up opens
2. Click the 'Saved Filters'
3. Select the filter
4. Press 'Select Filter' button
Expected result:
- 'Add filter' pop up should disappear
- New filter should appear near '+Add Filters' button
- Corresponding data should display

Issue comments:

Pull request review comments:
can't see step according to this assert in test case
can't see step according to this assert in test case
seems here should be disappeared addFilterCodeModalTitle instead of selectFilterBtnAddFilterMdl
wrong description
deleted
deleted
refactored
here u're already at topicDetails screen, no reason in 423 line
Yes , sorry it*s my carelessness, refactored! 

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicDetails.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicDetails.java
index eb14687ed99..675857dfd7e 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicDetails.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicDetails.java
@@ -1,20 +1,18 @@
 package com.provectus.kafka.ui.pages.topic;
 
-import static com.codeborne.selenide.Selenide.$;
-import static com.codeborne.selenide.Selenide.$$x;
-import static com.codeborne.selenide.Selenide.$x;
-import static org.apache.commons.lang.math.RandomUtils.nextInt;
-
 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 org.openqa.selenium.By;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import org.openqa.selenium.By;
+
+import static com.codeborne.selenide.Selenide.*;
+import static org.apache.commons.lang.math.RandomUtils.nextInt;
 
 public class TopicDetails extends BasePage {
 
@@ -30,6 +28,7 @@ public class TopicDetails extends BasePage {
   protected SelenideElement displayNameInputAddFilterMdl = $x("//input[@placeholder='Enter Name']");
   protected SelenideElement cancelBtnAddFilterMdl = $x("//button[text()='Cancel']");
   protected SelenideElement addFilterBtnAddFilterMdl = $x("//button[text()='Add filter']");
+  protected SelenideElement selectFilterBtnAddFilterMdl = $x("//button[text()='Select filter']");
   protected SelenideElement editSettingsMenu = $x("//li[@role][contains(text(),'Edit settings')]");
   protected SelenideElement removeTopicBtn = $x("//ul[@role='menu']//div[contains(text(),'Remove Topic')]");
   protected SelenideElement confirmBtn = $x("//div[@role='dialog']//button[contains(text(),'Confirm')]");
@@ -139,6 +138,19 @@ public boolean isFilterVisibleAtSavedFiltersMdl(String filterName){
     return isVisible($x(String.format(savedFilterNameLocator,filterName)));
   }
 
+  @Step
+  public TopicDetails selectFilterAtSavedFiltersMdl(String filterName){
+    $x(String.format(savedFilterNameLocator, filterName)).shouldBe(Condition.enabled).click();
+    return this;
+  }
+
+  @Step
+  public TopicDetails clickSelectFilterBtnAtSavedFiltersMdl(){
+    selectFilterBtnAddFilterMdl.shouldBe(Condition.enabled).click();
+    addFilterCodeModalTitle.shouldBe(Condition.disappear);
+    return this;
+  }
+
   @Step
   public TopicDetails waitUntilAddFiltersMdlVisible() {
     addFilterCodeModalTitle.shouldBe(Condition.visible);


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicsTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicsTests.java
index 559baaecc63..4f7c566fba4 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicsTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicsTests.java
@@ -10,7 +10,6 @@
 import static com.provectus.kafka.ui.settings.Source.CLUSTER_NAME;
 import static com.provectus.kafka.ui.utilities.FileUtils.fileToString;
 import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
-import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import com.codeborne.selenide.Condition;
@@ -388,7 +387,7 @@ void checkFilterSavingWithinSavedFilters() {
         .openDetailsTab(MESSAGES)
         .clickMessagesAddFiltersBtn()
         .waitUntilAddFiltersMdlVisible()
-        .setFilterCodeFieldAddFilterMdl(randomAlphanumeric(4))
+        .setFilterCodeFieldAddFilterMdl(randomAlphabetic(4))
         .selectSaveThisFilterCheckboxMdl(true)
         .setDisplayNameFldAddFilterMdl(displayName);
     assertThat(topicDetails.isAddFilterBtnAddFilterMdlEnabled()).as("isAddFilterBtnAddFilterMdlEnabled()")
@@ -400,12 +399,41 @@ void checkFilterSavingWithinSavedFilters() {
         .as("isFilterVisibleAtSavedFiltersMdl()").isTrue();
   }
 
+  @DisplayName("Checking applying saved filter within Topic/Messages")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(14)
+  @Test
+  @Order(12)
+  void checkingApplyingSavedFilterWithinTopicMessages() {
+    String displayName = randomAlphabetic(5);
+    naviSideBar
+        .openSideMenu(TOPICS);
+    topicsList
+        .waitUntilScreenReady()
+        .openTopic("my_ksql_1ksql_processing_log");
+    topicDetails
+        .waitUntilScreenReady()
+        .openDetailsTab(MESSAGES)
+        .clickMessagesAddFiltersBtn()
+        .waitUntilAddFiltersMdlVisible()
+        .setFilterCodeFieldAddFilterMdl(randomAlphabetic(4))
+        .selectSaveThisFilterCheckboxMdl(true)
+        .setDisplayNameFldAddFilterMdl(displayName)
+        .clickAddFilterBtnAndCloseMdl(false)
+        .openSavedFiltersListMdl()
+        .selectFilterAtSavedFiltersMdl(displayName)
+        .clickSelectFilterBtnAtSavedFiltersMdl();
+    assertThat(topicDetails.isActiveFilterVisible(displayName))
+        .as("isActiveFilterVisible()").isTrue();
+  }
+
   @DisplayName("Checking 'Show Internal Topics' toggle functionality within 'All Topics' page")
   @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(11)
   @Test
-  @Order(12)
+  @Order(13)
   void checkShowInternalTopicsButtonFunctionality(){
     naviSideBar
         .openSideMenu(TOPICS);