Repository: provectus/kafka-ui
Issue: [e2e]TopicTests.recreateTopic : Recreate topic
Labels: scope/QA
scope/AQA

Autotest implementation for:

https://app.qase.io/case/KAFKAUI-240
Pre-conditions :
1)Create a Topic
2)Add messages to Topic

Steps:
1)Navigate to Topics
2)Select "Recreate topic" from 3 dot menu for Topic
3)Press "Confirm" button

Expected results:
1)Confirm the action pop up should open
2)Topic should be recreated: messages should become 0

Issue comments:

Pull request review comments:
navigateToTopics() already has topicsList.waitUntilScreenReady()

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 73e2610b7e9..afe5633e440 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
@@ -8,6 +8,7 @@
 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.Arrays;
 import java.util.List;
@@ -24,6 +25,7 @@ public class TopicsList extends BasePage {
     protected SelenideElement copySelectedTopicBtn = $x("//button[text()='Copy selected topic']");
     protected SelenideElement purgeMessagesOfSelectedTopicsBtn = $x("//button[text()='Purge messages of selected topics']");
     protected SelenideElement clearMessagesBtn = $x("//ul[contains(@class ,'open')]//div[text()='Clear Messages']");
+    protected SelenideElement recreateTopicBtn = $x("//ul[contains(@class ,'open')]//div[text()='Recreate Topic']");
 
     @Step
     public TopicsList waitUntilScreenReady() {
@@ -90,6 +92,12 @@ public TopicsList clickClearMessagesBtn(){
       return this;
     }
 
+    @Step
+    public TopicsList clickRecreateTopicBtn(){
+      clickByJavaScript(recreateTopicBtn.shouldBe(visible));
+      return this;
+    }
+
     @Step
     public TopicsList clickConfirmBtnMdl() {
     clickConfirmButton();
@@ -174,7 +182,7 @@ public TopicsList selectItem(boolean select) {
       public boolean isInternal() {
         boolean internal = false;
         try {
-          element.$x("./td[2]/a/span").shouldBe(visible);
+          element.$x("./td[2]/a/span").shouldBe(visible, Duration.ofMillis(500));
           internal = true;
         } catch (Throwable ignored) {
         }


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicMessagesTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicMessagesTests.java
index 22b3b6e97b8..68dd2f72201 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicMessagesTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicMessagesTests.java
@@ -38,11 +38,15 @@ public class TopicMessagesTests extends BaseTest {
       .setName("topic-to-clear-message-attribute-" + randomAlphabetic(5))
       .setMessageKey(fileToString(System.getProperty("user.dir") + "/src/test/resources/producedkey.txt"))
       .setMessageContent(fileToString(System.getProperty("user.dir") + "/src/test/resources/testData.txt"));
+  private static final Topic TOPIC_TO_RECREATE = new Topic()
+      .setName("topic-to-recreate-attribute-" + randomAlphabetic(5))
+      .setMessageKey(fileToString(System.getProperty("user.dir") + "/src/test/resources/producedkey.txt"))
+      .setMessageContent(fileToString(System.getProperty("user.dir") + "/src/test/resources/testData.txt"));
   private static final List<Topic> TOPIC_LIST = new ArrayList<>();
 
   @BeforeAll
   public void beforeAll() {
-    TOPIC_LIST.addAll(List.of(TOPIC_FOR_MESSAGES, TOPIC_TO_CLEAR_MESSAGES));
+    TOPIC_LIST.addAll(List.of(TOPIC_FOR_MESSAGES, TOPIC_TO_CLEAR_MESSAGES, TOPIC_TO_RECREATE));
     TOPIC_LIST.forEach(topic -> apiService.createTopic(CLUSTER_NAME, topic.getName()));
   }
 
@@ -174,6 +178,41 @@ void checkClearTopicMessage() {
     softly.assertAll();
   }
 
+  @DisplayName("TopicTests.recreateTopic : Recreate topic")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(240)
+  @Test
+  void checkRecreateTopic(){
+    navigateToTopicsAndOpenDetails(TOPIC_TO_RECREATE.getName());
+    topicDetails
+        .openDetailsTab(TopicDetails.TopicMenu.OVERVIEW)
+        .clickProduceMessageBtn();
+    produceMessagePanel
+        .waitUntilScreenReady()
+        .setContentFiled(TOPIC_TO_RECREATE.getMessageContent())
+        .setKeyField(TOPIC_TO_RECREATE.getMessageKey())
+        .submitProduceMessage();
+    topicDetails
+        .waitUntilScreenReady();
+    navigateToTopics();
+    topicsList
+        .waitUntilScreenReady();
+    assertThat(topicsList.getTopicItem(TOPIC_TO_RECREATE.getName()).getNumberOfMessages())
+        .as("getNumberOfMessages()").isEqualTo(1);
+    topicsList
+        .openDotMenuByTopicName(TOPIC_TO_RECREATE.getName())
+        .clickRecreateTopicBtn()
+        .clickConfirmBtnMdl();
+    SoftAssertions softly = new SoftAssertions();
+    softly.assertThat(topicDetails.isAlertWithMessageVisible(SUCCESS,
+            String.format("Topic %s successfully recreated!", TOPIC_TO_RECREATE.getName())))
+        .as("isAlertWithMessageVisible()").isTrue();
+    softly.assertThat(topicsList.getTopicItem(TOPIC_TO_RECREATE.getName()).getNumberOfMessages())
+        .as("getNumberOfMessages()").isEqualTo(0);
+    softly.assertAll();
+  }
+
   @AfterAll
   public void afterAll() {
     TOPIC_LIST.forEach(topic -> apiService.deleteTopic(CLUSTER_NAME, topic.getName()));