Repository: provectus/kafka-ui
Issue: [e2e]Checking "Time to retain data (in ms)" custom value with editing Topic's settings
Labels: scope/QA
scope/AQA

Autotest implementation for:

https://app.qase.io/case/KAFKAUI-266

Description:
Purpose of this case is to check custom "Time to retain data (in ms)" to not be default value always

Pre-conditions:
Login to https://www.kafka-ui.provectus.io/

Post-conditions:
Empty value

Steps:
1. Navigate to Topics from left navigation bar
2. Add a Topic
Expected result:
Topic form should open with "604800000" default value for "Time to retain data (in ms)"
3. Fill Topic name
4. Change "Time to retain data (in ms)" value
Input data:
"86400000" 1 day
5. Press "Create Topic"
Expected result:
New created Topic profile should open
6. Select "Edit settings" from menu icon
Expected result:
Custom "86400000" value for "Time to retain data (in ms)" should be displayed instead of default value

Issue comments:

Pull request review comments:
not sure we really need this linebreak
I believe we need to wait until screen ready first
TOPIC_TO_RETAIN_DATA rename to cameCase pls
for example -> topicWithTimeToRetain
let's keep a single style in namings. all topics in this class are named using next pattern: topic-name-randomAlphabetic(5)
Deleted 
added 
Yes , it*s not a constant variable , refactored 
changed to randomAlphabetic(5)

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicDetails.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicDetails.java
index 9c6c4cec936..eb14687ed99 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicDetails.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicDetails.java
@@ -43,6 +43,7 @@ public class TopicDetails extends BasePage {
   protected String consumerIdLocator = "//a[@title='%s']";
   protected String topicHeaderLocator = "//h1[contains(text(),'%s')]";
   protected String activeFilterNameLocator = "//div[@data-testid='activeSmartFilter'][contains(text(),'%s')]";
+  protected String settingsGridValueLocator = "//tbody/tr/td/span[text()='%s']//ancestor::tr/td[2]/span";
 
   @Step
   public TopicDetails waitUntilScreenReady() {
@@ -58,6 +59,11 @@ public TopicDetails openDetailsTab(TopicMenu menu) {
     return this;
   }
 
+  @Step
+  public String getSettingsGridValueByKey(String key){
+    return $x(String.format(settingsGridValueLocator, key)).scrollTo().shouldBe(Condition.visible).getText();
+  }
+
   @Step
   public TopicDetails openDotMenu() {
     clickByJavaScript(dotMenuBtn);


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 a90b299cf25..559baaecc63 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
@@ -2,6 +2,7 @@
 
 import static com.provectus.kafka.ui.pages.NaviSideBar.SideMenuOption.TOPICS;
 import static com.provectus.kafka.ui.pages.topic.TopicDetails.TopicMenu.MESSAGES;
+import static com.provectus.kafka.ui.pages.topic.TopicDetails.TopicMenu.SETTINGS;
 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;
@@ -248,12 +249,47 @@ void checkTopicCreatePossibility() {
     assertThat(topicCreateEditForm.isCreateTopicButtonEnabled()).as("isCreateTopicButtonEnabled()").isTrue();
   }
 
+  @DisplayName("Checking 'Time to retain data (in ms)' custom value with editing Topic's settings")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(266)
+  @Test
+  @Order(7)
+  void checkTimeToRetainDataCustomValueWithEditingTopic() {
+    Topic topicToRetainData = new Topic()
+        .setName("topic-to-retain-data-" + randomAlphabetic(5))
+        .setTimeToRetainData("86400000");
+    naviSideBar
+        .openSideMenu(TOPICS);
+    topicsList
+        .waitUntilScreenReady()
+        .clickAddTopicBtn();
+    topicCreateEditForm
+        .waitUntilScreenReady()
+        .setTopicName(topicToRetainData.getName());
+    assertThat(topicCreateEditForm.getTimeToRetain()).as("getTimeToRetain()").isEqualTo("604800000");
+    topicCreateEditForm
+        .setTimeToRetainDataInMs(topicToRetainData.getTimeToRetainData())
+        .clickCreateTopicBtn();
+    topicDetails
+        .waitUntilScreenReady()
+        .openDotMenu()
+        .clickEditSettingsMenu();
+    assertThat(topicCreateEditForm.getTimeToRetain()).as("getTimeToRetain()")
+        .isEqualTo(topicToRetainData.getTimeToRetainData());
+    topicDetails
+        .openDetailsTab(SETTINGS);
+    assertThat(topicDetails.getSettingsGridValueByKey("retention.ms")).as("getSettingsGridValueByKey()")
+        .isEqualTo(topicToRetainData.getTimeToRetainData());
+    TOPIC_LIST.add(topicToRetainData);
+  }
+
   @DisplayName("Checking requiredness of Custom parameters within 'Create new Topic'")
   @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(6)
   @Test
-  @Order(7)
+  @Order(8)
   void checkCustomParametersWithinCreateNewTopic() {
     naviSideBar
         .openSideMenu(TOPICS);
@@ -278,7 +314,7 @@ void checkCustomParametersWithinCreateNewTopic() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(2)
   @Test
-  @Order(8)
+  @Order(9)
   void checkTopicListElements() {
     naviSideBar
         .openSideMenu(TOPICS);
@@ -299,9 +335,9 @@ void checkTopicListElements() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(12)
   @Test
-  @Order(9)
+  @Order(10)
   void addingNewFilterWithinTopic() {
-    String filterName = randomAlphanumeric(5);
+    String filterName = randomAlphabetic(5);
     naviSideBar
         .openSideMenu(TOPICS);
     topicsList
@@ -339,9 +375,9 @@ void addingNewFilterWithinTopic() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(13)
   @Test
-  @Order(10)
+  @Order(11)
   void checkFilterSavingWithinSavedFilters() {
-    String displayName = randomAlphanumeric(5);
+    String displayName = randomAlphabetic(5);
     naviSideBar
         .openSideMenu(TOPICS);
     topicsList
@@ -369,7 +405,7 @@ void checkFilterSavingWithinSavedFilters() {
   @AutomationStatus(status = Status.AUTOMATED)
   @CaseId(11)
   @Test
-  @Order(11)
+  @Order(12)
   void checkShowInternalTopicsButtonFunctionality(){
     naviSideBar
         .openSideMenu(TOPICS);