Repository: provectus/kafka-ui
Issue: [e2e] TopicTests.redirectToConsumerFromTopicProfile : Redirect to consumer from topic profile
Labels: scope/QA
scope/AQA

Autotest implentation for:
https://app.qase.io/project/KAFKAUI?view=1&suite=5&previewMode=side&case=20

Description:
Checking redirection to Consumer group from Topic profile

Preconditions:
Login to Kafka-ui application

Open the 'Local' section

Select the 'Topics'

Open the Topic profile

Turn to Consumers tab

Steps:
1 Click on Consumer

Expected result:
Should redirect to Consumer group profile



Issue comments:

Pull request review comments:
please add .withFailMessage
seems this annotations is no used in this class
seems this annotations is no used in this class
this class is not used in current test, will we used it in in foreseeable future?
please remove extra space
why do we define this element like string? can we create SelenideElement from the start?
Done
Done
Done
Yes, In next autotests implementations
This aproach is not unique and used in line 17. Definition of this element like string, requires to wraping it by String.format that affects on element searching and as result the Test fails with error. (ХЗ why and it`s requires additional investigation...)
really?
good. let's create only classes we use in current test next time, pls
is it button or tab? use the type in naming pls
add also here .withFailMessage, pls
it's not unique, but it used when we format the string with dynamic values. can't see the reason in this case
looks like it's consumer group id. I belive the best way is to not hardcode this name and create method openConsumerGroup(String id) and use additional variable with its id in test
don't see any difference between element search because at 28 line you use $x(thisString) as argument for isVisible() method. tested with SelenideElement -> passed. if you have some fails or unstable result need to investigate additionally
please not hardcode consumer id in methods
if the value used more than one time in test mb we can create local var?
Done
Done
It's Id. Refactored
Done
Done
you created instance var, but there's a lot of different topics we use in tests inside class, that's why abstract name is not preferred. if you want to use in on class level, let's define specific names for TOPIC_NAME and TOPIC_ID -> what topic or where we use it. mb we can create Topic object which we use in tests. but seems we can also use as local vars (inside tests), this way we understand were we use this var and scefific namin is not required
it's not only sourceActivitiesConsumerId. first of all please use type in var names ->  Locator in such cases. and also it can be used for another consumer ids, not only for sourceActivities. rename pls -> consumerIdLocator
it's not only connectSinkPostgresActivitiesHeader. first of all please use type in var names -> Locator in such cases. and also it can be used for another consumer ids, not only for connectSinkPostgresActivities. rename pls -> consumerIdHeaderLocator
no space before annotation and extra next line

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumer/ConsumersDetails.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumer/ConsumersDetails.java
new file mode 100644
index 00000000000..37b020d935a
--- /dev/null
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumer/ConsumersDetails.java
@@ -0,0 +1,32 @@
+package com.provectus.kafka.ui.pages.consumer;
+
+import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.SelenideElement;
+import io.qameta.allure.Step;
+
+import static com.codeborne.selenide.Selenide.$x;
+import static com.provectus.kafka.ui.utilities.WebUtils.isVisible;
+
+public class ConsumersDetails {
+
+    protected SelenideElement loadingSpinner = $x("//*[contains(text(),'Loading')]");
+    protected SelenideElement topicGrid = $x("//table");
+    protected String consumerIdHeaderLocator = "//h1[contains(text(),'%s')]";
+    protected String topicElementLocator = "//tbody//td//a[text()='%s']";
+    @Step
+    public ConsumersDetails waitUntilScreenReady() {
+        loadingSpinner.shouldBe(Condition.disappear);
+        topicGrid.shouldBe(Condition.visible);
+        return this;
+    }
+    @Step
+    public boolean isRedirectedConsumerTitleVisible(String consumerGroupId) {
+        return isVisible($x(String.format(consumerIdHeaderLocator, consumerGroupId)));
+    }
+    @Step
+    public boolean isTopicInConsumersDetailsVisible(String topicName) {
+        topicGrid.shouldBe(Condition.visible);
+        return isVisible($x(String.format(topicElementLocator, topicName)));
+    }
+
+}
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumer/ConsumersList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumer/ConsumersList.java
new file mode 100644
index 00000000000..0797d121955
--- /dev/null
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumer/ConsumersList.java
@@ -0,0 +1,11 @@
+package com.provectus.kafka.ui.pages.consumer;
+
+import com.codeborne.selenide.SelenideElement;
+import com.provectus.kafka.ui.utilities.WaitUtils;
+import lombok.experimental.ExtensionMethod;
+
+import static com.codeborne.selenide.Selenide.$x;
+public class ConsumersList {
+
+    protected SelenideElement consumerListHeader = $x("//h1[text()='Consumers']");
+}
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 5b4f1d3c962..73ce320a485 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
@@ -26,6 +26,7 @@ public class TopicDetails {
     protected SelenideElement confirmBtn = $x("//div[@role='dialog']//button[contains(text(),'Confirm')]");
     protected SelenideElement produceMessageBtn = $x("//div//button[text()='Produce Message']");
     protected SelenideElement contentMessageTab = $x("//html//div[@id='root']/div/main//table//p");
+    protected String consumerIdLocator = "//a[@title='%s']";
 
     @Step
     public TopicDetails waitUntilScreenReady() {
@@ -74,6 +75,12 @@ public TopicDetails clickProduceMessageBtn() {
         return this;
     }
 
+    @Step
+    public TopicDetails openConsumerGroup(String consumerId) {
+        $x(String.format(consumerIdLocator, consumerId)).click();
+        return this;
+    }
+
     @Step
     public boolean isKeyMessageVisible(String keyMessage) {
         return keyMessage.equals($("td[title]").getText());


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/base/Facade.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/base/Facade.java
index 8d3aea55d4f..ac223c62b11 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/base/Facade.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/base/Facade.java
@@ -5,6 +5,8 @@
 import com.provectus.kafka.ui.pages.connector.ConnectorCreateForm;
 import com.provectus.kafka.ui.pages.connector.ConnectorDetails;
 import com.provectus.kafka.ui.pages.connector.KafkaConnectList;
+import com.provectus.kafka.ui.pages.consumer.ConsumersDetails;
+import com.provectus.kafka.ui.pages.consumer.ConsumersList;
 import com.provectus.kafka.ui.pages.schema.SchemaCreateForm;
 import com.provectus.kafka.ui.pages.schema.SchemaDetails;
 import com.provectus.kafka.ui.pages.schema.SchemaRegistryList;
@@ -25,5 +27,7 @@ public abstract class Facade {
     protected TopicCreateEditForm topicCreateEditForm = new TopicCreateEditForm();
     protected TopicsList topicsList = new TopicsList();
     protected TopicDetails topicDetails = new TopicDetails();
+    protected ConsumersDetails consumersDetails = new ConsumersDetails();
+    protected ConsumersList consumersList = new ConsumersList();
     protected NaviSideBar naviSideBar = new NaviSideBar();
 }
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
index 2b596a9e545..33ad3d015a1 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
@@ -15,14 +15,15 @@
 import java.util.List;
 
 import static com.provectus.kafka.ui.pages.NaviSideBar.SideMenuOption.TOPICS;
-import static com.provectus.kafka.ui.pages.topic.TopicDetails.DotPartitionIdMenu.CLEAR_MESSAGES;
 import static com.provectus.kafka.ui.settings.Source.CLUSTER_NAME;
 import static com.provectus.kafka.ui.utilities.FileUtils.fileToString;
+import static org.assertj.core.api.Assertions.assertThat;
 
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 public class TopicTests extends BaseTest {
     private static final long SUITE_ID = 2;
     private static final String SUITE_TITLE = "Topics";
+
     private static final Topic TOPIC_FOR_UPDATE = new Topic()
             .setName("topic-to-update")
             .setCleanupPolicyValue("Compact")
@@ -186,11 +187,38 @@ void clearMessage() {
         topicDetails
                 .waitUntilScreenReady();
         String messageAmount = topicDetails.MessageCountAmount();
-        Assertions.assertEquals(messageAmount,topicDetails.MessageCountAmount());
+        assertThat(messageAmount)
+                .withFailMessage("message amount not equals").isEqualTo(topicDetails.MessageCountAmount());
         topicDetails
                 .openDotPartitionIdMenu()
                 .clickClearMessagesBtn();
-//        Assertions.assertEquals(Integer.toString(Integer.valueOf(messageAmount)-1),topicDetails.MessageCountAmount());
+//        assertThat(Integer.toString(Integer.valueOf(messageAmount)-1))
+//                .withFailMessage("message amount not decrease by one").isEqualTo(topicDetails.MessageCountAmount());
+    }
+
+    @DisplayName("Redirect to consumer from topic profile")
+    @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+    @AutomationStatus(status = Status.AUTOMATED)
+    @CaseId(20)
+    @Test
+    void redirectToConsumerFromTopic() {
+        String topicName = "source-activities";
+        String consumerGroupId = "connect-sink_postgres_activities";
+        naviSideBar
+                .openSideMenu(TOPICS);
+        topicsList
+                .waitUntilScreenReady()
+                .openTopic(topicName);
+        topicDetails
+                .waitUntilScreenReady()
+                .openTopicMenu(TopicDetails.TopicMenu.CONSUMERS)
+                .openConsumerGroup(consumerGroupId);
+        consumersDetails
+                .waitUntilScreenReady();
+        assertThat(consumersDetails.isRedirectedConsumerTitleVisible(consumerGroupId))
+                .withFailMessage("isRedirectedConsumerTitleVisible").isTrue();
+        assertThat(consumersDetails.isTopicInConsumersDetailsVisible(topicName))
+                .withFailMessage("isTopicInConsumersDetailsVisible").isTrue();
     }
 
     @AfterAll