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

Autotest implementation for:

https://app.qase.io/case/KAFKAUI-8

Description:
Checking possibility to copy the selected Topic from All Topics' list

   Pre-conditions
- Login to Kafka-ui application
- Open the 'Local' section
- Select the 'Topics'

Steps:
1)Check any Topic from All Topics' list
2)Click on 'Copy selected topic' button
3)Change the topic name
4)Press "Create topic" button

Expected results:
1)Make sure 'Delete selected topics', 'Copy selected topic', 'Purge messages of selected topics' are displayed
2)Should redirect to Copy Topic page with filled already existing data and disabled "Create topic" button
3)Create topic button should become active
4)Should redirect to newly created topic with displaying success message

Issue comments:

Pull request review comments:
let's set selectItem() method return TopicList object to avoid separate calling next method from topicList object
don't we need to wait until new screen ready first?
Added.
Fixed.

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 871ecbb752f..f24df1e926a 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
@@ -70,6 +70,12 @@ public List<SelenideElement> getActionButtons() {
           .collect(Collectors.toList());
     }
 
+    @Step
+    public TopicsList clickCopySelectedTopicBtn(){
+      copySelectedTopicBtn.shouldBe(Condition.enabled).click();
+      return this;
+    }
+
     private List<SelenideElement> getVisibleColumnHeaders() {
       return Stream.of("Replication Factor","Number of messages","Topic Name", "Partitions", "Out of sync replicas", "Size")
           .map(name -> $x(String.format(columnHeaderLocator, name)))
@@ -134,8 +140,9 @@ public TopicGridItem(SelenideElement element) {
       }
 
       @Step
-      public void selectItem(boolean select) {
-        selectElement(element.$x("./td[1]/input"), select);
+      public TopicsList selectItem(boolean select) {
+         selectElement(element.$x("./td[1]/input"), select);
+         return new TopicsList();
       }
 
       @Step


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/base/BaseTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/base/BaseTest.java
index 3a48f9f962d..9290c0af3b4 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/base/BaseTest.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/base/BaseTest.java
@@ -34,7 +34,7 @@
 
 @Slf4j
 @DisplayNameGeneration(DisplayNameGenerator.class)
-public class BaseTest extends Facade {
+public abstract class BaseTest extends Facade {
 
   private static final String SELENIUM_IMAGE_NAME = "selenium/standalone-chrome:103.0";
   private static final String SELENIARM_STANDALONE_CHROMIUM = "seleniarm/standalone-chromium:103.0";
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 01eff46b980..89857df9675 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
@@ -471,6 +471,38 @@ void recreateTopicFromTopicProfile(){
         .as("isAlertWithMessageVisible()").isTrue();
   }
 
+  @DisplayName("TopicTests.copyTopic : Copy topic")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(8)
+  @Test
+  void checkCopyTopicPossibility(){
+    Topic topicToCopy = new Topic()
+        .setName("topic-to-copy-" + randomAlphabetic(5))
+        .setNumberOfPartitions(1);
+    navigateToTopics();
+    topicsList
+        .getTopicItem("_schemas")
+        .selectItem(true)
+        .clickCopySelectedTopicBtn();
+    topicCreateEditForm
+        .waitUntilScreenReady();
+    assertThat(topicCreateEditForm.isCreateTopicButtonEnabled()).as("isCreateTopicButtonEnabled()").isFalse();
+    topicCreateEditForm
+        .setTopicName(topicToCopy.getName())
+        .setNumberOfPartitions(topicToCopy.getNumberOfPartitions())
+        .clickCreateTopicBtn();
+    topicDetails
+        .waitUntilScreenReady();
+    TOPIC_LIST.add(topicToCopy);
+    SoftAssertions softly = new SoftAssertions();
+    softly.assertThat(topicDetails.isAlertWithMessageVisible(SUCCESS, "Topic successfully created."))
+        .as("isAlertWithMessageVisible()").isTrue();
+    softly.assertThat(topicDetails.isTopicHeaderVisible(topicToCopy.getName()))
+        .as("isTopicHeaderVisible()").isTrue();
+    softly.assertAll();
+  }
+
   @AfterAll
   public void afterAll() {
     TOPIC_LIST.forEach(topic -> apiService.deleteTopic(CLUSTER_NAME, topic.getName()));