Repository: provectus/kafka-ui
Issue: [e2e] Checking Topics settings to make sure retention.bytes is right according to Max size on disk in GB selected value
Labels: scope/QA
scope/AQA

Autotest implementation for:

https://app.qase.io/case/KAFKAUI-56

Description:

The purpose of this case is to make sure that retention.bytes value in Settings is right according to Max size on disk in GB fields' selected value (in case of 'Not set' value, retention.bytes should be '-1')

Pre-conditions :
Not set
Post-conditions :
Not set

Issue comments:

Pull request review comments:
u already added this topic at 406 line
seems here we need topicSettingsTab.waitUntilScreenReady();
can't we openDotMenu from here?
extra indent
seems we can set it to private w/o @Step, because we'll have only two methods using current inside this class
Removed.
Fixed.
Fixed.
Fixed.
Fixed.
not sure
not sure
Fixed for sure.

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTabPanel.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTab.java
similarity index 90%
rename from kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTabPanel.java
rename to kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTab.java
index b7f1402a57e..70bba6047a8 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTabPanel.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTab.java
@@ -11,13 +11,13 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-public class BrokersConfigTabPanel extends BasePage {
+public class BrokersConfigTab extends BasePage {
 
   protected List<SelenideElement> editBtn = $$x("//button[@aria-label='editAction']");
   protected SelenideElement searchByKeyField = $x("//input[@placeholder='Search by Key']");
 
   @Step
-  public BrokersConfigTabPanel waitUntilScreenReady(){
+  public BrokersConfigTab waitUntilScreenReady(){
     waitUntilSpinnerDisappear();
     searchByKeyField.shouldBe(Condition.visible);
     return this;
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicSettingsTab.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicSettingsTab.java
new file mode 100644
index 00000000000..4bf78fb2af0
--- /dev/null
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicSettingsTab.java
@@ -0,0 +1,65 @@
+package com.provectus.kafka.ui.pages.topic;
+
+import static com.codeborne.selenide.Selenide.$x;
+
+import com.codeborne.selenide.CollectionCondition;
+import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.SelenideElement;
+import com.provectus.kafka.ui.pages.BasePage;
+import io.qameta.allure.Step;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TopicSettingsTab extends BasePage {
+
+  protected SelenideElement defaultValueColumnHeaderLocator = $x("//div[text() = 'Default Value']");
+
+  @Step
+  public TopicSettingsTab waitUntilScreenReady(){
+    waitUntilSpinnerDisappear();
+    defaultValueColumnHeaderLocator.shouldBe(Condition.visible);
+    return this;
+  }
+
+  private List<SettingsGridItem> initGridItems() {
+    List<SettingsGridItem> gridItemList = new ArrayList<>();
+    allGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0))
+        .forEach(item -> gridItemList.add(new SettingsGridItem(item)));
+    return gridItemList;
+  }
+
+  private TopicSettingsTab.SettingsGridItem getItemByKey(String key){
+    return initGridItems().stream()
+        .filter(e ->e.getKey().equals(key))
+        .findFirst().orElse(null);
+  }
+
+  @Step
+  public String getValueByKey(String key){
+    return getItemByKey(key).getValue();
+  }
+
+  public static class SettingsGridItem extends BasePage {
+
+    private final SelenideElement element;
+
+    public SettingsGridItem(SelenideElement element) {
+      this.element = element;
+    }
+
+    @Step
+    public String getKey(){
+      return element.$x("./td[1]/span").getText().trim();
+    }
+
+    @Step
+    public String getValue(){
+      return element.$x("./td[2]/span").getText().trim();
+    }
+
+    @Step
+    public String getDefaultValue() {
+      return element.$x("./td[3]/span").getText().trim();
+    }
+  }
+}


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 1e3ea4d630f..c39df88dc25 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
@@ -3,7 +3,7 @@
 import com.provectus.kafka.ui.helpers.ApiHelper;
 import com.provectus.kafka.ui.pages.NaviSideBar;
 import com.provectus.kafka.ui.pages.TopPanel;
-import com.provectus.kafka.ui.pages.brokers.BrokersConfigTabPanel;
+import com.provectus.kafka.ui.pages.brokers.BrokersConfigTab;
 import com.provectus.kafka.ui.pages.brokers.BrokersDetails;
 import com.provectus.kafka.ui.pages.brokers.BrokersList;
 import com.provectus.kafka.ui.pages.connector.ConnectorCreateForm;
@@ -15,6 +15,7 @@
 import com.provectus.kafka.ui.pages.schema.SchemaDetails;
 import com.provectus.kafka.ui.pages.schema.SchemaRegistryList;
 import com.provectus.kafka.ui.pages.topic.ProduceMessagePanel;
+import com.provectus.kafka.ui.pages.topic.TopicSettingsTab;
 import com.provectus.kafka.ui.pages.topic.TopicCreateEditForm;
 import com.provectus.kafka.ui.pages.topic.TopicDetails;
 import com.provectus.kafka.ui.pages.topic.TopicsList;
@@ -37,5 +38,6 @@ public abstract class Facade {
     protected TopPanel topPanel = new TopPanel();
     protected BrokersList brokersList = new BrokersList();
     protected BrokersDetails brokersDetails = new BrokersDetails();
-    protected BrokersConfigTabPanel brokersConfigTabPanel = new BrokersConfigTabPanel();
+    protected BrokersConfigTab brokersConfigTab = new BrokersConfigTab();
+    protected TopicSettingsTab topicSettingsTab = new TopicSettingsTab();
 }
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/brokers/BrokersTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/brokers/BrokersTests.java
index 2fc2adce35c..0cba13812c3 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/brokers/BrokersTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/brokers/BrokersTests.java
@@ -46,11 +46,11 @@ public void checkExistingBrokersInCluster(){
     verifyElementsCondition(brokersDetails.getAllEnabledElements(), Condition.enabled);
     brokersDetails
         .openDetailsTab(CONFIGS);
-    brokersConfigTabPanel
+    brokersConfigTab
         .waitUntilScreenReady();
-    verifyElementsCondition(brokersConfigTabPanel.getColumnHeaders(), Condition.visible);
-    verifyElementsCondition(brokersConfigTabPanel.getEditButtons(), Condition.enabled);
-    assertThat(brokersConfigTabPanel.isSearchByKeyVisible()).as("isSearchByKeyVisible()").isTrue();
+    verifyElementsCondition(brokersConfigTab.getColumnHeaders(), Condition.visible);
+    verifyElementsCondition(brokersConfigTab.getEditButtons(), Condition.enabled);
+    assertThat(brokersConfigTab.isSearchByKeyVisible()).as("isSearchByKeyVisible()").isTrue();
   }
 
   @Step
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 e75c39f7e97..4eca498532f 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
@@ -5,6 +5,8 @@
 import static com.provectus.kafka.ui.pages.topic.enums.CleanupPolicyValue.COMPACT;
 import static com.provectus.kafka.ui.pages.topic.enums.CleanupPolicyValue.DELETE;
 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.settings.Source.CLUSTER_NAME;
 import static com.provectus.kafka.ui.utilities.FileUtils.fileToString;
@@ -46,21 +48,26 @@ public class TopicsTests extends BaseTest {
       .setCustomParameterType(COMPRESSION_TYPE)
       .setCustomParameterValue("producer")
       .setCleanupPolicyValue(DELETE);
-  private static final Topic TOPIC_FOR_UPDATE = new Topic()
+  private static final Topic TOPIC_TO_UPDATE = new Topic()
       .setName("topic-to-update-" + randomAlphabetic(5))
+      .setNumberOfPartitions(1)
       .setCleanupPolicyValue(COMPACT)
       .setTimeToRetainData("604800001")
       .setMaxSizeOnDisk(SIZE_20_GB)
       .setMaxMessageBytes("1000020")
       .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_CHECK_SETTINGS = new Topic()
+      .setName("new-topic-" + randomAlphabetic(5))
+      .setNumberOfPartitions(1)
+      .setMaxMessageBytes("1000012")
+      .setMaxSizeOnDisk(NOT_SET);
   private static final Topic TOPIC_FOR_DELETE = new Topic().setName("topic-to-delete-" + randomAlphabetic(5));
   private static final List<Topic> TOPIC_LIST = new ArrayList<>();
 
   @BeforeAll
   public void beforeAll() {
-    TOPIC_LIST.addAll(List.of(TOPIC_FOR_UPDATE, TOPIC_FOR_DELETE));
+    TOPIC_LIST.addAll(List.of(TOPIC_TO_UPDATE, TOPIC_FOR_DELETE));
     TOPIC_LIST.forEach(topic -> apiHelper.createTopic(CLUSTER_NAME, topic.getName()));
   }
 
@@ -121,33 +128,33 @@ void checkAvailableOperations() {
   @Test
   @Order(3)
   public void updateTopic() {
-    navigateToTopicsAndOpenDetails(TOPIC_FOR_UPDATE.getName());
+    navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE.getName());
     topicDetails
         .openDotMenu()
         .clickEditSettingsMenu();
     topicCreateEditForm
         .waitUntilScreenReady()
-        .selectCleanupPolicy((TOPIC_FOR_UPDATE.getCleanupPolicyValue()))
+        .selectCleanupPolicy((TOPIC_TO_UPDATE.getCleanupPolicyValue()))
         .setMinInsyncReplicas(10)
-        .setTimeToRetainDataInMs(TOPIC_FOR_UPDATE.getTimeToRetainData())
-        .setMaxSizeOnDiskInGB(TOPIC_FOR_UPDATE.getMaxSizeOnDisk())
-        .setMaxMessageBytes(TOPIC_FOR_UPDATE.getMaxMessageBytes())
+        .setTimeToRetainDataInMs(TOPIC_TO_UPDATE.getTimeToRetainData())
+        .setMaxSizeOnDiskInGB(TOPIC_TO_UPDATE.getMaxSizeOnDisk())
+        .setMaxMessageBytes(TOPIC_TO_UPDATE.getMaxMessageBytes())
         .clickCreateTopicBtn();
     topicDetails
         .waitUntilScreenReady();
-    navigateToTopicsAndOpenDetails(TOPIC_FOR_UPDATE.getName());
+    navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE.getName());
     topicDetails
         .openDotMenu()
         .clickEditSettingsMenu();
     SoftAssertions softly = new SoftAssertions();
     softly.assertThat(topicCreateEditForm.getCleanupPolicy()).as("getCleanupPolicy()")
-        .isEqualTo(TOPIC_FOR_UPDATE.getCleanupPolicyValue().getVisibleText());
+        .isEqualTo(TOPIC_TO_UPDATE.getCleanupPolicyValue().getVisibleText());
     softly.assertThat(topicCreateEditForm.getTimeToRetain()).as("getTimeToRetain()")
-        .isEqualTo(TOPIC_FOR_UPDATE.getTimeToRetainData());
+        .isEqualTo(TOPIC_TO_UPDATE.getTimeToRetainData());
     softly.assertThat(topicCreateEditForm.getMaxSizeOnDisk()).as("getMaxSizeOnDisk()")
-        .isEqualTo(TOPIC_FOR_UPDATE.getMaxSizeOnDisk().getVisibleText());
+        .isEqualTo(TOPIC_TO_UPDATE.getMaxSizeOnDisk().getVisibleText());
     softly.assertThat(topicCreateEditForm.getMaxMessageBytes()).as("getMaxMessageBytes()")
-        .isEqualTo(TOPIC_FOR_UPDATE.getMaxMessageBytes());
+        .isEqualTo(TOPIC_TO_UPDATE.getMaxMessageBytes());
     softly.assertAll();
   }
 
@@ -381,6 +388,57 @@ void checkShowInternalTopicsButtonFunctionality(){
     softly.assertAll();
   }
 
+  @DisplayName("Checking Topics settings to make sure retention.bytes is right according to Max size on disk in GB selected value")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(56)
+  @Test
+  void checkRetentionBytesAccordingToMaxSizeOnDisk(){
+    navigateToTopics();
+    topicsList
+        .clickAddTopicBtn();
+    topicCreateEditForm
+        .waitUntilScreenReady()
+        .setTopicName(TOPIC_TO_CHECK_SETTINGS.getName())
+        .setNumberOfPartitions(TOPIC_TO_CHECK_SETTINGS.getNumberOfPartitions())
+        .setMaxMessageBytes(TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes())
+        .clickCreateTopicBtn();
+    topicDetails
+        .waitUntilScreenReady();
+    TOPIC_LIST.add(TOPIC_TO_CHECK_SETTINGS);
+    topicDetails
+        .openDetailsTab(SETTINGS);
+    topicSettingsTab
+        .waitUntilScreenReady();
+    SoftAssertions softly = new SoftAssertions();
+    softly.assertThat(topicSettingsTab.getValueByKey("retention.bytes"))
+        .as("getValueOfKey(retention.bytes)").isEqualTo(TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk().getOptionValue());
+    softly.assertThat(topicSettingsTab.getValueByKey("max.message.bytes"))
+        .as("getValueOfKey(max.message.bytes)").isEqualTo(TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes());
+    softly.assertAll();
+    TOPIC_TO_CHECK_SETTINGS
+        .setMaxSizeOnDisk(SIZE_1_GB)
+        .setMaxMessageBytes("1000056");
+    topicDetails
+        .openDotMenu()
+        .clickEditSettingsMenu();
+    topicCreateEditForm
+        .waitUntilScreenReady()
+        .setMaxSizeOnDiskInGB(TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk())
+        .setMaxMessageBytes(TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes())
+        .clickCreateTopicBtn();
+    topicDetails
+        .waitUntilScreenReady()
+        .openDetailsTab(SETTINGS);
+    topicSettingsTab
+        .waitUntilScreenReady();
+    softly.assertThat(topicSettingsTab.getValueByKey("retention.bytes"))
+        .as("getValueOfKey(retention.bytes)").isEqualTo(TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk().getOptionValue());
+    softly.assertThat(topicSettingsTab.getValueByKey("max.message.bytes"))
+        .as("getValueOfKey(max.message.bytes)").isEqualTo(TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes());
+    softly.assertAll();
+  }
+
   @AfterAll
   public void afterAll() {
     TOPIC_LIST.forEach(topic -> apiHelper.deleteTopic(CLUSTER_NAME, topic.getName()));