Repository: provectus/kafka-ui
Issue: [e2e] Checking Topic creation possibility in case of empty Topic Name
Labels: scope/QA
scope/AQA

Autotest implementation for:

https://app.qase.io/project/KAFKAUI?view=1&suite=4&case=4

Description:
Checking Creation of a new Topic with letting required field empty

Pre-conditions:
Login to Kafka-ui application

Open the 'Local' section

Select the 'Topics'

Redirect to 'Create new Topic' page with click on '+ Add a Topic' button from 'All Topics' page

Steps:
1 Let 'Topic Name *' field empty

2 Fill 'Topic name* field  "testTopic1"

Expected result: 
1 "Create topic" button should stay disabled
2 "Create topic" button should become enabled

Issue comments:

Pull request review comments:
isCreateTopicButtonEnabled()
Changed.

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicCreateEditForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicCreateEditForm.java
index 539520445ed..9a97e6dba32 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicCreateEditForm.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicCreateEditForm.java
@@ -8,6 +8,7 @@
 
 import static com.codeborne.selenide.Selenide.*;
 import static com.provectus.kafka.ui.utilities.WebUtils.clickByJavaScript;
+import static com.provectus.kafka.ui.utilities.WebUtils.isEnabled;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class TopicCreateEditForm {
@@ -269,6 +270,10 @@ public String getVisibleText() {
         }
     }
 
+    public boolean isCreateTopicButtonEnabled(){
+       return isEnabled(createTopicBtn);
+    }
+
     private TopicCreateEditForm selectFromDropDownByOptionValue(String dropDownElementName,
                                                                 String optionValue) {
         KafkaUISelectElement select = new KafkaUISelectElement(dropDownElementName);
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java
index ad93bfbc772..e35cad9769a 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java
@@ -46,4 +46,15 @@ public static boolean isVisible(SelenideElement element) {
         return isVisible;
     }
 
-}
\ No newline at end of file
+  public static boolean isEnabled(SelenideElement element) {
+    log.debug("\nisEnabled: {}", element.getSearchCriteria());
+    boolean isEnabled = false;
+    try {
+      element.shouldBe(Condition.enabled);
+      isEnabled = true;
+    } catch (Throwable e) {
+      log.debug("{} is not enabled", element.getSearchCriteria());
+    }
+    return isEnabled;
+  }
+}


Test patch:
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 97f70c194e3..07bdf3b0b52 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
@@ -1,5 +1,14 @@
 package com.provectus.kafka.ui.tests;
 
+import static com.provectus.kafka.ui.pages.NaviSideBar.SideMenuOption.TOPICS;
+import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.CleanupPolicyValue.COMPACT;
+import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.CleanupPolicyValue.DELETE;
+import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.MaxSizeOnDisk.SIZE_20_GB;
+import static com.provectus.kafka.ui.settings.Source.CLUSTER_NAME;
+import static com.provectus.kafka.ui.utilities.FileUtils.fileToString;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
+import static org.assertj.core.api.Assertions.assertThat;
+
 import com.provectus.kafka.ui.base.BaseTest;
 import com.provectus.kafka.ui.models.Topic;
 import com.provectus.kafka.ui.pages.topic.TopicDetails;
@@ -8,20 +17,16 @@
 import com.provectus.kafka.ui.utilities.qaseIoUtils.enums.Status;
 import io.qameta.allure.Issue;
 import io.qase.api.annotation.CaseId;
-import org.assertj.core.api.SoftAssertions;
-import org.junit.jupiter.api.*;
-
 import java.util.ArrayList;
 import java.util.List;
-
-import static com.provectus.kafka.ui.pages.NaviSideBar.SideMenuOption.TOPICS;
-import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.CleanupPolicyValue.COMPACT;
-import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.CleanupPolicyValue.DELETE;
-import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.MaxSizeOnDisk.SIZE_20_GB;
-import static com.provectus.kafka.ui.settings.Source.CLUSTER_NAME;
-import static com.provectus.kafka.ui.utilities.FileUtils.fileToString;
-import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
-import static org.assertj.core.api.Assertions.assertThat;
+import org.assertj.core.api.SoftAssertions;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
 
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 public class TopicTests extends BaseTest {
@@ -239,6 +244,26 @@ void redirectToConsumerFromTopic() {
                 .withFailMessage("isTopicInConsumersDetailsVisible").isTrue();
     }
 
+  @DisplayName("Checking Topic creation possibility in case of empty Topic Name")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(4)
+  @Test
+  void checkTopicCreatePossibility() {
+    naviSideBar
+        .openSideMenu(TOPICS);
+    topicsList
+        .waitUntilScreenReady()
+        .clickAddTopicBtn();
+    topicCreateEditForm
+        .waitUntilScreenReady()
+        .setTopicName("");
+    assertThat(topicCreateEditForm.isCreateTopicButtonEnabled()).as("isCreateTopicButtonEnabled()").isFalse();
+    topicCreateEditForm
+        .setTopicName("testTopic1");
+    assertThat(topicCreateEditForm.isCreateTopicButtonEnabled()).as("isCreateTopicButtonEnabled()").isTrue();
+  }
+
     @AfterAll
     public void afterAll() {
         TOPIC_LIST.forEach(topic -> apiHelper.deleteTopic(CLUSTER_NAME, topic.getName()));