Repository: provectus/kafka-ui
Issue: [e2e]SchemasTests.updateSchemaAvro : Update schema avro ( REFACTORED WITH NEW ASSERTIONS)
Labels: scope/QA
scope/AQA

Auto test implementation for:

https://app.qase.io/case/KAFKAUI-186

Description:
The purpose of this case is to make sure that possible to edit the Schemas

Pre-conditions:

- Login to Kafka-ui

- Navigate to Schema Registry

- Create a schema

- Open the Schema

Steps:

- [ ] 1. Press "Edit Schema" button
Expected result
Following content should be displayed:

- Disabled Type field
- Compatibility level
- Latest Schema
- New schema
- Disabled "Submit" button

- [x] 2. Make change within schema body
 Expected result
 the "Submit" button should become active
 
- [x] 3. Press "Compatibility level" dropdown field
 Input data
 Change any value
 Expected result
 The available values should be listed
 
- [x] 4. Select any value for "Compatibility level"
 Input data
 "NONE"

- [x] 5. Click on "Submit" button
 Expected result
 The Schema profile should open
 
- [x] 6. Press "Edit Schema" button
 Expected result
 All changes should be saved

Issue comments:

Pull request review comments:
remove System.out.println pls
use custom line breaks pls in cases where line is too long
can we use Condition.enabled here instead of handling attributes?
Done
Done
Refactored

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaCreateForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaCreateForm.java
index 7d0d5c58a93..d749b5feb8b 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaCreateForm.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaCreateForm.java
@@ -11,6 +11,8 @@
 import com.provectus.kafka.ui.pages.BasePage;
 import io.qameta.allure.Step;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 public class SchemaCreateForm extends BasePage {
 
@@ -21,6 +23,7 @@ public class SchemaCreateForm extends BasePage {
     protected SelenideElement schemaTypeDdl = $x("//ul[@name='schemaType']");
     protected SelenideElement compatibilityLevelList = $x("//ul[@name='compatibilityLevel']");
     protected SelenideElement newSchemaTextArea = $x("//div[@id='newSchema']");
+    protected SelenideElement latestSchemaTextArea = $x("//div[@id='latestSchema']");
     protected SelenideElement schemaVersionDdl = $$x("//ul[@role='listbox']/li[text()='Version 2']").first();
     protected List<SelenideElement> visibleMarkers = $$x("//div[@class='ace_scroller']//div[contains(@class,'codeMarker')]");
     protected List<SelenideElement> elementsCompareVersionDdl = $$x("//ul[@role='listbox']/ul/li");
@@ -96,14 +99,25 @@ public SchemaCreateForm setNewSchemaValue(String configJson) {
     }
 
     @Step
-    public boolean isSchemaDropDownDisabled(){
-        boolean disabled = false;
+    public List<SelenideElement> getAllDetailsPageElements() {
+      return Stream.of(compatibilityLevelList, newSchemaTextArea, latestSchemaTextArea, submitBtn, schemaTypeDdl)
+          .collect(Collectors.toList());
+    }
+
+    @Step
+    public boolean isSubmitBtnEnabled(){
+      return isEnabled(submitBtn);
+    }
+
+    @Step
+    public boolean isSchemaDropDownEnabled(){
+        boolean enabled = true;
         try{
             String attribute = schemaTypeDdl.getAttribute("disabled");
-            disabled = true;
+            enabled = false;
         }
         catch (Throwable ignored){
         }
-        return disabled;
+        return enabled;
     }
 }


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/schemas/SchemasTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/schemas/SchemasTests.java
index 398130bcd19..f112c7b5881 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/schemas/SchemasTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/schemas/SchemasTests.java
@@ -4,6 +4,7 @@
 import static com.provectus.kafka.ui.settings.Source.CLUSTER_NAME;
 import static com.provectus.kafka.ui.utilities.FileUtils.fileToString;
 
+import com.codeborne.selenide.Condition;
 import com.provectus.kafka.ui.api.model.CompatibilityLevel;
 import com.provectus.kafka.ui.base.BaseTest;
 import com.provectus.kafka.ui.models.Schema;
@@ -93,7 +94,13 @@ void updateSchemaAvro() {
                 .openEditSchema();
         schemaCreateForm
                 .waitUntilScreenReady();
-        Assertions.assertTrue(schemaCreateForm.isSchemaDropDownDisabled(),"isSchemaDropDownDisabled()");
+        SoftAssertions softly = new SoftAssertions();
+        schemaCreateForm.getAllDetailsPageElements()
+            .forEach(element -> softly.assertThat(element.is(Condition.visible))
+                .as(element.getSearchCriteria() + " isVisible").isTrue());
+        softly.assertThat(schemaCreateForm.isSubmitBtnEnabled()).as("isSubmitBtnEnabled()").isFalse();
+        softly.assertThat(schemaCreateForm.isSchemaDropDownEnabled()).as("isSchemaDropDownEnabled()").isFalse();
+        softly.assertAll();
         schemaCreateForm
                 .selectCompatibilityLevelFromDropdown(CompatibilityLevel.CompatibilityEnum.NONE)
                 .setNewSchemaValue(fileToString(AVRO_API.getValuePath()))