Repository: provectus/kafka-ui
Issue: Checking available operations for selected Topic within 'All Topics' page
Labels: scope/QA
scope/AQA

Auto test implementation for:

https://app.qase.io/case/KAFKAUI-7

Description:
Checking available operations for selected Topic within 'All Topics' page

Pre-conditions:

Login to Kafka-ui application

Open the 'Local' section

Select the 'Topics'

Steps:

1. Check any Topic from 'All Topics' list

Expected result:
Should display 'Delete selected topics', 'Copy selected topic' 'Purge messages of selected topics' options

2. Check one more Topic from 'All Topics' list

Expected result:
Should disappear 'Copy selected topic' function

Issue comments:

Pull request review comments:
are you sure this case will run before deleteTopic() every time without test run order specifying?
here we don't need soft assertion, because it's a new step in test don't related to previous action. is there's any mismatch inside the getEnabledActionButtons() loop test should fail there
why do we need this duplicated method? seems we can set getActionButtons public with Step annotation and use it instead
1. method works with the one element -> it should have name of this element in the title
2. seems better to use boolean (ex: isCopySelectedTopicBtnEnabled()) and assert it inside test as isTrue os isFalse
this method will select and UNSELECT checkbox because u don't check its state inside. we hase isSelected() method in selenide 
u can do like if(!element.isSelected()) element.click() -> this way method can be named 'selectCheckboxByName'
and the main point -> i've asked u to take different functions to avoid merge conflicts. Arthur now works on implementing the inner class to work with this grid. and your implementation is temporary here
Done
done
Done
Added @TestMethodOrder(MethodOrderer.OrderAnnotation.class) and sorted tests with order
Refactored with Assertions.assertFalse
can we use here and at 121 line some default instances? seems if topic creation by api will fail we'll lose atomicity and get additional failed test
changed to connect_configs and connect_offset topics 

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
index c32621bf1a5..11d47a07ca3 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
@@ -18,7 +18,10 @@ public class TopicsList extends BasePage {
     protected SelenideElement addTopicBtn = $x("//button[normalize-space(text()) ='Add a Topic']");
     protected SelenideElement searchField = $x("//input[@placeholder='Search by Topic Name']");
     protected SelenideElement showInternalRadioBtn = $x("//input[@name='ShowInternalTopics']");
-    protected String actionButtonLocator = "//button[text()='%s']";
+    protected SelenideElement deleteSelectedTopicsBtn = $x("//button[text()='Delete selected topics']");
+    protected SelenideElement copySelectedTopicBtn = $x("//button[text()='Copy selected topic']");
+    protected SelenideElement purgeMessagesOfSelectedTopicsBtn = $x("//button[text()='Purge messages of selected topics']");
+    protected String checkBoxListLocator = "//a[@title='%s']//ancestor::td/../td/input[@type='checkbox']";
 
     @Step
     public TopicsList waitUntilScreenReady() {
@@ -45,9 +48,21 @@ public TopicsList openTopic(String topicName) {
         return this;
     }
 
-    private List<SelenideElement> getActionButtons() {
-      return Stream.of("Delete selected topics", "Copy selected topic", "Purge messages of selected topics")
-          .map(name -> $x(String.format(actionButtonLocator, name)))
+    @Step
+    public TopicsList selectCheckboxByName(String topicName){
+      SelenideElement checkBox = $x(String.format(checkBoxListLocator,topicName));
+      if(!checkBox.is(Condition.selected)){clickByJavaScript(checkBox);}
+      return this;
+    }
+
+    @Step
+    public boolean isCopySelectedTopicBtnEnabled(){
+      return isEnabled(copySelectedTopicBtn);
+    }
+
+    @Step
+    public List<SelenideElement> getActionButtons() {
+      return Stream.of(deleteSelectedTopicsBtn, copySelectedTopicBtn, purgeMessagesOfSelectedTopicsBtn)
           .collect(Collectors.toList());
     }
 


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 c342a216074..05b614c3bbb 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
@@ -27,10 +27,14 @@
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestMethodOrder;
 
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 public class TopicsTests extends BaseTest {
   private static final long SUITE_ID = 2;
   private static final String SUITE_TITLE = "Topics";
@@ -63,6 +67,7 @@ public void beforeAll() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(199)
   @Test
+  @Order(1)
   public void createTopic() {
     naviSideBar
         .openSideMenu(TOPICS);
@@ -97,6 +102,28 @@ public void createTopic() {
     TOPIC_LIST.add(TOPIC_TO_CREATE);
   }
 
+  @DisplayName("Checking available operations for selected Topic within 'All Topics' page")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(7)
+  @Test
+  @Order(2)
+  void checkAvailableOperations(){
+    String processingTopic = "my_ksql_1ksql_processing_log";
+    String confluentTopic = "_confluent-ksql-my_ksql_1_command_topic";
+    naviSideBar
+        .openSideMenu(TOPICS);
+    topicsList
+        .waitUntilScreenReady()
+        .selectCheckboxByName(processingTopic);
+    topicsList.getActionButtons().
+        forEach(element -> assertThat(element.is(Condition.enabled))
+            .as(element.getSearchCriteria() + " isEnabled()").isTrue());
+    topicsList
+        .selectCheckboxByName(confluentTopic);
+    Assertions.assertFalse(topicsList.isCopySelectedTopicBtnEnabled(),"isCopySelectedTopicBtnEnabled()");
+  }
+
   @Disabled()
   @Issue("https://github.com/provectus/kafka-ui/issues/2625")
   @DisplayName("should update a topic")
@@ -104,6 +131,7 @@ public void createTopic() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(197)
   @Test
+  @Order(3)
   public void updateTopic() {
     naviSideBar
         .openSideMenu(TOPICS);
@@ -150,6 +178,7 @@ public void updateTopic() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(207)
   @Test
+  @Order(4)
   public void deleteTopic() {
     naviSideBar
         .openSideMenu(TOPICS);
@@ -174,6 +203,7 @@ public void deleteTopic() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(20)
   @Test
+  @Order(5)
   void redirectToConsumerFromTopic() {
     String topicName = "source-activities";
     String consumerGroupId = "connect-sink_postgres_activities";
@@ -199,6 +229,7 @@ void redirectToConsumerFromTopic() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(4)
   @Test
+  @Order(6)
   void checkTopicCreatePossibility() {
     naviSideBar
         .openSideMenu(TOPICS);
@@ -219,6 +250,7 @@ void checkTopicCreatePossibility() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(6)
   @Test
+  @Order(7)
   void checkCustomParametersWithinCreateNewTopic() {
     naviSideBar
         .openSideMenu(TOPICS);
@@ -243,6 +275,7 @@ void checkCustomParametersWithinCreateNewTopic() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(2)
   @Test
+  @Order(8)
   void checkTopicListElements() {
     naviSideBar
         .openSideMenu(TOPICS);
@@ -263,6 +296,7 @@ void checkTopicListElements() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(12)
   @Test
+  @Order(9)
   void addingNewFilterWithinTopic() {
     String topicName = "_schemas";
     String filterName = "123ABC";