소스 검색

626: wait for cleanup policy to update

Anna Antipova 4 년 전
부모
커밋
e57b4304d3

+ 16 - 5
kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/helpers/Utils.java

@@ -1,20 +1,31 @@
 package com.provectus.kafka.ui.helpers;
 
 import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.SelenideElement;
+import org.junit.jupiter.api.Assertions;
 import org.openqa.selenium.By;
 
 import static com.codeborne.selenide.Selenide.*;
 import static com.codeborne.selenide.Selenide.$;
 
 public class Utils {
-    public static void refreshUntil(By by){
-        int i =0;
-        do
-        {
+    public static void refreshUntil(By by) {
+        int i = 0;
+        do {
             refresh();
             i++;
             sleep(2000);
-        } while(getElements(by).size()<1 && i!=20);
+        } while (getElements(by).size() < 1 && i != 20);
         $(by).shouldBe(Condition.visible);
     }
+
+    public static void waitForSelectedValue(SelenideElement element, String selectedValue) {
+        int i = 0;
+        do {
+            refresh();
+            i++;
+            sleep(2000);
+        } while (!selectedValue.equals(element.getSelectedValue()) && i != 10);
+        Assertions.assertEquals(element.getSelectedValue(), selectedValue);
+    }
 }

+ 11 - 5
kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/topics/TopicTests.java

@@ -9,11 +9,14 @@ import org.junit.jupiter.api.*;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 
+import static com.provectus.kafka.ui.helpers.Utils.waitForSelectedValue;
+
 
 public class TopicTests extends BaseTest {
 
-    public static final String UPDATE_TOPIC = "update-topic";
     public static final String NEW_TOPIC = "new-topic";
+    public static final String UPDATE_TOPIC = "update-topic";
+    public static final String DELETE_TOPIC = "delete-topic";
     public static final String SECOND_LOCAL = "secondLocal";
     public static final String COMPACT_POLICY_VALUE = "compact";
     public static final String UPDATED_TIME_TO_RETAIN_VALUE = "604800001";
@@ -24,12 +27,14 @@ public class TopicTests extends BaseTest {
     @SneakyThrows
     public static void beforeAll() {
         Helpers.INSTANCE.apiHelper.createTopic(SECOND_LOCAL, UPDATE_TOPIC);
+        Helpers.INSTANCE.apiHelper.createTopic(SECOND_LOCAL, DELETE_TOPIC);
     }
 
     @AfterAll
     @SneakyThrows
     public static void afterAll() {
         Helpers.INSTANCE.apiHelper.deleteTopic(SECOND_LOCAL, UPDATE_TOPIC);
+        Helpers.INSTANCE.apiHelper.deleteTopic(SECOND_LOCAL, DELETE_TOPIC);
     }
 
     @SneakyThrows
@@ -67,7 +72,8 @@ public class TopicTests extends BaseTest {
         TopicViewPage topicViewPage = pages.openTopicViewPage(path)
                 .openEditSettings();
 
-        Assertions.assertEquals(COMPACT_POLICY_VALUE,topicViewPage.cleanupPolicy.getSelectedValue());
+        waitForSelectedValue(topicViewPage.cleanupPolicy, COMPACT_POLICY_VALUE);
+
         Assertions.assertEquals(UPDATED_TIME_TO_RETAIN_VALUE,topicViewPage.timeToRetain.getValue());
         Assertions.assertEquals(UPDATED_MAX_SIZE_ON_DISK,topicViewPage.maxSizeOnDisk.getSelectedText());
         Assertions.assertEquals(UPDATED_MAX_MESSAGE_BYTES,topicViewPage.maxMessageBytes.getValue());
@@ -78,13 +84,13 @@ public class TopicTests extends BaseTest {
     @Test
     @Disabled
     void deleteTopic(){
-        final String path = "ui/clusters/" + SECOND_LOCAL + "/topics/" + UPDATE_TOPIC;
+        final String path = "ui/clusters/" + SECOND_LOCAL + "/topics/" + DELETE_TOPIC;
 
         pages.openTopicsListPage()
                 .shouldBeOnPage()
-                .openTopic(UPDATE_TOPIC);
+                .openTopic(DELETE_TOPIC);
         pages.openTopicViewPage(path).clickDeleteTopicButton();
-        pages.openTopicsListPage().shouldBeDeleted(UPDATE_TOPIC);
+        pages.openTopicsListPage().shouldBeDeleted(DELETE_TOPIC);
     }
 
 }