Repository: provectus/kafka-ui
Issue: [e2e]TopicTests.editSettingsOfTopic : Edit settings of topic
Labels: scope/QA
scope/AQA

Autotest implementation for:

https://app.qase.io/case/KAFKAUI-248

Pre-conditions:
-Create a Topic with Delete cleanup policy and Time to retain data "7days"; Max size on disk "Not Set"; Maximum message size in bytes "1048588"

Post-conditions:
Not set

Steps:
-Navigate to Topics
-Select the Topic
-Select "Edit settings" from 3dot menu
-Change "Cleanup Policy"
-Change "Time to retain data" field
-Change "Max size on disk"
-Change "Maximum message size in bytes"
-Press "Update topic" button
-Press "Edit settings" from 3dot menu

Expected results:
-Topic Name field should be frozen
-"Update topic" should become active
-Input data
"2 days"
172800000 should be filled
-Input data
"50 GB"
-Input data
"1048589"
-Success message should display
Topic overview should open
-The following updated data should display:
Cleanup Policy "Compact"; Time to retain data "2days"; Max size on disk "50 GB"; Maximum message size in bytes "1048589"


Issue comments:

Pull request review comments:
u need to wait new screen after 136 line
Fix.
ok, but why do we need wait at 154. screen wasn't changed
can't we refactor TineToRetain enum with two attributes: buttonName and value. to use the same instance while setting value at he form and getting the result in asserts
Fixed.
Fixed.
Fixed.

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Topic.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Topic.java
index 53c234c8d38..16b3ef6e2fb 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Topic.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Topic.java
@@ -3,6 +3,7 @@
 import com.provectus.kafka.ui.pages.topic.enums.CleanupPolicyValue;
 import com.provectus.kafka.ui.pages.topic.enums.CustomParameterType;
 import com.provectus.kafka.ui.pages.topic.enums.MaxSizeOnDisk;
+import com.provectus.kafka.ui.pages.topic.enums.TimeToRetain;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
@@ -14,4 +15,5 @@ public class Topic {
     private CustomParameterType customParameterType;
     private CleanupPolicyValue cleanupPolicyValue;
     private MaxSizeOnDisk maxSizeOnDisk;
+    private TimeToRetain timeToRetain;
 }
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 3822cca257a..1ad65bdb36d 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
@@ -13,6 +13,7 @@
 import com.provectus.kafka.ui.pages.topic.enums.CleanupPolicyValue;
 import com.provectus.kafka.ui.pages.topic.enums.CustomParameterType;
 import com.provectus.kafka.ui.pages.topic.enums.MaxSizeOnDisk;
