Bläddra i källkod

Checks/fix e2e tests (#987)

* #626 fix delete topic test

* #626 increase waiting time for topic update

* #626 increase the waiting time for the topic update to 5 minutes

* #626 delete refreshing pages for update topic test
Anna Antipova 3 år sedan
förälder
incheckning
8a36af12b1

+ 1 - 1
kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/extensions/WaitUtils.java

@@ -25,7 +25,7 @@ public class WaitUtils {
             refresh();
             i++;
             sleep(2000);
-        } while (!selectedValue.equals(element.getSelectedValue()) && i != 40);
+        } while (!selectedValue.equals(element.getSelectedValue()) && i != 60);
         Assertions.assertEquals(selectedValue, element.getSelectedValue()) ;
     }
 }

+ 7 - 1
kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/helpers/ApiHelper.java

@@ -4,6 +4,7 @@ import com.provectus.kafka.ui.api.ApiClient;
 import com.provectus.kafka.ui.api.api.TopicsApi;
 import com.provectus.kafka.ui.api.model.TopicCreation;
 import lombok.SneakyThrows;
+import org.springframework.web.reactive.function.client.WebClientResponseException;
 
 public class ApiHelper {
     int partitions = 1;
@@ -35,7 +36,12 @@ public class ApiHelper {
 
     @SneakyThrows
     public void deleteTopic(String clusterName, String topicName) {
-        topicApi().deleteTopic(clusterName,topicName).block();
+        try {
+            topicApi().deleteTopic(clusterName, topicName).block();
+        } catch (WebClientResponseException ex) {
+            if (ex.getRawStatusCode() != 404)  // except already deleted
+                throw ex;
+        }
     }
 
 }

+ 11 - 1
kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/pages/TopicView.java

@@ -1,5 +1,6 @@
 package com.provectus.kafka.ui.pages;
 
+import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.Selenide;
 import com.codeborne.selenide.SelenideElement;
 import com.provectus.kafka.ui.base.TestConfiguration;
@@ -25,6 +26,14 @@ public class TopicView {
         Selenide.open(TestConfiguration.BASE_URL+path.formatted(cluster,topic));
         return this;
     }
+
+    @Step
+    public TopicsList isOnTopicListPage() {
+        $(By.xpath("//*[contains(text(),'Loading')]")).shouldBe(Condition.disappear);
+        $(By.xpath("//span[text()='All Topics']")).shouldBe(Condition.visible);
+        return new TopicsList();
+    }
+
     @SneakyThrows
     public TopicView openEditSettings() {
         $(By.xpath("//a[@class=\"button\" and text()='Edit settings']")).click();
@@ -32,9 +41,10 @@ public class TopicView {
     }
 
     @SneakyThrows
-    public void  clickDeleteTopicButton() {
+    public TopicView clickDeleteTopicButton() {
         $(By.xpath("//*[text()='Delete Topic']")).click();
         $(By.xpath("//*[text()='Confirm']")).click();
+        return this;
     }
 
     @SneakyThrows

+ 4 - 8
kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/topics/TopicTests.java

@@ -57,7 +57,6 @@ public class TopicTests extends BaseTest {
         pages.openTopicsList(SECOND_LOCAL)
                 .isOnPage()
                 .openTopic(TOPIC_TO_UPDATE);
-        Selenide.refresh();
         pages.openTopicView(SECOND_LOCAL, TOPIC_TO_UPDATE)
                 .openEditSettings()
                 .changeCleanupPolicy(COMPACT_POLICY_VALUE)
@@ -65,7 +64,6 @@ public class TopicTests extends BaseTest {
                 .changeMaxSizeOnDisk(UPDATED_MAX_SIZE_ON_DISK)
                 .changeMaxMessageBytes(UPDATED_MAX_MESSAGE_BYTES)
                 .submitSettingChanges();
-        Selenide.refresh();
         pages.openTopicView(SECOND_LOCAL, TOPIC_TO_UPDATE)
                 .openEditSettings()
         // Assertions
@@ -78,15 +76,13 @@ public class TopicTests extends BaseTest {
     @SneakyThrows
     @DisplayName("should delete topic")
     @Test
-    @Disabled
     void deleteTopic() {
-
         pages.openTopicsList(SECOND_LOCAL)
                 .isOnPage()
                 .openTopic(TOPIC_TO_DELETE);
-        pages.openTopicView(SECOND_LOCAL, TOPIC_TO_DELETE).clickDeleteTopicButton();
-        pages.openTopicsList(SECOND_LOCAL).isNotVisible(TOPIC_TO_DELETE);
-        
+        pages.openTopicView(SECOND_LOCAL, TOPIC_TO_DELETE)
+                .clickDeleteTopicButton()
+                .isOnTopicListPage()
+                .isNotVisible(TOPIC_TO_DELETE);
     }
-
 }