Repository: provectus/kafka-ui
Issue: [e2e]Checking the Brokers overview
Labels: scope/QA
scope/AQA

Autotest implementation for:

https://app.qase.io/case/KAFKAUI-1

Description:
Checking the existing brokers in a cluster

Pre-conditions:
Empty value

Post-conditions:
Empty value

Steps:
1 Login to Kafka-ui
2 Press the cluster in a left panel
3 Press the Brokers.

Expected result:
1 The existing clusters should be displayed in a left
2 Brokers, Topics, Consumers, Schema Registry, Kafka connect, KSQL DB components should be visible
3 More than 0 Brokers should be available with following information: Uptime, Partitions, Broker ID, Segment Size, Segment Count, Port, Host

Issue comments:

Pull request review comments:
why do we need order annotation is this class?
seems we don't mind which test will run first, because their instances aren't depended
seems we use this check at SmokeTest, no reason to duplicate it here. it's not correspond to main goal of this test
getBroker -> GetAllBrokers
no need to filter by visibility, because another way table won't be created
method name should start from lower case
getVisibleUptimeSummaryCells -> getUptimeSummaryCells
getVisiblePartitionsSummaryCells -> getPartitionsSummaryCells
kinky method. you trying to assert the broker's id for already shown broker in table? suggest remove it
Removed.
Renamened.
Renamened.
Fixed.
Removed.
Removed.

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 069b1b41dda..d7b342b0254 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
@@ -1,8 +1,10 @@
 package com.provectus.kafka.ui.pages;
 
+import static com.codeborne.selenide.Selenide.$$x;
 import static com.codeborne.selenide.Selenide.$x;
 
 import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.ElementsCollection;
 import com.codeborne.selenide.SelenideElement;
 import com.provectus.kafka.ui.utilities.WebUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -16,6 +18,7 @@ public abstract class BasePage extends WebUtils {
   protected SelenideElement dotMenuBtn = $x("//button[@aria-label='Dropdown Toggle']");
   protected SelenideElement alertHeader = $x("//div[@role='alert']//div[@role='heading']");
   protected SelenideElement alertMessage = $x("//div[@role='alert']//div[@role='contentinfo']");
+  protected ElementsCollection allGridItems = $$x("//tr[@class]");
   protected String summaryCellLocator = "//div[contains(text(),'%s')]";
   protected String tableElementNameLocator = "//tbody//a[contains(text(),'%s')]";
   protected String columnHeaderLocator = "//table//tr/th/div[text()='%s']";
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersList.java
index 0d9ee67492c..3df1a09304b 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersList.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersList.java
@@ -2,10 +2,15 @@
 
 import static com.codeborne.selenide.Selenide.$x;
 
+import com.codeborne.selenide.CollectionCondition;
 import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.SelenideElement;
 import com.provectus.kafka.ui.pages.BasePage;
 import io.qameta.allure.Step;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 public class BrokersList extends BasePage {
 
@@ -19,14 +24,100 @@ public BrokersList waitUntilScreenReady() {
   }
 
   @Step
-  public boolean isBrokerVisible(String brokerId) {
-    tableGrid.shouldBe(Condition.visible);
-    return isVisible(getTableElement(brokerId));
+  public BrokersList openBroker(String brokerId) {
+    getBrokerItem(brokerId).openItem();
+    return this;
+  }
+
+  private List<SelenideElement> getUptimeSummaryCells() {
+    return Stream.of("Broker Count", "Active Controllers", "Version")
+        .map(name -> $x(String.format(summaryCellLocator, name)))
+        .collect(Collectors.toList());
+  }
+
+  private List<SelenideElement> getPartitionsSummaryCells() {
+    return Stream.of("Online", "URP", "In Sync Replicas", "Out Of Sync Replicas")
+        .map(name -> $x(String.format(summaryCellLocator, name)))
+        .collect(Collectors.toList());
   }
 
   @Step
-  public BrokersList openBroker(String brokerName) {
-    getTableElement(brokerName).shouldBe(Condition.enabled).click();
-    return this;
+  public List<SelenideElement> getAllVisibleElements() {
+    List<SelenideElement> visibleElements = new ArrayList<>(getUptimeSummaryCells());
+    visibleElements.addAll(getPartitionsSummaryCells());
+    return visibleElements;
+  }
+
+  private List<SelenideElement> getEnabledColumnHeaders() {
+    return Stream.of("Broker ID", "Segment Size", "Segment Count", "Port", "Host")
+        .map(name -> $x(String.format(columnHeaderLocator, name)))
+        .collect(Collectors.toList());
+  }
+
+  @Step
+  public List<SelenideElement> getAllEnabledElements() {
+    return getEnabledColumnHeaders();
+  }
+
+  private List<BrokersList.BrokerGridItem> initGridItems() {
+    List<BrokersList.BrokerGridItem> gridItemList = new ArrayList<>();
+    allGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0))
+        .forEach(item -> gridItemList.add(new BrokersList.BrokerGridItem(item)));
+    return gridItemList;
+  }
+
+  @Step
+  public BrokerGridItem getBrokerItem(String id){
+    return initGridItems().stream()
+        .filter(e ->e.getId().equals(id))
+        .findFirst().orElse(null);
+  }
+
+  @Step
+  public List<BrokerGridItem> getAllBrokers(){
+    return initGridItems();
+  }
+
+  public static class BrokerGridItem extends BasePage {
+
+    private final SelenideElement element;
+
+    public BrokerGridItem(SelenideElement element) {
+      this.element = element;
+    }
+
+    private SelenideElement getIdElm() {
+      return element.$x("./td[1]/a");
+    }
+
+    @Step
+    public String getId() {
+      return getIdElm().getText().trim();
+    }
+
+    @Step
+    public void openItem() {
+      getIdElm().click();
+    }
+
+    @Step
+    public int getSegmentSize(){
+      return Integer.parseInt(element.$x("./td[2]").getText().trim());
+    }
+
+    @Step
+    public int getSegmentCount(){
+      return Integer.parseInt(element.$x("./td[3]").getText().trim());
+    }
+
+    @Step
+    public int getPort(){
+      return Integer.parseInt(element.$x("./td[4]").getText().trim());
+    }
+
+    @Step
+    public String getHost(){
+      return element.$x("./td[5]").getText().trim();
+    }
   }
 }
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 d6fd9af61d3..9c6c4cec936 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
@@ -218,7 +218,7 @@ public int getMessageCountAmount() {
 
   private List<TopicDetails.MessageGridItem> initItems() {
     List<TopicDetails.MessageGridItem> gridItemList = new ArrayList<>();
-    messageGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0))
+    allGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0))
         .forEach(item -> gridItemList.add(new TopicDetails.MessageGridItem(item)));
     return gridItemList;
   }
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 4c88f45aa90..871ecbb752f 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
@@ -1,11 +1,9 @@
 package com.provectus.kafka.ui.pages.topic;
 