+import com.provectus.kafka.ui.pages.topic.enums.TimeToRetain;
 import io.qameta.allure.Step;
 
 public class TopicCreateEditForm extends BasePage {
@@ -30,6 +31,8 @@ public class TopicCreateEditForm extends BasePage {
   protected SelenideElement customParameterValueField = $x("//input[@placeholder='Value']");
   protected SelenideElement validationCustomParameterValueMsg = $x("//p[contains(text(),'Value is required')]");
   protected String ddlElementLocator = "//li[@value='%s']";
+  protected String btnTimeToRetainLocator = "//button[@class][text()='%s']";
+
 
   @Step
   public TopicCreateEditForm waitUntilScreenReady() {
@@ -46,6 +49,10 @@ public boolean isDeleteCustomParameterButtonEnabled() {
     return isEnabled(deleteCustomParameterBtn);
   }
 
+  public boolean isNameFieldEnabled(){
+    return isEnabled(nameField);
+  }
+
   @Step
   public TopicCreateEditForm setTopicName(String topicName) {
     nameField.shouldBe(Condition.enabled).clear();
@@ -118,13 +125,8 @@ public TopicCreateEditForm setNumberOfPartitions(int partitions) {
   }
 
   @Step
-  public TopicCreateEditForm setTimeToRetainDataInMsUsingButtons(String value) {
-    timeToRetainField
-        .parent()
-        .parent()
-        .$$("button")
-        .find(Condition.exactText(value))
-        .click();
+  public TopicCreateEditForm setTimeToRetainDataByButtons(TimeToRetain timeToRetain) {
+    $x(String.format(btnTimeToRetainLocator, timeToRetain.getButton())).shouldBe(Condition.enabled).click();
     return this;
   }
 
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/enums/TimeToRetain.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/enums/TimeToRetain.java
new file mode 100644
index 00000000000..9d42bf800f4
--- /dev/null
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/enums/TimeToRetain.java
@@ -0,0 +1,25 @@
+package com.provectus.kafka.ui.pages.topic.enums;
+
+public enum TimeToRetain {
+  BTN_12_HOURS("12 hours", "43200000"),
+  BTN_1_DAY("1 day", "86400000"),
+  BTN_2_DAYS("2 days", "172800000"),
+  BTN_7_DAYS("7 days", "604800000"),
+  BTN_4_WEEKS("4 weeks", "2419200000");
+
+  private final String button;
+  private final String value;
+
+  TimeToRetain(String button, String value) {
+    this.button = button;
+    this.value = value;
+  }
+
+  public String getButton(){
+    return button;
+  }
+
+  public String getValue(){
+    return value;
+  }
+}


Test patch:
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 b70daa33079..7f301835c8a 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
@@ -8,7 +8,9 @@
 import static com.provectus.kafka.ui.pages.topic.enums.CustomParameterType.COMPRESSION_TYPE;
 import static com.provectus.kafka.ui.pages.topic.enums.MaxSizeOnDisk.NOT_SET;
 import static com.provectus.kafka.ui.pages.topic.enums.MaxSizeOnDisk.SIZE_1_GB;
-import static com.provectus.kafka.ui.pages.topic.enums.MaxSizeOnDisk.SIZE_20_GB;
+import static com.provectus.kafka.ui.pages.topic.enums.MaxSizeOnDisk.SIZE_50_GB;
+import static com.provectus.kafka.ui.pages.topic.enums.TimeToRetain.BTN_2_DAYS;
+import static com.provectus.kafka.ui.pages.topic.enums.TimeToRetain.BTN_7_DAYS;
 import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
 import static org.apache.commons.lang3.RandomUtils.nextInt;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -50,10 +52,10 @@ public class TopicsTests extends BaseTest {
   private static final Topic TOPIC_TO_UPDATE_AND_DELETE = new Topic()
       .setName("topic-to-update-and-delete-" + randomAlphabetic(5))
       .setNumberOfPartitions(1)
-      .setCleanupPolicyValue(COMPACT)
-      .setTimeToRetainData("604800001")
-      .setMaxSizeOnDisk(SIZE_20_GB)
-      .setMaxMessageBytes("1000020")
+      .setCleanupPolicyValue(DELETE)
+      .setTimeToRetain(BTN_7_DAYS)
+      .setMaxSizeOnDisk(NOT_SET)
+      .setMaxMessageBytes("1048588")
       .setMessageKey(randomAlphabetic(5))
       .setMessageContent(randomAlphabetic(10));
   private static final Topic TOPIC_TO_CHECK_SETTINGS = new Topic()
@@ -132,24 +134,43 @@ public void updateTopic() {
         .openDotMenu()
         .clickEditSettingsMenu();
     topicCreateEditForm
-        .waitUntilScreenReady()
+        .waitUntilScreenReady();
+    SoftAssertions softly = new SoftAssertions();
+    softly.assertThat(topicCreateEditForm.getCleanupPolicy()).as("getCleanupPolicy()")
+        .isEqualTo(TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue().getVisibleText());
+    softly.assertThat(topicCreateEditForm.getTimeToRetain()).as("getTimeToRetain()")
+        .isEqualTo(TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain().getValue());
+    softly.assertThat(topicCreateEditForm.getMaxSizeOnDisk()).as("getMaxSizeOnDisk()")
+        .isEqualTo(TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk().getVisibleText());
+    softly.assertThat(topicCreateEditForm.getMaxMessageBytes()).as("getMaxMessageBytes()")
+        .isEqualTo(TOPIC_TO_UPDATE_AND_DELETE.getMaxMessageBytes());
+    softly.assertAll();
+    TOPIC_TO_UPDATE_AND_DELETE
+        .setCleanupPolicyValue(COMPACT)
+        .setTimeToRetain(BTN_2_DAYS)
+        .setMaxSizeOnDisk(SIZE_50_GB).setMaxMessageBytes("1048589");
+    topicCreateEditForm
         .selectCleanupPolicy((TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue()))
-        .setMinInsyncReplicas(10)
-        .setTimeToRetainDataInMs(TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetainData())
+        .setTimeToRetainDataByButtons(TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain())
         .setMaxSizeOnDiskInGB(TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk())
         .setMaxMessageBytes(TOPIC_TO_UPDATE_AND_DELETE.getMaxMessageBytes())
         .clickCreateTopicBtn();
+    softly.assertThat(topicDetails.isAlertWithMessageVisible(SUCCESS, "Topic successfully updated."))
+        .as("isAlertWithMessageVisible()").isTrue();
+    softly.assertThat(topicDetails.isTopicHeaderVisible(TOPIC_TO_UPDATE_AND_DELETE.getName()))
+        .as("isTopicHeaderVisible()").isTrue();
+    softly.assertAll();
     topicDetails
         .waitUntilScreenReady();
     navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE_AND_DELETE.getName());
     topicDetails
         .openDotMenu()
         .clickEditSettingsMenu();
-    SoftAssertions softly = new SoftAssertions();
+    softly.assertThat(topicCreateEditForm.isNameFieldEnabled()).as("isNameFieldEnabled()").isFalse();
     softly.assertThat(topicCreateEditForm.getCleanupPolicy()).as("getCleanupPolicy()")
         .isEqualTo(TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue().getVisibleText());
     softly.assertThat(topicCreateEditForm.getTimeToRetain()).as("getTimeToRetain()")
-        .isEqualTo(TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetainData());
+        .isEqualTo(TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain().getValue());
     softly.assertThat(topicCreateEditForm.getMaxSizeOnDisk()).as("getMaxSizeOnDisk()")
         .isEqualTo(TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk().getVisibleText());
     softly.assertThat(topicCreateEditForm.getMaxMessageBytes()).as("getMaxMessageBytes()")