Repository: provectus/kafka-ui
Issue: [e2e] Get rid of asserts in helper classes
Labels: type/enhancement
scope/QA
status/accepted


Issue comments:
@Haarolean as we agreed, all those methods containing just 'SelenideElement.shouldBe(Condition)' are needed
but to avoid such confuses methods should be renamed to 'waitUntilScreenRedy()' because the main goal is waiting for element's state and not assertion
@anezboretskiy please find all those methods and fix naming

Pull request review comments:
need to fix step description: 'Wait until page opened'
@anezboretskiy better just delete description from annotation
@VladSenyuta description deleted 

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/MainPage.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/MainPage.java
index 7e2a6640a82..797d0277b9d 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/MainPage.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/MainPage.java
@@ -26,7 +26,7 @@ public MainPage goTo() {
     }
 
     @Step
-    public MainPage isOnPage() {
+    public MainPage waitUntilScreenReady() {
         $(By.xpath("//*[contains(text(),'Loading')]")).shouldBe(Condition.disappear);
         $("input[name=switchRoundedDefault]").parent().$("span").shouldBe(Condition.visible);
         return this;
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorCreateView.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorCreateView.java
index e87dcfe342f..69f67a9a4af 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorCreateView.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorCreateView.java
@@ -34,8 +34,8 @@ public ConnectorsView setConnectorConfig(String connectName, String configJson)
         return new ConnectorsView();
     }
 
-    @Step("Verify that page 'Create Connector' opened")
-    public ConnectorCreateView isOnConnectorCreatePage() {
+    @Step
+    public ConnectorCreateView waitUntilScreenReady() {
         nameField.shouldBe(Condition.visible);
         return this;
     }
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorsList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorsList.java
index 13c2ce2b70f..ed4b045caef 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorsList.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorsList.java
@@ -24,7 +24,7 @@ public ConnectorsList goTo(String cluster) {
     }
 
     @Step
-    public ConnectorsList isOnPage() {
+    public ConnectorsList waitUntilScreenReady() {
         $(By.xpath("//h1[text()='Connectors']")).shouldBe(Condition.visible);
         return this;
     }
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaView.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaView.java
index cce7ecefc4c..a2b715f4f18 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaView.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaView.java
@@ -12,7 +12,7 @@
 public class SchemaView {
 
     @Step
-    public SchemaView isOnSchemaViewPage() {
+    public SchemaView waitUntilScreenReady() {
         $("div#schema").shouldBe(Condition.visible);
         return this;
     }
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicView.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicView.java
index a71d49e0f51..9e667df7197 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicView.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicView.java
@@ -29,7 +29,7 @@ public TopicView goTo(String cluster, String topic) {
     }
 
     @Step
-    public TopicView isOnTopicViewPage() {
+    public TopicView waitUntilScreenReady() {
         $(By.linkText("Overview")).shouldBe(Condition.visible);
         return this;
     }
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
index 5b816d05f5c..ccdf4b7a110 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
@@ -25,7 +25,7 @@ public TopicsList goTo(String cluster) {
     }
 
     @Step
-    public TopicsList isOnPage() {
+    public TopicsList waitUntilScreenReady() {
         $(By.xpath("//*[contains(text(),'Loading')]")).shouldBe(Condition.disappear);
         $(By.xpath("//h1[text()='All Topics']")).shouldBe(Condition.visible);
         return this;


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/SmokeTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/SmokeTests.java
index e52d9dc1d87..149acf4aa56 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/SmokeTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/SmokeTests.java
@@ -16,7 +16,7 @@ public class SmokeTests extends BaseTest {
     @DisplayName("main page should load")
     void mainPageLoads() {
         pages.open()
-                .isOnPage();
+                .waitUntilScreenReady();
         compareScreenshots("main");
     }
 
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/ConnectorsTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/ConnectorsTests.java
index 57002ee5b6b..fe0e468e45f 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/ConnectorsTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/ConnectorsTests.java
@@ -70,14 +70,14 @@ public static void afterAll() {
     @Test
     public void createConnector() {
         pages.openConnectorsList(LOCAL_CLUSTER)
-                .isOnPage()
+                .waitUntilScreenReady()
                 .clickCreateConnectorButton()
-                .isOnConnectorCreatePage()
+                .waitUntilScreenReady()
                 .setConnectorConfig(
                         SINK_CONNECTOR,
                         FileUtils.getResourceAsString("config_for_create_connector.json"));
         pages.openConnectorsList(LOCAL_CLUSTER)
-                .isOnPage()
+                .waitUntilScreenReady()
                 .connectorIsVisibleInList(SINK_CONNECTOR, TOPIC_FOR_CONNECTOR);
     }
 
@@ -89,7 +89,7 @@ public void createConnector() {
     @Test
     public void updateConnector() {
         pages.openConnectorsList(LOCAL_CLUSTER)
-                .isOnPage()
+                .waitUntilScreenReady()
                 .openConnector(CONNECTOR_FOR_UPDATE);
         pages.connectorsView.connectorIsVisibleOnOverview();
         pages.connectorsView.openEditConfig()
@@ -106,7 +106,7 @@ public void updateConnector() {
     @Test
     public void deleteConnector() {
         pages.openConnectorsList(LOCAL_CLUSTER)
-                .isOnPage()
+                .waitUntilScreenReady()
                 .openConnector(CONNECTOR_FOR_DELETE);
         pages.connectorsView.clickDeleteButton();
         pages.openConnectorsList(LOCAL_CLUSTER)
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/SchemasTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/SchemasTests.java
index d7f1bf9c0c6..af14f108198 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/SchemasTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/SchemasTests.java
@@ -71,7 +71,7 @@ void createSchemaAvro() throws IOException {
                 .setSchemaField(readFileAsString(PATH_AVRO_VALUE))
                 .selectSchemaTypeFromDropdown(SchemaCreateView.SchemaType.AVRO)
                 .clickSubmit()
-                .isOnSchemaViewPage();
+                .waitUntilScreenReady();
         pages.mainPage
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.isSchemaVisible(SCHEMA_AVRO_CREATE);
@@ -88,12 +88,12 @@ void updateSchemaAvro() {
         pages.openMainPage()
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.openSchema(SCHEMA_AVRO_API_UPDATE)
-                .isOnSchemaViewPage()
+                .waitUntilScreenReady()
                 .openEditSchema()
                 .selectCompatibilityLevelFromDropdown(CompatibilityLevel.CompatibilityEnum.NONE)
                 .setNewSchemaValue(readFileAsString(PATH_AVRO_FOR_UPDATE))
                 .clickSubmit()
-                .isOnSchemaViewPage()
+                .waitUntilScreenReady()
                 .isCompatibility(CompatibilityLevel.CompatibilityEnum.NONE);
     }
 
@@ -108,7 +108,7 @@ void deleteSchemaAvro() {
         pages.openMainPage()
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.openSchema(SCHEMA_AVRO_API)
-                .isOnSchemaViewPage()
+                .waitUntilScreenReady()
                 .removeSchema()
                 .isNotVisible(SCHEMA_AVRO_API);
     }
@@ -128,7 +128,7 @@ void createSchemaJson() {
                 .setSchemaField(readFileAsString(PATH_JSON_VALUE))
                 .selectSchemaTypeFromDropdown(SchemaCreateView.SchemaType.JSON)
                 .clickSubmit()
-                .isOnSchemaViewPage();
+                .waitUntilScreenReady();
         pages.mainPage
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.isSchemaVisible(SCHEMA_JSON_CREATE);
@@ -145,7 +145,7 @@ void deleteSchemaJson() {
         pages.openMainPage()
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.openSchema(SCHEMA_JSON_API)
-                .isOnSchemaViewPage()
+                .waitUntilScreenReady()
                 .removeSchema()
                 .isNotVisible(SCHEMA_JSON_API);
     }
@@ -165,7 +165,7 @@ void createSchemaProtobuf() {
                 .setSchemaField(readFileAsString(PATH_PROTOBUF_VALUE))
                 .selectSchemaTypeFromDropdown(SchemaCreateView.SchemaType.PROTOBUF)
                 .clickSubmit()
-                .isOnSchemaViewPage();
+                .waitUntilScreenReady();
         pages.mainPage
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.isSchemaVisible(SCHEMA_PROTOBUF_CREATE);
@@ -182,7 +182,7 @@ void deleteSchemaProtobuf() {
         pages.openMainPage()
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.openSchema(SCHEMA_PROTOBUF_API)
-                .isOnSchemaViewPage()
+                .waitUntilScreenReady()
                 .removeSchema()
                 .isNotVisible(SCHEMA_PROTOBUF_API);
     }
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
index 75e5cfa7224..0d6026e1edb 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
@@ -55,7 +55,7 @@ public void createTopic() {
         pages.topicsList.pressCreateNewTopic()
                 .setTopicName(NEW_TOPIC)
                 .sendData()
-                .isOnTopicViewPage();
+                .waitUntilScreenReady();
         pages.open()
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.TOPICS)
                 .topicIsVisible(NEW_TOPIC);
@@ -74,9 +74,9 @@ public void createTopic() {
     @Test
     public void updateTopic() {
         pages.openTopicsList(SECOND_LOCAL)
-                .isOnPage();
+                .waitUntilScreenReady();
         pages.openTopicView(SECOND_LOCAL, TOPIC_TO_UPDATE)
-                .isOnTopicViewPage()
+                .waitUntilScreenReady()
                 .openEditSettings()
                 .selectCleanupPolicy(COMPACT_POLICY_VALUE)
                 .setMinInsyncReplicas(10)
@@ -84,10 +84,10 @@ public void updateTopic() {
                 .setMaxSizeOnDiskInGB(UPDATED_MAX_SIZE_ON_DISK)
                 .setMaxMessageBytes(UPDATED_MAX_MESSAGE_BYTES)
                 .sendData()
-                .isOnTopicViewPage();
+                .waitUntilScreenReady();
 
         pages.openTopicsList(SECOND_LOCAL)
-                .isOnPage();
+                .waitUntilScreenReady();
         pages.openTopicView(SECOND_LOCAL, TOPIC_TO_UPDATE)
                 .openEditSettings()
                 // Assertions
@@ -105,11 +105,11 @@ public void updateTopic() {
     @Test
     public void deleteTopic() {
         pages.openTopicsList(SECOND_LOCAL)
-                .isOnPage()
+                .waitUntilScreenReady()
                 .openTopic(TOPIC_TO_DELETE)
-                .isOnTopicViewPage()
+                .waitUntilScreenReady()
                 .deleteTopic()
-                .isOnPage()
+                .waitUntilScreenReady()
                 .isTopicNotVisible(TOPIC_TO_DELETE);
     }
 
@@ -121,9 +121,9 @@ public void deleteTopic() {
     @Test
     void produceMessage() {
         pages.openTopicsList(SECOND_LOCAL)
-                .isOnPage()
+                .waitUntilScreenReady()
                 .openTopic(TOPIC_TO_UPDATE)
-                .isOnTopicViewPage()
+                .waitUntilScreenReady()
                 .openTopicMenu(TopicView.TopicMenu.MESSAGES)
                 .clickOnButton("Produce Message")
                 .setContentFiled(readFileAsString(CONTENT_TO_PRODUCE_MESSAGE))