-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;
@@ -24,7 +22,6 @@ public class TopicsList extends BasePage {
     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 ElementsCollection topicsGridItems = $$x("//tr[@class]");
 
     @Step
     public TopicsList waitUntilScreenReady() {
@@ -102,7 +99,7 @@ public List<SelenideElement> getAllEnabledElements() {
 
     private List<TopicGridItem> initGridItems() {
       List<TopicGridItem> gridItemList = new ArrayList<>();
-      topicsGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0))
+      allGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0))
           .forEach(item -> gridItemList.add(new TopicGridItem(item)));
       return gridItemList;
     }


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/brokers/BrokersTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/brokers/BrokersTests.java
index 5a493438f98..dcff92bc28c 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/brokers/BrokersTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/brokers/BrokersTests.java
@@ -17,6 +17,25 @@ public class BrokersTests extends BaseTest {
   private static final String SUITE_TITLE = "Brokers";
   private static final long SUITE_ID = 1;
 
+  @DisplayName("Checking the Brokers overview")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(1)
+  @Test
+  public void checkBrokersOverview(){
+    naviSideBar
+        .openSideMenu(BROKERS);
+    brokersList
+        .waitUntilScreenReady();
+    SoftAssertions softly = new SoftAssertions();
+    softly.assertThat(brokersList.getAllBrokers()).as("getAllBrokers()").size().isGreaterThan(0);
+    brokersList.getAllVisibleElements().forEach(element -> softly.assertThat(element.is(Condition.visible))
+        .as(element.getSearchCriteria() + " isVisible()").isTrue());
+    brokersList.getAllEnabledElements().forEach(element -> softly.assertThat(element.is(Condition.enabled))
+        .as(element.getSearchCriteria() + " isEnabled()").isTrue());
+    softly.assertAll();
+  }
+
   @DisplayName("Checking the existing Broker's profile in a cluster")
   @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
   @AutomationStatus(status = Status.AUTOMATED)
@@ -27,7 +46,7 @@ public void checkExistingBrokersInCluster(){
         .openSideMenu(BROKERS);
     brokersList
         .waitUntilScreenReady();
-    assertThat(brokersList.isBrokerVisible("1")).as("isBrokerVisible()").isTrue();
+    assertThat(brokersList.getAllBrokers()).as("getAllBrokers()").size().isGreaterThan(0);
     brokersList
         .openBroker("1");
     brokersDetails