626: wait for cleanup policy to update

This commit is contained in:
Anna Antipova 2021-07-20 19:45:34 +03:00
parent d47c7b1649
commit e57b4304d3
2 changed files with 27 additions and 10 deletions

View file

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

View file

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