From a2741291bfd5bff2283e9361adebf30b2db56cca Mon Sep 17 00:00:00 2001 From: Vlad Senyuta <66071557+VladSenyuta@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:22:57 +0300 Subject: [PATCH] [e2e] Clearing messages availability with Topic's cleanup policy update (#3632) * add verifyClearMessagesMenuStateAfterTopicUpdate * fix indents * upd imports * Add checkstyle plugin execution for e2e * upd violations * upd violations * Impl a separate checkstyle config for e2e --------- Co-authored-by: Roman Zabaluev --- etc/checkstyle/checkstyle-e2e.xml | 333 +++++++ etc/checkstyle/checkstyle.xml | 4 +- kafka-ui-e2e-checks/pom.xml | 31 + .../provectus/kafka/ui/models/Connector.java | 2 +- .../com/provectus/kafka/ui/models/Schema.java | 39 +- .../com/provectus/kafka/ui/models/Topic.java | 12 +- .../provectus/kafka/ui/pages/BasePage.java | 253 +++--- .../ui/pages/brokers/BrokersConfigTab.java | 55 +- .../ui/pages/brokers/BrokersDetails.java | 147 ++-- .../kafka/ui/pages/brokers/BrokersList.java | 177 ++-- .../pages/connectors/ConnectorCreateForm.java | 78 +- .../ui/pages/connectors/ConnectorDetails.java | 128 +-- .../ui/pages/connectors/KafkaConnectList.java | 66 +- .../ui/pages/consumers/ConsumersDetails.java | 38 +- .../ui/pages/consumers/ConsumersList.java | 16 +- .../kafka/ui/pages/ksqlDb/KsqlDbList.java | 139 --- .../kafka/ui/pages/ksqlDb/KsqlQueryForm.java | 154 ---- .../ui/pages/ksqlDb/enums/KsqlMenuTabs.java | 17 - .../pages/ksqlDb/enums/KsqlQueryConfig.java | 19 - .../kafka/ui/pages/ksqldb/KsqlDbList.java | 138 +++ .../kafka/ui/pages/ksqldb/KsqlQueryForm.java | 153 ++++ .../ui/pages/ksqldb/enums/KsqlMenuTabs.java | 17 + .../pages/ksqldb/enums/KsqlQueryConfig.java | 18 + .../{ksqlDb => ksqldb}/models/Stream.java | 4 +- .../{ksqlDb => ksqldb}/models/Table.java | 4 +- .../kafka/ui/pages/panels/NaviSideBar.java | 93 +- .../kafka/ui/pages/panels/TopPanel.java | 27 +- .../kafka/ui/pages/panels/enums/MenuItem.java | 48 +- .../ui/pages/schemas/SchemaCreateForm.java | 246 +++--- .../kafka/ui/pages/schemas/SchemaDetails.java | 102 +-- .../ui/pages/schemas/SchemaRegistryList.java | 60 +- .../ui/pages/topics/ProduceMessagePanel.java | 91 +- .../ui/pages/topics/TopicCreateEditForm.java | 530 ++++++------ .../kafka/ui/pages/topics/TopicDetails.java | 813 +++++++++--------- .../ui/pages/topics/TopicSettingsTab.java | 83 +- .../kafka/ui/pages/topics/TopicsList.java | 463 +++++----- .../topics/enums/CleanupPolicyValue.java | 30 +- .../topics/enums/CustomParameterType.java | 58 +- .../ui/pages/topics/enums/MaxSizeOnDisk.java | 34 +- .../ui/pages/topics/enums/TimeToRetain.java | 34 +- .../kafka/ui/services/ApiService.java | 454 +++++----- .../kafka/ui/settings/BaseSource.java | 38 +- .../kafka/ui/settings/configs/Profiles.java | 16 +- .../kafka/ui/settings/drivers/WebDriver.java | 149 ++-- .../ui/settings/listeners/AllureListener.java | 46 +- .../ui/settings/listeners/LoggerListener.java | 48 +- .../listeners/QaseCreateListener.java | 197 +++-- .../listeners/QaseResultListener.java | 145 ++-- .../kafka/ui/utilities/FileUtils.java | 29 +- .../kafka/ui/utilities/TimeUtils.java | 15 +- .../kafka/ui/utilities/WebUtils.java | 161 ++-- .../kafka/ui/utilities/qase/QaseSetup.java | 33 + .../annotations/Automation.java | 7 +- .../annotations/Status.java | 4 +- .../annotations/Suite.java | 4 +- .../kafka/ui/utilities/qase/enums/State.java | 18 + .../kafka/ui/utilities/qase/enums/Status.java | 18 + .../ui/utilities/qaseUtils/QaseSetup.java | 34 - .../ui/utilities/qaseUtils/enums/State.java | 18 - .../ui/utilities/qaseUtils/enums/Status.java | 18 - .../provectus/kafka/ui/variables/Browser.java | 4 +- .../provectus/kafka/ui/variables/Suite.java | 10 +- .../com/provectus/kafka/ui/variables/Url.java | 12 +- .../config_for_create_connector.json | 2 +- .../config_for_create_connector_via_api.json | 2 +- .../connectors/delete_connector_config.json | 2 +- .../schemas/schema_avro_for_update.json | 2 +- .../testData/schemas/schema_avro_value.json | 2 +- .../testData/schemas/schema_json_Value.json | 2 +- .../topics/message_content_create_topic.json | 2 +- .../java/com/provectus/kafka/ui/BaseTest.java | 261 +++--- .../java/com/provectus/kafka/ui/Facade.java | 56 +- .../kafka/ui/manualSuite/BaseManualTest.java | 30 - .../ui/manualSuite/backlog/SanityBacklog.java | 19 - .../ui/manualSuite/backlog/SmokeBacklog.java | 75 -- .../ui/manualSuite/suite/DataMaskingTest.java | 29 - .../kafka/ui/manualSuite/suite/RbacTest.java | 53 -- .../ui/manualSuite/suite/TopicsTest.java | 95 -- .../ui/manualSuite/suite/WizardTest.java | 17 - .../kafka/ui/manualsuite/BaseManualTest.java | 30 + .../ui/manualsuite/backlog/SanityBacklog.java | 7 + .../ui/manualsuite/backlog/SmokeBacklog.java | 78 ++ .../ui/manualsuite/suite/DataMaskingTest.java | 29 + .../kafka/ui/manualsuite/suite/RbacTest.java | 53 ++ .../ui/manualsuite/suite/TopicsTest.java | 95 ++ .../ui/manualsuite/suite/WizardTest.java | 17 + .../kafka/ui/qaseSuite/BaseQaseTest.java | 23 - .../kafka/ui/qaseSuite/Template.java | 58 -- .../kafka/ui/qasesuite/BaseQaseTest.java | 25 + .../kafka/ui/qasesuite/Template.java | 58 ++ .../kafka/ui/sanitySuite/TestClass.java | 4 - .../kafka/ui/sanitysuite/TopicsTest.java | 66 ++ .../kafka/ui/smokeSuite/SmokeTest.java | 107 --- .../ui/smokeSuite/brokers/BrokersTest.java | 41 - .../smokeSuite/connectors/ConnectorsTest.java | 106 --- .../ui/smokeSuite/ksqlDb/KsqlDbTest.java | 80 -- .../ui/smokeSuite/schemas/SchemasTest.java | 190 ---- .../ui/smokeSuite/topics/MessagesTest.java | 283 ------ .../ui/smokeSuite/topics/TopicsTest.java | 496 ----------- .../kafka/ui/smokesuite/SmokeTest.java | 115 +++ .../ui/smokesuite/brokers/BrokersTest.java | 41 + .../smokesuite/connectors/ConnectorsTest.java | 107 +++ .../ui/smokesuite/ksqldb/KsqlDbTest.java | 79 ++ .../ui/smokesuite/schemas/SchemasTest.java | 190 ++++ .../ui/smokesuite/topics/MessagesTest.java | 279 ++++++ .../ui/smokesuite/topics/TopicsTest.java | 500 +++++++++++ .../src/test/resources/manual.xml | 2 +- .../src/test/resources/qase.xml | 2 +- .../src/test/resources/regression.xml | 6 +- .../src/test/resources/sanity.xml | 2 +- .../src/test/resources/smoke.xml | 2 +- 111 files changed, 5273 insertions(+), 4779 deletions(-) create mode 100644 etc/checkstyle/checkstyle-e2e.xml delete mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlDbList.java delete mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlQueryForm.java delete mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/enums/KsqlMenuTabs.java delete mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/enums/KsqlQueryConfig.java create mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlDbList.java create mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlQueryForm.java create mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/enums/KsqlMenuTabs.java create mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/enums/KsqlQueryConfig.java rename kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/{ksqlDb => ksqldb}/models/Stream.java (50%) rename kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/{ksqlDb => ksqldb}/models/Table.java (56%) create mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/QaseSetup.java rename kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/{qaseUtils => qase}/annotations/Automation.java (63%) rename kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/{qaseUtils => qase}/annotations/Status.java (65%) rename kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/{qaseUtils => qase}/annotations/Suite.java (76%) create mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/enums/State.java create mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/enums/Status.java delete mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/QaseSetup.java delete mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/enums/State.java delete mode 100644 kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/enums/Status.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/BaseManualTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/backlog/SanityBacklog.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/backlog/SmokeBacklog.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/DataMaskingTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/RbacTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/TopicsTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/WizardTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/BaseManualTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SanityBacklog.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SmokeBacklog.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/DataMaskingTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/RbacTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/TopicsTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/WizardTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/BaseQaseTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/Template.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qasesuite/BaseQaseTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qasesuite/Template.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/sanitySuite/TestClass.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/sanitysuite/TopicsTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/SmokeTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/brokers/BrokersTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/connectors/ConnectorsTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/ksqlDb/KsqlDbTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/schemas/SchemasTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/topics/MessagesTest.java delete mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/topics/TopicsTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/SmokeTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/brokers/BrokersTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/connectors/ConnectorsTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/ksqldb/KsqlDbTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/schemas/SchemasTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/MessagesTest.java create mode 100644 kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/TopicsTest.java diff --git a/etc/checkstyle/checkstyle-e2e.xml b/etc/checkstyle/checkstyle-e2e.xml new file mode 100644 index 000000000..c2af9c987 --- /dev/null +++ b/etc/checkstyle/checkstyle-e2e.xml @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/etc/checkstyle/checkstyle.xml b/etc/checkstyle/checkstyle.xml index 0348f809b..745f1bc36 100644 --- a/etc/checkstyle/checkstyle.xml +++ b/etc/checkstyle/checkstyle.xml @@ -318,7 +318,7 @@ - + @@ -330,4 +330,4 @@ - \ No newline at end of file + diff --git a/kafka-ui-e2e-checks/pom.xml b/kafka-ui-e2e-checks/pom.xml index e4d912dbe..c93f6bcab 100644 --- a/kafka-ui-e2e-checks/pom.xml +++ b/kafka-ui-e2e-checks/pom.xml @@ -264,6 +264,37 @@ allure-maven 2.10.0 + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.2 + + + com.puppycrawl.tools + checkstyle + 10.3.1 + + + + + checkstyle + validate + + check + + + warning + true + true + true + file:${basedir}/../etc/checkstyle/checkstyle-e2e.xml + file:${basedir}/../etc/checkstyle/apache-header.txt + + + + + + diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Connector.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Connector.java index 48088cdf9..493010a3f 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Connector.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Connector.java @@ -7,5 +7,5 @@ @Accessors(chain = true) public class Connector { - private String name, config; + private String name, config; } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Schema.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Schema.java index 19dc44a02..55a6e6311 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Schema.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Schema.java @@ -1,33 +1,34 @@ package com.provectus.kafka.ui.models; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + import com.provectus.kafka.ui.api.model.SchemaType; import lombok.Data; import lombok.experimental.Accessors; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - @Data @Accessors(chain = true) public class Schema { - private String name, valuePath; - private SchemaType type; + private String name, valuePath; + private SchemaType type; - public static Schema createSchemaAvro() { - return new Schema().setName("schema_avro-" + randomAlphabetic(5)) - .setType(SchemaType.AVRO) - .setValuePath(System.getProperty("user.dir") + "/src/main/resources/testData/schemas/schema_avro_value.json"); - } + public static Schema createSchemaAvro() { + return new Schema().setName("schema_avro-" + randomAlphabetic(5)) + .setType(SchemaType.AVRO) + .setValuePath(System.getProperty("user.dir") + "/src/main/resources/testData/schemas/schema_avro_value.json"); + } - public static Schema createSchemaJson() { - return new Schema().setName("schema_json-" + randomAlphabetic(5)) - .setType(SchemaType.JSON) - .setValuePath(System.getProperty("user.dir") + "/src/main/resources/testData/schemas/schema_json_Value.json"); - } + public static Schema createSchemaJson() { + return new Schema().setName("schema_json-" + randomAlphabetic(5)) + .setType(SchemaType.JSON) + .setValuePath(System.getProperty("user.dir") + "/src/main/resources/testData/schemas/schema_json_Value.json"); + } - public static Schema createSchemaProtobuf() { - return new Schema().setName("schema_protobuf-" + randomAlphabetic(5)) - .setType(SchemaType.PROTOBUF) - .setValuePath(System.getProperty("user.dir") + "/src/main/resources/testData/schemas/schema_protobuf_value.txt"); - } + public static Schema createSchemaProtobuf() { + return new Schema().setName("schema_protobuf-" + randomAlphabetic(5)) + .setType(SchemaType.PROTOBUF) + .setValuePath( + System.getProperty("user.dir") + "/src/main/resources/testData/schemas/schema_protobuf_value.txt"); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Topic.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Topic.java index 21486a93f..ece16b4cc 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Topic.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/models/Topic.java @@ -11,10 +11,10 @@ @Accessors(chain = true) public class Topic { - private String name, timeToRetainData, maxMessageBytes, messageKey, messageContent, customParameterValue; - private int numberOfPartitions; - private CustomParameterType customParameterType; - private CleanupPolicyValue cleanupPolicyValue; - private MaxSizeOnDisk maxSizeOnDisk; - private TimeToRetain timeToRetain; + private String name, timeToRetainData, maxMessageBytes, messageKey, messageContent, customParameterValue; + private int numberOfPartitions; + private CustomParameterType customParameterType; + private CleanupPolicyValue cleanupPolicyValue; + private MaxSizeOnDisk maxSizeOnDisk; + private TimeToRetain timeToRetain; } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/BasePage.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/BasePage.java index 2bb4ecce5..fb2e0877e 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/BasePage.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/BasePage.java @@ -1,143 +1,142 @@ package com.provectus.kafka.ui.pages; +import static com.codeborne.selenide.Selenide.$$x; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; import com.codeborne.selenide.WebDriverRunner; import com.provectus.kafka.ui.pages.panels.enums.MenuItem; import com.provectus.kafka.ui.utilities.WebUtils; +import java.time.Duration; import lombok.extern.slf4j.Slf4j; import org.openqa.selenium.Keys; import org.openqa.selenium.interactions.Actions; -import java.time.Duration; - -import static com.codeborne.selenide.Selenide.$$x; -import static com.codeborne.selenide.Selenide.$x; - @Slf4j public abstract class BasePage extends WebUtils { - protected SelenideElement loadingSpinner = $x("//div[@role='progressbar']"); - protected SelenideElement submitBtn = $x("//button[@type='submit']"); - protected SelenideElement tableGrid = $x("//table"); - protected SelenideElement searchFld = $x("//input[@type='text'][contains(@id, ':r')]"); - protected SelenideElement dotMenuBtn = $x("//button[@aria-label='Dropdown Toggle']"); - protected SelenideElement alertHeader = $x("//div[@role='alert']//div[@role='heading']"); - protected SelenideElement alertMessage = $x("//div[@role='alert']//div[@role='contentinfo']"); - protected SelenideElement confirmationMdl = $x("//div[text()= 'Confirm the action']/.."); - protected SelenideElement confirmBtn = $x("//button[contains(text(),'Confirm')]"); - protected SelenideElement cancelBtn = $x("//button[contains(text(),'Cancel')]"); - protected SelenideElement backBtn = $x("//button[contains(text(),'Back')]"); - protected SelenideElement nextBtn = $x("//button[contains(text(),'Next')]"); - protected ElementsCollection ddlOptions = $$x("//li[@value]"); - protected ElementsCollection gridItems = $$x("//tr[@class]"); - protected String summaryCellLocator = "//div[contains(text(),'%s')]"; - protected String tableElementNameLocator = "//tbody//a[contains(text(),'%s')]"; - protected String columnHeaderLocator = "//table//tr/th//div[text()='%s']"; - protected String pageTitleFromHeader = "//h1[text()='%s']"; - protected String pagePathFromHeader = "//a[text()='%s']/../h1"; - - protected void waitUntilSpinnerDisappear(int... timeoutInSeconds) { - log.debug("\nwaitUntilSpinnerDisappear"); - if (isVisible(loadingSpinner, timeoutInSeconds)) { - loadingSpinner.shouldBe(Condition.disappear, Duration.ofSeconds(60)); - } - } - - protected void searchItem(String tag) { - log.debug("\nsearchItem: {}", tag); - sendKeysAfterClear(searchFld, tag); - searchFld.pressEnter().shouldHave(Condition.value(tag)); - waitUntilSpinnerDisappear(1); - } - - protected SelenideElement getPageTitleFromHeader(MenuItem menuItem) { - return $x(String.format(pageTitleFromHeader, menuItem.getPageTitle())); - } - - protected SelenideElement getPagePathFromHeader(MenuItem menuItem) { - return $x(String.format(pagePathFromHeader, menuItem.getPageTitle())); - } - - protected void clickSubmitBtn() { - clickByJavaScript(submitBtn); - } - - protected void setJsonInputValue(SelenideElement jsonInput, String jsonConfig) { - sendKeysByActions(jsonInput, jsonConfig.replace(" ", "")); - new Actions(WebDriverRunner.getWebDriver()) - .keyDown(Keys.SHIFT) - .sendKeys(Keys.PAGE_DOWN) - .keyUp(Keys.SHIFT) - .sendKeys(Keys.DELETE) - .perform(); - } - - protected SelenideElement getTableElement(String elementName) { - log.debug("\ngetTableElement: {}", elementName); - return $x(String.format(tableElementNameLocator, elementName)); - } - - protected ElementsCollection getDdlOptions() { - return ddlOptions; - } - - protected String getAlertHeader() { - log.debug("\ngetAlertHeader"); - String result = alertHeader.shouldBe(Condition.visible).getText(); - log.debug("-> {}", result); - return result; - } - - protected String getAlertMessage() { - log.debug("\ngetAlertMessage"); - String result = alertMessage.shouldBe(Condition.visible).getText(); - log.debug("-> {}", result); - return result; - } - - protected boolean isAlertVisible(AlertHeader header) { - log.debug("\nisAlertVisible: {}", header.toString()); - boolean result = getAlertHeader().equals(header.toString()); - log.debug("-> {}", result); - return result; - } - - protected boolean isAlertVisible(AlertHeader header, String message) { - log.debug("\nisAlertVisible: {} {}", header, message); - boolean result = isAlertVisible(header) && getAlertMessage().equals(message); - log.debug("-> {}", result); - return result; - } - - protected void clickConfirmButton() { - confirmBtn.shouldBe(Condition.enabled).click(); - confirmBtn.shouldBe(Condition.disappear); - } - - protected void clickCancelButton() { - cancelBtn.shouldBe(Condition.enabled).click(); - cancelBtn.shouldBe(Condition.disappear); - } - - protected boolean isConfirmationModalVisible() { - return isVisible(confirmationMdl); - } - - public enum AlertHeader { - SUCCESS("Success"), - VALIDATION_ERROR("Validation Error"), - BAD_REQUEST("400 Bad Request"); - - private final String value; - - AlertHeader(String value) { - this.value = value; - } - - public String toString() { - return value; - } - } + protected SelenideElement loadingSpinner = $x("//div[@role='progressbar']"); + protected SelenideElement submitBtn = $x("//button[@type='submit']"); + protected SelenideElement tableGrid = $x("//table"); + protected SelenideElement searchFld = $x("//input[@type='text'][contains(@id, ':r')]"); + protected SelenideElement dotMenuBtn = $x("//button[@aria-label='Dropdown Toggle']"); + protected SelenideElement alertHeader = $x("//div[@role='alert']//div[@role='heading']"); + protected SelenideElement alertMessage = $x("//div[@role='alert']//div[@role='contentinfo']"); + protected SelenideElement confirmationMdl = $x("//div[text()= 'Confirm the action']/.."); + protected SelenideElement confirmBtn = $x("//button[contains(text(),'Confirm')]"); + protected SelenideElement cancelBtn = $x("//button[contains(text(),'Cancel')]"); + protected SelenideElement backBtn = $x("//button[contains(text(),'Back')]"); + protected SelenideElement nextBtn = $x("//button[contains(text(),'Next')]"); + protected ElementsCollection ddlOptions = $$x("//li[@value]"); + protected ElementsCollection gridItems = $$x("//tr[@class]"); + protected String summaryCellLocator = "//div[contains(text(),'%s')]"; + protected String tableElementNameLocator = "//tbody//a[contains(text(),'%s')]"; + protected String columnHeaderLocator = "//table//tr/th//div[text()='%s']"; + protected String pageTitleFromHeader = "//h1[text()='%s']"; + protected String pagePathFromHeader = "//a[text()='%s']/../h1"; + + protected void waitUntilSpinnerDisappear(int... timeoutInSeconds) { + log.debug("\nwaitUntilSpinnerDisappear"); + if (isVisible(loadingSpinner, timeoutInSeconds)) { + loadingSpinner.shouldBe(Condition.disappear, Duration.ofSeconds(60)); + } + } + + protected void searchItem(String tag) { + log.debug("\nsearchItem: {}", tag); + sendKeysAfterClear(searchFld, tag); + searchFld.pressEnter().shouldHave(Condition.value(tag)); + waitUntilSpinnerDisappear(1); + } + + protected SelenideElement getPageTitleFromHeader(MenuItem menuItem) { + return $x(String.format(pageTitleFromHeader, menuItem.getPageTitle())); + } + + protected SelenideElement getPagePathFromHeader(MenuItem menuItem) { + return $x(String.format(pagePathFromHeader, menuItem.getPageTitle())); + } + + protected void clickSubmitBtn() { + clickByJavaScript(submitBtn); + } + + protected void setJsonInputValue(SelenideElement jsonInput, String jsonConfig) { + sendKeysByActions(jsonInput, jsonConfig.replace(" ", "")); + new Actions(WebDriverRunner.getWebDriver()) + .keyDown(Keys.SHIFT) + .sendKeys(Keys.PAGE_DOWN) + .keyUp(Keys.SHIFT) + .sendKeys(Keys.DELETE) + .perform(); + } + + protected SelenideElement getTableElement(String elementName) { + log.debug("\ngetTableElement: {}", elementName); + return $x(String.format(tableElementNameLocator, elementName)); + } + + protected ElementsCollection getDdlOptions() { + return ddlOptions; + } + + protected String getAlertHeader() { + log.debug("\ngetAlertHeader"); + String result = alertHeader.shouldBe(Condition.visible).getText(); + log.debug("-> {}", result); + return result; + } + + protected String getAlertMessage() { + log.debug("\ngetAlertMessage"); + String result = alertMessage.shouldBe(Condition.visible).getText(); + log.debug("-> {}", result); + return result; + } + + protected boolean isAlertVisible(AlertHeader header) { + log.debug("\nisAlertVisible: {}", header.toString()); + boolean result = getAlertHeader().equals(header.toString()); + log.debug("-> {}", result); + return result; + } + + protected boolean isAlertVisible(AlertHeader header, String message) { + log.debug("\nisAlertVisible: {} {}", header, message); + boolean result = isAlertVisible(header) && getAlertMessage().equals(message); + log.debug("-> {}", result); + return result; + } + + protected void clickConfirmButton() { + confirmBtn.shouldBe(Condition.enabled).click(); + confirmBtn.shouldBe(Condition.disappear); + } + + protected void clickCancelButton() { + cancelBtn.shouldBe(Condition.enabled).click(); + cancelBtn.shouldBe(Condition.disappear); + } + + protected boolean isConfirmationModalVisible() { + return isVisible(confirmationMdl); + } + + public enum AlertHeader { + SUCCESS("Success"), + VALIDATION_ERROR("Validation Error"), + BAD_REQUEST("400 Bad Request"); + + private final String value; + + AlertHeader(String value) { + this.value = value; + } + + public String toString() { + return value; + } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTab.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTab.java index 7b37d6709..f358614dc 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTab.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersConfigTab.java @@ -1,41 +1,40 @@ package com.provectus.kafka.ui.pages.brokers; +import static com.codeborne.selenide.Selenide.$$x; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; 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; -import static com.codeborne.selenide.Selenide.$$x; -import static com.codeborne.selenide.Selenide.$x; - public class BrokersConfigTab extends BasePage { - protected List editBtn = $$x("//button[@aria-label='editAction']"); - protected SelenideElement searchByKeyField = $x("//input[@placeholder='Search by Key']"); - - @Step - public BrokersConfigTab waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - searchByKeyField.shouldBe(Condition.visible); - return this; - } - - @Step - public boolean isSearchByKeyVisible() { - return isVisible(searchByKeyField); - } - - public List getColumnHeaders() { - return Stream.of("Key", "Value", "Source") - .map(name -> $x(String.format(columnHeaderLocator, name))) - .collect(Collectors.toList()); - } - - public List getEditButtons() { - return editBtn; - } + protected List editBtn = $$x("//button[@aria-label='editAction']"); + protected SelenideElement searchByKeyField = $x("//input[@placeholder='Search by Key']"); + + @Step + public BrokersConfigTab waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + searchByKeyField.shouldBe(Condition.visible); + return this; + } + + @Step + public boolean isSearchByKeyVisible() { + return isVisible(searchByKeyField); + } + + public List getColumnHeaders() { + return Stream.of("Key", "Value", "Source") + .map(name -> $x(String.format(columnHeaderLocator, name))) + .collect(Collectors.toList()); + } + + public List getEditButtons() { + return editBtn; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersDetails.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersDetails.java index 8cc3dd98b..4eca65f1f 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersDetails.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersDetails.java @@ -1,92 +1,91 @@ package com.provectus.kafka.ui.pages.brokers; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import org.openqa.selenium.By; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$x; +import org.openqa.selenium.By; public class BrokersDetails extends BasePage { - protected SelenideElement logDirectoriesTab = $x("//a[text()='Log directories']"); - protected SelenideElement metricsTab = $x("//a[text()='Metrics']"); - protected String brokersTabLocator = "//a[text()='%s']"; - - @Step - public BrokersDetails waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - Arrays.asList(logDirectoriesTab, metricsTab).forEach(element -> element.shouldBe(Condition.visible)); - return this; - } - - @Step - public BrokersDetails openDetailsTab(DetailsTab menu) { - $(By.linkText(menu.toString())).shouldBe(Condition.enabled).click(); - waitUntilSpinnerDisappear(); - return this; - } - - private List getVisibleColumnHeaders() { - return Stream.of("Name", "Topics", "Error", "Partitions") - .map(name -> $x(String.format(columnHeaderLocator, name))) - .collect(Collectors.toList()); + protected SelenideElement logDirectoriesTab = $x("//a[text()='Log directories']"); + protected SelenideElement metricsTab = $x("//a[text()='Metrics']"); + protected String brokersTabLocator = "//a[text()='%s']"; + + @Step + public BrokersDetails waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + Arrays.asList(logDirectoriesTab, metricsTab).forEach(element -> element.shouldBe(Condition.visible)); + return this; + } + + @Step + public BrokersDetails openDetailsTab(DetailsTab menu) { + $(By.linkText(menu.toString())).shouldBe(Condition.enabled).click(); + waitUntilSpinnerDisappear(); + return this; + } + + private List getVisibleColumnHeaders() { + return Stream.of("Name", "Topics", "Error", "Partitions") + .map(name -> $x(String.format(columnHeaderLocator, name))) + .collect(Collectors.toList()); + } + + private List getEnabledColumnHeaders() { + return Stream.of("Name", "Error") + .map(name -> $x(String.format(columnHeaderLocator, name))) + .collect(Collectors.toList()); + } + + private List getVisibleSummaryCells() { + return Stream.of("Segment Size", "Segment Count", "Port", "Host") + .map(name -> $x(String.format(summaryCellLocator, name))) + .collect(Collectors.toList()); + } + + private List getDetailsTabs() { + return Stream.of(DetailsTab.values()) + .map(name -> $x(String.format(brokersTabLocator, name))) + .collect(Collectors.toList()); + } + + @Step + public List getAllEnabledElements() { + List enabledElements = new ArrayList<>(getEnabledColumnHeaders()); + enabledElements.addAll(getDetailsTabs()); + return enabledElements; + } + + @Step + public List getAllVisibleElements() { + List visibleElements = new ArrayList<>(getVisibleSummaryCells()); + visibleElements.addAll(getVisibleColumnHeaders()); + visibleElements.addAll(getDetailsTabs()); + return visibleElements; + } + + public enum DetailsTab { + LOG_DIRECTORIES("Log directories"), + CONFIGS("Configs"), + METRICS("Metrics"); + + private final String value; + + DetailsTab(String value) { + this.value = value; } - private List getEnabledColumnHeaders() { - return Stream.of("Name", "Error") - .map(name -> $x(String.format(columnHeaderLocator, name))) - .collect(Collectors.toList()); - } - - private List getVisibleSummaryCells() { - return Stream.of("Segment Size", "Segment Count", "Port", "Host") - .map(name -> $x(String.format(summaryCellLocator, name))) - .collect(Collectors.toList()); - } - - private List getDetailsTabs() { - return Stream.of(DetailsTab.values()) - .map(name -> $x(String.format(brokersTabLocator, name))) - .collect(Collectors.toList()); - } - - @Step - public List getAllEnabledElements() { - List enabledElements = new ArrayList<>(getEnabledColumnHeaders()); - enabledElements.addAll(getDetailsTabs()); - return enabledElements; - } - - @Step - public List getAllVisibleElements() { - List visibleElements = new ArrayList<>(getVisibleSummaryCells()); - visibleElements.addAll(getVisibleColumnHeaders()); - visibleElements.addAll(getDetailsTabs()); - return visibleElements; - } - - public enum DetailsTab { - LOG_DIRECTORIES("Log directories"), - CONFIGS("Configs"), - METRICS("Metrics"); - - private final String value; - - DetailsTab(String value) { - this.value = value; - } - - public String toString() { - return value; - } + public String toString() { + return value; } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersList.java index f1f08c3cf..50ecdff35 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersList.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/brokers/BrokersList.java @@ -1,123 +1,122 @@ package com.provectus.kafka.ui.pages.brokers; +import static com.codeborne.selenide.Selenide.$x; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.BROKERS; + import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.codeborne.selenide.Selenide.$x; -import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.BROKERS; - public class BrokersList extends BasePage { - @Step - public BrokersList waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - getPageTitleFromHeader(BROKERS).shouldBe(Condition.visible); - return this; - } - - @Step - public BrokersList openBroker(int brokerId) { - getBrokerItem(brokerId).openItem(); - return this; - } - - private List getUptimeSummaryCells() { - return Stream.of("Broker Count", "Active Controller", "Version") - .map(name -> $x(String.format(summaryCellLocator, name))) - .collect(Collectors.toList()); + @Step + public BrokersList waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + getPageTitleFromHeader(BROKERS).shouldBe(Condition.visible); + return this; + } + + @Step + public BrokersList openBroker(int brokerId) { + getBrokerItem(brokerId).openItem(); + return this; + } + + private List getUptimeSummaryCells() { + return Stream.of("Broker Count", "Active Controller", "Version") + .map(name -> $x(String.format(summaryCellLocator, name))) + .collect(Collectors.toList()); + } + + private List getPartitionsSummaryCells() { + return Stream.of("Online", "URP", "In Sync Replicas", "Out Of Sync Replicas") + .map(name -> $x(String.format(summaryCellLocator, name))) + .collect(Collectors.toList()); + } + + @Step + public List getAllVisibleElements() { + List visibleElements = new ArrayList<>(getUptimeSummaryCells()); + visibleElements.addAll(getPartitionsSummaryCells()); + return visibleElements; + } + + private List getEnabledColumnHeaders() { + return Stream.of("Broker ID", "Segment Size", "Segment Count", "Port", "Host") + .map(name -> $x(String.format(columnHeaderLocator, name))) + .collect(Collectors.toList()); + } + + @Step + public List getAllEnabledElements() { + return getEnabledColumnHeaders(); + } + + private List initGridItems() { + List gridItemList = new ArrayList<>(); + gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) + .forEach(item -> gridItemList.add(new BrokersList.BrokerGridItem(item))); + return gridItemList; + } + + @Step + public BrokerGridItem getBrokerItem(int id) { + return initGridItems().stream() + .filter(e -> e.getId() == id) + .findFirst().orElseThrow(); + } + + @Step + public List getAllBrokers() { + return initGridItems(); + } + + public static class BrokerGridItem extends BasePage { + + private final SelenideElement element; + + public BrokerGridItem(SelenideElement element) { + this.element = element; } - private List getPartitionsSummaryCells() { - return Stream.of("Online", "URP", "In Sync Replicas", "Out Of Sync Replicas") - .map(name -> $x(String.format(summaryCellLocator, name))) - .collect(Collectors.toList()); + private SelenideElement getIdElm() { + return element.$x("./td[1]/div/a"); } @Step - public List getAllVisibleElements() { - List visibleElements = new ArrayList<>(getUptimeSummaryCells()); - visibleElements.addAll(getPartitionsSummaryCells()); - return visibleElements; - } - - private List getEnabledColumnHeaders() { - return Stream.of("Broker ID", "Segment Size", "Segment Count", "Port", "Host") - .map(name -> $x(String.format(columnHeaderLocator, name))) - .collect(Collectors.toList()); + public int getId() { + return Integer.parseInt(getIdElm().getText().trim()); } @Step - public List getAllEnabledElements() { - return getEnabledColumnHeaders(); + public void openItem() { + getIdElm().click(); } - private List initGridItems() { - List gridItemList = new ArrayList<>(); - gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) - .forEach(item -> gridItemList.add(new BrokersList.BrokerGridItem(item))); - return gridItemList; + @Step + public int getSegmentSize() { + return Integer.parseInt(element.$x("./td[2]").getText().trim()); } @Step - public BrokerGridItem getBrokerItem(int id) { - return initGridItems().stream() - .filter(e -> e.getId() == id) - .findFirst().orElseThrow(); + public int getSegmentCount() { + return Integer.parseInt(element.$x("./td[3]").getText().trim()); } @Step - public List getAllBrokers() { - return initGridItems(); + public int getPort() { + return Integer.parseInt(element.$x("./td[4]").getText().trim()); } - public static class BrokerGridItem extends BasePage { - - private final SelenideElement element; - - public BrokerGridItem(SelenideElement element) { - this.element = element; - } - - private SelenideElement getIdElm() { - return element.$x("./td[1]/div/a"); - } - - @Step - public int getId() { - return Integer.parseInt(getIdElm().getText().trim()); - } - - @Step - public void openItem() { - getIdElm().click(); - } - - @Step - public int getSegmentSize() { - return Integer.parseInt(element.$x("./td[2]").getText().trim()); - } - - @Step - public int getSegmentCount() { - return Integer.parseInt(element.$x("./td[3]").getText().trim()); - } - - @Step - public int getPort() { - return Integer.parseInt(element.$x("./td[4]").getText().trim()); - } - - @Step - public String getHost() { - return element.$x("./td[5]").getText().trim(); - } + @Step + public String getHost() { + return element.$x("./td[5]").getText().trim(); } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/ConnectorCreateForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/ConnectorCreateForm.java index fbbea0f1c..0b6b7b560 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/ConnectorCreateForm.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/ConnectorCreateForm.java @@ -1,49 +1,49 @@ package com.provectus.kafka.ui.pages.connectors; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import static com.codeborne.selenide.Selenide.$x; - public class ConnectorCreateForm extends BasePage { - protected SelenideElement nameField = $x("//input[@name='name']"); - protected SelenideElement contentTextArea = $x("//textarea[@class='ace_text-input']"); - protected SelenideElement configField = $x("//div[@id='config']"); - - @Step - public ConnectorCreateForm waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - nameField.shouldBe(Condition.visible); - return this; - } - - @Step - public ConnectorCreateForm setName(String connectName) { - nameField.shouldBe(Condition.enabled).setValue(connectName); - return this; - } - - @Step - public ConnectorCreateForm setConfig(String configJson) { - configField.shouldBe(Condition.enabled).click(); - setJsonInputValue(contentTextArea, configJson); - return this; - } - - @Step - public ConnectorCreateForm setConnectorDetails(String connectName, String configJson) { - setName(connectName); - setConfig(configJson); - return this; - } - - @Step - public ConnectorCreateForm clickSubmitButton() { - clickSubmitBtn(); - waitUntilSpinnerDisappear(); - return this; - } + protected SelenideElement nameField = $x("//input[@name='name']"); + protected SelenideElement contentTextArea = $x("//textarea[@class='ace_text-input']"); + protected SelenideElement configField = $x("//div[@id='config']"); + + @Step + public ConnectorCreateForm waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + nameField.shouldBe(Condition.visible); + return this; + } + + @Step + public ConnectorCreateForm setName(String connectName) { + nameField.shouldBe(Condition.enabled).setValue(connectName); + return this; + } + + @Step + public ConnectorCreateForm setConfig(String configJson) { + configField.shouldBe(Condition.enabled).click(); + setJsonInputValue(contentTextArea, configJson); + return this; + } + + @Step + public ConnectorCreateForm setConnectorDetails(String connectName, String configJson) { + setName(connectName); + setConfig(configJson); + return this; + } + + @Step + public ConnectorCreateForm clickSubmitButton() { + clickSubmitBtn(); + waitUntilSpinnerDisappear(); + return this; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/ConnectorDetails.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/ConnectorDetails.java index fbe1984ce..de74f67e1 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/ConnectorDetails.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/ConnectorDetails.java @@ -1,84 +1,84 @@ package com.provectus.kafka.ui.pages.connectors; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import static com.codeborne.selenide.Selenide.$x; - public class ConnectorDetails extends BasePage { - protected SelenideElement deleteBtn = $x("//li/div[contains(text(),'Delete')]"); - protected SelenideElement confirmBtnMdl = $x("//div[@role='dialog']//button[contains(text(),'Confirm')]"); - protected SelenideElement contentTextArea = $x("//textarea[@class='ace_text-input']"); - protected SelenideElement taskTab = $x("//a[contains(text(),'Tasks')]"); - protected SelenideElement configTab = $x("//a[contains(text(),'Config')]"); - protected SelenideElement configField = $x("//div[@id='config']"); - protected String connectorHeaderLocator = "//h1[contains(text(),'%s')]"; + protected SelenideElement deleteBtn = $x("//li/div[contains(text(),'Delete')]"); + protected SelenideElement confirmBtnMdl = $x("//div[@role='dialog']//button[contains(text(),'Confirm')]"); + protected SelenideElement contentTextArea = $x("//textarea[@class='ace_text-input']"); + protected SelenideElement taskTab = $x("//a[contains(text(),'Tasks')]"); + protected SelenideElement configTab = $x("//a[contains(text(),'Config')]"); + protected SelenideElement configField = $x("//div[@id='config']"); + protected String connectorHeaderLocator = "//h1[contains(text(),'%s')]"; - @Step - public ConnectorDetails waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - dotMenuBtn.shouldBe(Condition.visible); - return this; - } + @Step + public ConnectorDetails waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + dotMenuBtn.shouldBe(Condition.visible); + return this; + } - @Step - public ConnectorDetails openConfigTab() { - clickByJavaScript(configTab); - return this; - } + @Step + public ConnectorDetails openConfigTab() { + clickByJavaScript(configTab); + return this; + } - @Step - public ConnectorDetails setConfig(String configJson) { - configField.shouldBe(Condition.enabled).click(); - clearByKeyboard(contentTextArea); - contentTextArea.setValue(configJson); - configField.shouldBe(Condition.enabled).click(); - return this; - } + @Step + public ConnectorDetails setConfig(String configJson) { + configField.shouldBe(Condition.enabled).click(); + clearByKeyboard(contentTextArea); + contentTextArea.setValue(configJson); + configField.shouldBe(Condition.enabled).click(); + return this; + } - @Step - public ConnectorDetails clickSubmitButton() { - clickSubmitBtn(); - return this; - } + @Step + public ConnectorDetails clickSubmitButton() { + clickSubmitBtn(); + return this; + } - @Step - public ConnectorDetails openDotMenu() { - clickByJavaScript(dotMenuBtn); - return this; - } + @Step + public ConnectorDetails openDotMenu() { + clickByJavaScript(dotMenuBtn); + return this; + } - @Step - public ConnectorDetails clickDeleteBtn() { - clickByJavaScript(deleteBtn); - return this; - } + @Step + public ConnectorDetails clickDeleteBtn() { + clickByJavaScript(deleteBtn); + return this; + } - @Step - public ConnectorDetails clickConfirmBtn() { - confirmBtnMdl.shouldBe(Condition.enabled).click(); - confirmBtnMdl.shouldBe(Condition.disappear); - return this; - } + @Step + public ConnectorDetails clickConfirmBtn() { + confirmBtnMdl.shouldBe(Condition.enabled).click(); + confirmBtnMdl.shouldBe(Condition.disappear); + return this; + } - @Step - public ConnectorDetails deleteConnector() { - openDotMenu(); - clickDeleteBtn(); - clickConfirmBtn(); - return this; - } + @Step + public ConnectorDetails deleteConnector() { + openDotMenu(); + clickDeleteBtn(); + clickConfirmBtn(); + return this; + } - @Step - public boolean isConnectorHeaderVisible(String connectorName) { - return isVisible($x(String.format(connectorHeaderLocator, connectorName))); - } + @Step + public boolean isConnectorHeaderVisible(String connectorName) { + return isVisible($x(String.format(connectorHeaderLocator, connectorName))); + } - @Step - public boolean isAlertWithMessageVisible(AlertHeader header, String message) { - return isAlertVisible(header, message); - } + @Step + public boolean isAlertWithMessageVisible(AlertHeader header, String message) { + return isAlertVisible(header, message); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/KafkaConnectList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/KafkaConnectList.java index 6c672855a..e4b0d94e6 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/KafkaConnectList.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connectors/KafkaConnectList.java @@ -1,44 +1,44 @@ package com.provectus.kafka.ui.pages.connectors; +import static com.codeborne.selenide.Selenide.$x; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KAFKA_CONNECT; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import static com.codeborne.selenide.Selenide.$x; -import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KAFKA_CONNECT; - public class KafkaConnectList extends BasePage { - protected SelenideElement createConnectorBtn = $x("//button[contains(text(),'Create Connector')]"); - - public KafkaConnectList() { - tableElementNameLocator = "//tbody//td[contains(text(),'%s')]"; - } - - @Step - public KafkaConnectList waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - getPageTitleFromHeader(KAFKA_CONNECT).shouldBe(Condition.visible); - return this; - } - - @Step - public KafkaConnectList clickCreateConnectorBtn() { - clickByJavaScript(createConnectorBtn); - return this; - } - - @Step - public KafkaConnectList openConnector(String connectorName) { - getTableElement(connectorName).shouldBe(Condition.enabled).click(); - return this; - } - - @Step - public boolean isConnectorVisible(String connectorName) { - tableGrid.shouldBe(Condition.visible); - return isVisible(getTableElement(connectorName)); - } + protected SelenideElement createConnectorBtn = $x("//button[contains(text(),'Create Connector')]"); + + public KafkaConnectList() { + tableElementNameLocator = "//tbody//td[contains(text(),'%s')]"; + } + + @Step + public KafkaConnectList waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + getPageTitleFromHeader(KAFKA_CONNECT).shouldBe(Condition.visible); + return this; + } + + @Step + public KafkaConnectList clickCreateConnectorBtn() { + clickByJavaScript(createConnectorBtn); + return this; + } + + @Step + public KafkaConnectList openConnector(String connectorName) { + getTableElement(connectorName).shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public boolean isConnectorVisible(String connectorName) { + tableGrid.shouldBe(Condition.visible); + return isVisible(getTableElement(connectorName)); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumers/ConsumersDetails.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumers/ConsumersDetails.java index 240dc613c..46025927e 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumers/ConsumersDetails.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumers/ConsumersDetails.java @@ -1,31 +1,31 @@ package com.provectus.kafka.ui.pages.consumers; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.Condition; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import static com.codeborne.selenide.Selenide.$x; - public class ConsumersDetails extends BasePage { - protected String consumerIdHeaderLocator = "//h1[contains(text(),'%s')]"; - protected String topicElementLocator = "//tbody//td//a[text()='%s']"; + protected String consumerIdHeaderLocator = "//h1[contains(text(),'%s')]"; + protected String topicElementLocator = "//tbody//td//a[text()='%s']"; - @Step - public ConsumersDetails waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - tableGrid.shouldBe(Condition.visible); - return this; - } + @Step + public ConsumersDetails waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + tableGrid.shouldBe(Condition.visible); + return this; + } - @Step - public boolean isRedirectedConsumerTitleVisible(String consumerGroupId) { - return isVisible($x(String.format(consumerIdHeaderLocator, consumerGroupId))); - } + @Step + public boolean isRedirectedConsumerTitleVisible(String consumerGroupId) { + return isVisible($x(String.format(consumerIdHeaderLocator, consumerGroupId))); + } - @Step - public boolean isTopicInConsumersDetailsVisible(String topicName) { - tableGrid.shouldBe(Condition.visible); - return isVisible($x(String.format(topicElementLocator, topicName))); - } + @Step + public boolean isTopicInConsumersDetailsVisible(String topicName) { + tableGrid.shouldBe(Condition.visible); + return isVisible($x(String.format(topicElementLocator, topicName))); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumers/ConsumersList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumers/ConsumersList.java index 35ef40434..bc10b8f23 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumers/ConsumersList.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/consumers/ConsumersList.java @@ -1,17 +1,17 @@ package com.provectus.kafka.ui.pages.consumers; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.CONSUMERS; + import com.codeborne.selenide.Condition; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.CONSUMERS; - public class ConsumersList extends BasePage { - @Step - public ConsumersList waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - getPageTitleFromHeader(CONSUMERS).shouldBe(Condition.visible); - return this; - } + @Step + public ConsumersList waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + getPageTitleFromHeader(CONSUMERS).shouldBe(Condition.visible); + return this; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlDbList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlDbList.java deleted file mode 100644 index e80229d93..000000000 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlDbList.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.provectus.kafka.ui.pages.ksqlDb; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; -import com.provectus.kafka.ui.pages.BasePage; -import com.provectus.kafka.ui.pages.ksqlDb.enums.KsqlMenuTabs; -import io.qameta.allure.Step; -import org.openqa.selenium.By; - -import java.util.ArrayList; -import java.util.List; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$x; -import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KSQL_DB; - -public class KsqlDbList extends BasePage { - - protected SelenideElement executeKsqlBtn = $x("//button[text()='Execute KSQL Request']"); - protected SelenideElement tablesTab = $x("//nav[@role='navigation']/a[text()='Tables']"); - protected SelenideElement streamsTab = $x("//nav[@role='navigation']/a[text()='Streams']"); - - @Step - public KsqlDbList waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - getPageTitleFromHeader(KSQL_DB).shouldBe(Condition.visible); - return this; - } - - @Step - public KsqlDbList clickExecuteKsqlRequestBtn() { - clickByJavaScript(executeKsqlBtn); - return this; - } - - @Step - public KsqlDbList openDetailsTab(KsqlMenuTabs menu) { - $(By.linkText(menu.toString())).shouldBe(Condition.visible).click(); - waitUntilSpinnerDisappear(); - return this; - } - - private List initTablesItems() { - List gridItemList = new ArrayList<>(); - gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) - .forEach(item -> gridItemList.add(new KsqlDbList.KsqlTablesGridItem(item))); - return gridItemList; - } - - @Step - public KsqlDbList.KsqlTablesGridItem getTableByName(String tableName) { - return initTablesItems().stream() - .filter(e -> e.getTableName().equals(tableName)) - .findFirst().orElseThrow(); - } - - private List initStreamsItems() { - List gridItemList = new ArrayList<>(); - gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) - .forEach(item -> gridItemList.add(new KsqlDbList.KsqlStreamsGridItem(item))); - return gridItemList; - } - - @Step - public KsqlDbList.KsqlStreamsGridItem getStreamByName(String streamName) { - return initStreamsItems().stream() - .filter(e -> e.getStreamName().equals(streamName)) - .findFirst().orElseThrow(); - } - - public static class KsqlTablesGridItem extends BasePage { - - private final SelenideElement element; - - public KsqlTablesGridItem(SelenideElement element) { - this.element = element; - } - - @Step - public String getTableName() { - return element.$x("./td[1]").getText().trim(); - } - - @Step - public String getTopicName() { - return element.$x("./td[2]").getText().trim(); - } - - @Step - public String getKeyFormat() { - return element.$x("./td[3]").getText().trim(); - } - - @Step - public String getValueFormat() { - return element.$x("./td[4]").getText().trim(); - } - - @Step - public String getIsWindowed() { - return element.$x("./td[5]").getText().trim(); - } - } - - public static class KsqlStreamsGridItem extends BasePage { - - private final SelenideElement element; - - public KsqlStreamsGridItem(SelenideElement element) { - this.element = element; - } - - @Step - public String getStreamName() { - return element.$x("./td[1]").getText().trim(); - } - - @Step - public String getTopicName() { - return element.$x("./td[2]").getText().trim(); - } - - @Step - public String getKeyFormat() { - return element.$x("./td[3]").getText().trim(); - } - - @Step - public String getValueFormat() { - return element.$x("./td[4]").getText().trim(); - } - - @Step - public String getIsWindowed() { - return element.$x("./td[5]").getText().trim(); - } - } -} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlQueryForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlQueryForm.java deleted file mode 100644 index df915c009..000000000 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/KsqlQueryForm.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.provectus.kafka.ui.pages.ksqlDb; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; -import com.provectus.kafka.ui.pages.BasePage; -import io.qameta.allure.Step; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; - -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$$x; -import static com.codeborne.selenide.Selenide.$x; - -public class KsqlQueryForm extends BasePage { - protected SelenideElement clearBtn = $x("//div/button[text()='Clear']"); - protected SelenideElement executeBtn = $x("//div/button[text()='Execute']"); - protected SelenideElement stopQueryBtn = $x("//div/button[text()='Stop query']"); - protected SelenideElement clearResultsBtn = $x("//div/button[text()='Clear results']"); - protected SelenideElement addStreamPropertyBtn = $x("//button[text()='Add Stream Property']"); - protected SelenideElement queryAreaValue = $x("//div[@class='ace_content']"); - protected SelenideElement queryArea = $x("//div[@id='ksql']/textarea[@class='ace_text-input']"); - protected ElementsCollection ksqlGridItems = $$x("//tbody//tr"); - protected ElementsCollection keyField = $$x("//input[@aria-label='key']"); - protected ElementsCollection valueField = $$x("//input[@aria-label='value']"); - - @Step - public KsqlQueryForm waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - executeBtn.shouldBe(Condition.visible); - return this; - } - - @Step - public KsqlQueryForm clickClearBtn() { - clickByJavaScript(clearBtn); - return this; - } - - @Step - public KsqlQueryForm clickExecuteBtn() { - clickByActions(executeBtn); - if (queryAreaValue.getText().contains("EMIT CHANGES;")) { - loadingSpinner.shouldBe(Condition.visible); - } else { - waitUntilSpinnerDisappear(); - } - return this; - } - - @Step - public KsqlQueryForm clickStopQueryBtn() { - clickByActions(stopQueryBtn); - waitUntilSpinnerDisappear(); - return this; - } - - @Step - public KsqlQueryForm clickClearResultsBtn() { - clickByActions(clearResultsBtn); - waitUntilSpinnerDisappear(); - return this; - } - - @Step - public KsqlQueryForm clickAddStreamProperty() { - clickByJavaScript(addStreamPropertyBtn); - return this; - } - - @Step - public KsqlQueryForm setQuery(String query) { - queryAreaValue.shouldBe(Condition.visible).click(); - queryArea.setValue(query); - return this; - } - - @Step - public KsqlQueryForm.KsqlResponseGridItem getTableByName(String name) { - return initItems().stream() - .filter(e -> e.getName().equalsIgnoreCase(name)) - .findFirst().orElseThrow(); - } - - @Step - public boolean areResultsVisible() { - boolean visible = false; - try { - visible = initItems().size() > 0; - } catch (Throwable ignored) { - } - return visible; - } - - private List initItems() { - List gridItemList = new ArrayList<>(); - ksqlGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) - .forEach(item -> gridItemList.add(new KsqlQueryForm.KsqlResponseGridItem(item))); - return gridItemList; - } - - public static class KsqlResponseGridItem extends BasePage { - - private final SelenideElement element; - - private KsqlResponseGridItem(SelenideElement element) { - this.element = element; - } - - @Step - public String getType() { - return element.$x("./td[1]").getText().trim(); - } - - @Step - public String getName() { - return element.$x("./td[2]").scrollTo().getText().trim(); - } - - @Step - public boolean isVisible() { - boolean isVisible = false; - try { - element.$x("./td[2]").shouldBe(visible, Duration.ofMillis(500)); - isVisible = true; - } catch (Throwable ignored) { - } - return isVisible; - } - - @Step - public String getTopic() { - return element.$x("./td[3]").getText().trim(); - } - - @Step - public String getKeyFormat() { - return element.$x("./td[4]").getText().trim(); - } - - @Step - public String getValueFormat() { - return element.$x("./td[5]").getText().trim(); - } - - @Step - public String getIsWindowed() { - return element.$x("./td[6]").getText().trim(); - } - } -} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/enums/KsqlMenuTabs.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/enums/KsqlMenuTabs.java deleted file mode 100644 index bb719dc0f..000000000 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/enums/KsqlMenuTabs.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.provectus.kafka.ui.pages.ksqlDb.enums; - -public enum KsqlMenuTabs { - - TABLES("Table"), - STREAMS("Streams"); - - private final String value; - - KsqlMenuTabs(String value) { - this.value = value; - } - - public String toString() { - return value; - } -} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/enums/KsqlQueryConfig.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/enums/KsqlQueryConfig.java deleted file mode 100644 index 9f8583747..000000000 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/enums/KsqlQueryConfig.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.provectus.kafka.ui.pages.ksqlDb.enums; - -public enum KsqlQueryConfig { - - SHOW_TABLES("show tables;"), - SHOW_STREAMS("show streams;"), - SELECT_ALL_FROM("SELECT * FROM %s\n" + - "EMIT CHANGES;"); - - private final String query; - - KsqlQueryConfig(String query) { - this.query = query; - } - - public String getQuery() { - return query; - } -} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlDbList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlDbList.java new file mode 100644 index 000000000..7eb35d52f --- /dev/null +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlDbList.java @@ -0,0 +1,138 @@ +package com.provectus.kafka.ui.pages.ksqldb; + +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$x; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KSQL_DB; + +import com.codeborne.selenide.CollectionCondition; +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; +import com.provectus.kafka.ui.pages.BasePage; +import com.provectus.kafka.ui.pages.ksqldb.enums.KsqlMenuTabs; +import io.qameta.allure.Step; +import java.util.ArrayList; +import java.util.List; +import org.openqa.selenium.By; + +public class KsqlDbList extends BasePage { + + protected SelenideElement executeKsqlBtn = $x("//button[text()='Execute KSQL Request']"); + protected SelenideElement tablesTab = $x("//nav[@role='navigation']/a[text()='Tables']"); + protected SelenideElement streamsTab = $x("//nav[@role='navigation']/a[text()='Streams']"); + + @Step + public KsqlDbList waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + getPageTitleFromHeader(KSQL_DB).shouldBe(Condition.visible); + return this; + } + + @Step + public KsqlDbList clickExecuteKsqlRequestBtn() { + clickByJavaScript(executeKsqlBtn); + return this; + } + + @Step + public KsqlDbList openDetailsTab(KsqlMenuTabs menu) { + $(By.linkText(menu.toString())).shouldBe(Condition.visible).click(); + waitUntilSpinnerDisappear(); + return this; + } + + private List initTablesItems() { + List gridItemList = new ArrayList<>(); + gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) + .forEach(item -> gridItemList.add(new KsqlDbList.KsqlTablesGridItem(item))); + return gridItemList; + } + + @Step + public KsqlDbList.KsqlTablesGridItem getTableByName(String tableName) { + return initTablesItems().stream() + .filter(e -> e.getTableName().equals(tableName)) + .findFirst().orElseThrow(); + } + + private List initStreamsItems() { + List gridItemList = new ArrayList<>(); + gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) + .forEach(item -> gridItemList.add(new KsqlDbList.KsqlStreamsGridItem(item))); + return gridItemList; + } + + @Step + public KsqlDbList.KsqlStreamsGridItem getStreamByName(String streamName) { + return initStreamsItems().stream() + .filter(e -> e.getStreamName().equals(streamName)) + .findFirst().orElseThrow(); + } + + public static class KsqlTablesGridItem extends BasePage { + + private final SelenideElement element; + + public KsqlTablesGridItem(SelenideElement element) { + this.element = element; + } + + @Step + public String getTableName() { + return element.$x("./td[1]").getText().trim(); + } + + @Step + public String getTopicName() { + return element.$x("./td[2]").getText().trim(); + } + + @Step + public String getKeyFormat() { + return element.$x("./td[3]").getText().trim(); + } + + @Step + public String getValueFormat() { + return element.$x("./td[4]").getText().trim(); + } + + @Step + public String getIsWindowed() { + return element.$x("./td[5]").getText().trim(); + } + } + + public static class KsqlStreamsGridItem extends BasePage { + + private final SelenideElement element; + + public KsqlStreamsGridItem(SelenideElement element) { + this.element = element; + } + + @Step + public String getStreamName() { + return element.$x("./td[1]").getText().trim(); + } + + @Step + public String getTopicName() { + return element.$x("./td[2]").getText().trim(); + } + + @Step + public String getKeyFormat() { + return element.$x("./td[3]").getText().trim(); + } + + @Step + public String getValueFormat() { + return element.$x("./td[4]").getText().trim(); + } + + @Step + public String getIsWindowed() { + return element.$x("./td[5]").getText().trim(); + } + } +} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlQueryForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlQueryForm.java new file mode 100644 index 000000000..ab24cbe9a --- /dev/null +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/KsqlQueryForm.java @@ -0,0 +1,153 @@ +package com.provectus.kafka.ui.pages.ksqldb; + +import static com.codeborne.selenide.Condition.visible; +import static com.codeborne.selenide.Selenide.$$x; +import static com.codeborne.selenide.Selenide.$x; + +import com.codeborne.selenide.CollectionCondition; +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.SelenideElement; +import com.provectus.kafka.ui.pages.BasePage; +import io.qameta.allure.Step; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +public class KsqlQueryForm extends BasePage { + protected SelenideElement clearBtn = $x("//div/button[text()='Clear']"); + protected SelenideElement executeBtn = $x("//div/button[text()='Execute']"); + protected SelenideElement stopQueryBtn = $x("//div/button[text()='Stop query']"); + protected SelenideElement clearResultsBtn = $x("//div/button[text()='Clear results']"); + protected SelenideElement addStreamPropertyBtn = $x("//button[text()='Add Stream Property']"); + protected SelenideElement queryAreaValue = $x("//div[@class='ace_content']"); + protected SelenideElement queryArea = $x("//div[@id='ksql']/textarea[@class='ace_text-input']"); + protected ElementsCollection ksqlGridItems = $$x("//tbody//tr"); + protected ElementsCollection keyField = $$x("//input[@aria-label='key']"); + protected ElementsCollection valueField = $$x("//input[@aria-label='value']"); + + @Step + public KsqlQueryForm waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + executeBtn.shouldBe(Condition.visible); + return this; + } + + @Step + public KsqlQueryForm clickClearBtn() { + clickByJavaScript(clearBtn); + return this; + } + + @Step + public KsqlQueryForm clickExecuteBtn() { + clickByActions(executeBtn); + if (queryAreaValue.getText().contains("EMIT CHANGES;")) { + loadingSpinner.shouldBe(Condition.visible); + } else { + waitUntilSpinnerDisappear(); + } + return this; + } + + @Step + public KsqlQueryForm clickStopQueryBtn() { + clickByActions(stopQueryBtn); + waitUntilSpinnerDisappear(); + return this; + } + + @Step + public KsqlQueryForm clickClearResultsBtn() { + clickByActions(clearResultsBtn); + waitUntilSpinnerDisappear(); + return this; + } + + @Step + public KsqlQueryForm clickAddStreamProperty() { + clickByJavaScript(addStreamPropertyBtn); + return this; + } + + @Step + public KsqlQueryForm setQuery(String query) { + queryAreaValue.shouldBe(Condition.visible).click(); + queryArea.setValue(query); + return this; + } + + @Step + public KsqlQueryForm.KsqlResponseGridItem getTableByName(String name) { + return initItems().stream() + .filter(e -> e.getName().equalsIgnoreCase(name)) + .findFirst().orElseThrow(); + } + + @Step + public boolean areResultsVisible() { + boolean visible = false; + try { + visible = initItems().size() > 0; + } catch (Throwable ignored) { + } + return visible; + } + + private List initItems() { + List gridItemList = new ArrayList<>(); + ksqlGridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) + .forEach(item -> gridItemList.add(new KsqlQueryForm.KsqlResponseGridItem(item))); + return gridItemList; + } + + public static class KsqlResponseGridItem extends BasePage { + + private final SelenideElement element; + + private KsqlResponseGridItem(SelenideElement element) { + this.element = element; + } + + @Step + public String getType() { + return element.$x("./td[1]").getText().trim(); + } + + @Step + public String getName() { + return element.$x("./td[2]").scrollTo().getText().trim(); + } + + @Step + public boolean isVisible() { + boolean isVisible = false; + try { + element.$x("./td[2]").shouldBe(visible, Duration.ofMillis(500)); + isVisible = true; + } catch (Throwable ignored) { + } + return isVisible; + } + + @Step + public String getTopic() { + return element.$x("./td[3]").getText().trim(); + } + + @Step + public String getKeyFormat() { + return element.$x("./td[4]").getText().trim(); + } + + @Step + public String getValueFormat() { + return element.$x("./td[5]").getText().trim(); + } + + @Step + public String getIsWindowed() { + return element.$x("./td[6]").getText().trim(); + } + } +} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/enums/KsqlMenuTabs.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/enums/KsqlMenuTabs.java new file mode 100644 index 000000000..016246edb --- /dev/null +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/enums/KsqlMenuTabs.java @@ -0,0 +1,17 @@ +package com.provectus.kafka.ui.pages.ksqldb.enums; + +public enum KsqlMenuTabs { + + TABLES("Table"), + STREAMS("Streams"); + + private final String value; + + KsqlMenuTabs(String value) { + this.value = value; + } + + public String toString() { + return value; + } +} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/enums/KsqlQueryConfig.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/enums/KsqlQueryConfig.java new file mode 100644 index 000000000..d3cf0ddec --- /dev/null +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/enums/KsqlQueryConfig.java @@ -0,0 +1,18 @@ +package com.provectus.kafka.ui.pages.ksqldb.enums; + +public enum KsqlQueryConfig { + + SHOW_TABLES("show tables;"), + SHOW_STREAMS("show streams;"), + SELECT_ALL_FROM("SELECT * FROM %s\n" + "EMIT CHANGES;"); + + private final String query; + + KsqlQueryConfig(String query) { + this.query = query; + } + + public String getQuery() { + return query; + } +} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/models/Stream.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/models/Stream.java similarity index 50% rename from kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/models/Stream.java rename to kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/models/Stream.java index 4030a478c..3583a2436 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/models/Stream.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/models/Stream.java @@ -1,4 +1,4 @@ -package com.provectus.kafka.ui.pages.ksqlDb.models; +package com.provectus.kafka.ui.pages.ksqldb.models; import lombok.Data; import lombok.experimental.Accessors; @@ -7,5 +7,5 @@ @Accessors(chain = true) public class Stream { - private String name, topicName, valueFormat, partitions; + private String name, topicName, valueFormat, partitions; } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/models/Table.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/models/Table.java similarity index 56% rename from kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/models/Table.java rename to kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/models/Table.java index 1856fffd8..96b3d88ba 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqlDb/models/Table.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/ksqldb/models/Table.java @@ -1,4 +1,4 @@ -package com.provectus.kafka.ui.pages.ksqlDb.models; +package com.provectus.kafka.ui.pages.ksqldb.models; import lombok.Data; import lombok.experimental.Accessors; @@ -7,5 +7,5 @@ @Accessors(chain = true) public class Table { - private String name, streamName; + private String name, streamName; } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/NaviSideBar.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/NaviSideBar.java index 35490a27d..ea3cc6ecd 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/NaviSideBar.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/NaviSideBar.java @@ -1,64 +1,63 @@ package com.provectus.kafka.ui.pages.panels; +import static com.codeborne.selenide.Selenide.$x; +import static com.provectus.kafka.ui.settings.BaseSource.CLUSTER_NAME; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import com.provectus.kafka.ui.pages.panels.enums.MenuItem; import io.qameta.allure.Step; - import java.time.Duration; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.codeborne.selenide.Selenide.$x; -import static com.provectus.kafka.ui.settings.BaseSource.CLUSTER_NAME; - public class NaviSideBar extends BasePage { - protected SelenideElement dashboardMenuItem = $x("//a[@title='Dashboard']"); - protected String sideMenuOptionElementLocator = ".//ul/li[contains(.,'%s')]"; - protected String clusterElementLocator = "//aside/ul/li[contains(.,'%s')]"; - - private SelenideElement expandCluster(String clusterName) { - SelenideElement clusterElement = $x(String.format(clusterElementLocator, clusterName)).shouldBe(Condition.visible); - if (clusterElement.parent().$$x(".//ul").size() == 0) { - clickByActions(clusterElement); - } - return clusterElement; - } - - @Step - public NaviSideBar waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - dashboardMenuItem.shouldBe(Condition.visible, Duration.ofSeconds(30)); - return this; - } - - @Step - public String getPagePath(MenuItem menuItem) { - return getPagePathFromHeader(menuItem) - .shouldBe(Condition.visible) - .getText().trim(); - } - - @Step - public NaviSideBar openSideMenu(String clusterName, MenuItem menuItem) { - clickByActions(expandCluster(clusterName).parent() - .$x(String.format(sideMenuOptionElementLocator, menuItem.getNaviTitle()))); - return this; - } - - @Step - public NaviSideBar openSideMenu(MenuItem menuItem) { - openSideMenu(CLUSTER_NAME, menuItem); - return this; - } + protected SelenideElement dashboardMenuItem = $x("//a[@title='Dashboard']"); + protected String sideMenuOptionElementLocator = ".//ul/li[contains(.,'%s')]"; + protected String clusterElementLocator = "//aside/ul/li[contains(.,'%s')]"; - public List getAllMenuButtons() { - expandCluster(CLUSTER_NAME); - return Stream.of(MenuItem.values()) - .map(menuItem -> $x(String.format(sideMenuOptionElementLocator, menuItem.getNaviTitle()))) - .collect(Collectors.toList()); + private SelenideElement expandCluster(String clusterName) { + SelenideElement clusterElement = $x(String.format(clusterElementLocator, clusterName)).shouldBe(Condition.visible); + if (clusterElement.parent().$$x(".//ul").size() == 0) { + clickByActions(clusterElement); } + return clusterElement; + } + + @Step + public NaviSideBar waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + dashboardMenuItem.shouldBe(Condition.visible, Duration.ofSeconds(30)); + return this; + } + + @Step + public String getPagePath(MenuItem menuItem) { + return getPagePathFromHeader(menuItem) + .shouldBe(Condition.visible) + .getText().trim(); + } + + @Step + public NaviSideBar openSideMenu(String clusterName, MenuItem menuItem) { + clickByActions(expandCluster(clusterName).parent() + .$x(String.format(sideMenuOptionElementLocator, menuItem.getNaviTitle()))); + return this; + } + + @Step + public NaviSideBar openSideMenu(MenuItem menuItem) { + openSideMenu(CLUSTER_NAME, menuItem); + return this; + } + + public List getAllMenuButtons() { + expandCluster(CLUSTER_NAME); + return Stream.of(MenuItem.values()) + .map(menuItem -> $x(String.format(sideMenuOptionElementLocator, menuItem.getNaviTitle()))) + .collect(Collectors.toList()); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/TopPanel.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/TopPanel.java index 77cf71a92..805e5b1ee 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/TopPanel.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/TopPanel.java @@ -1,26 +1,25 @@ package com.provectus.kafka.ui.pages.panels; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; - import java.util.Arrays; import java.util.List; -import static com.codeborne.selenide.Selenide.$x; - public class TopPanel extends BasePage { - protected SelenideElement kafkaLogo = $x("//a[contains(text(),'UI for Apache Kafka')]"); - protected SelenideElement kafkaVersion = $x("//a[@title='Current commit']"); - protected SelenideElement logOutBtn = $x("//button[contains(text(),'Log out')]"); - protected SelenideElement gitBtn = $x("//a[@href='https://github.com/provectus/kafka-ui']"); - protected SelenideElement discordBtn = $x("//a[contains(@href,'https://discord.com/invite')]"); + protected SelenideElement kafkaLogo = $x("//a[contains(text(),'UI for Apache Kafka')]"); + protected SelenideElement kafkaVersion = $x("//a[@title='Current commit']"); + protected SelenideElement logOutBtn = $x("//button[contains(text(),'Log out')]"); + protected SelenideElement gitBtn = $x("//a[@href='https://github.com/provectus/kafka-ui']"); + protected SelenideElement discordBtn = $x("//a[contains(@href,'https://discord.com/invite')]"); - public List getAllVisibleElements() { - return Arrays.asList(kafkaLogo, kafkaVersion, gitBtn, discordBtn); - } + public List getAllVisibleElements() { + return Arrays.asList(kafkaLogo, kafkaVersion, gitBtn, discordBtn); + } - public List getAllEnabledElements() { - return Arrays.asList(gitBtn, discordBtn, kafkaLogo); - } + public List getAllEnabledElements() { + return Arrays.asList(gitBtn, discordBtn, kafkaLogo); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/enums/MenuItem.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/enums/MenuItem.java index 6610a8293..993d6070a 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/enums/MenuItem.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/panels/enums/MenuItem.java @@ -1,28 +1,28 @@ package com.provectus.kafka.ui.pages.panels.enums; public enum MenuItem { - - DASHBOARD("Dashboard", "Dashboard"), - BROKERS("Brokers", "Brokers"), - TOPICS("Topics", "Topics"), - CONSUMERS("Consumers", "Consumers"), - SCHEMA_REGISTRY("Schema Registry", "Schema Registry"), - KAFKA_CONNECT("Kafka Connect", "Connectors"), - KSQL_DB("KSQL DB", "KSQL DB"); - - private final String naviTitle; - private final String pageTitle; - - MenuItem(String naviTitle, String pageTitle) { - this.naviTitle = naviTitle; - this.pageTitle = pageTitle; - } - - public String getNaviTitle() { - return naviTitle; - } - - public String getPageTitle() { - return pageTitle; - } + + DASHBOARD("Dashboard", "Dashboard"), + BROKERS("Brokers", "Brokers"), + TOPICS("Topics", "Topics"), + CONSUMERS("Consumers", "Consumers"), + SCHEMA_REGISTRY("Schema Registry", "Schema Registry"), + KAFKA_CONNECT("Kafka Connect", "Connectors"), + KSQL_DB("KSQL DB", "KSQL DB"); + + private final String naviTitle; + private final String pageTitle; + + MenuItem(String naviTitle, String pageTitle) { + this.naviTitle = naviTitle; + this.pageTitle = pageTitle; + } + + public String getNaviTitle() { + return naviTitle; + } + + public String getPageTitle() { + return pageTitle; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaCreateForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaCreateForm.java index 52bfe0971..374bb4274 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaCreateForm.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaCreateForm.java @@ -1,5 +1,10 @@ package com.provectus.kafka.ui.pages.schemas; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$$x; +import static com.codeborne.selenide.Selenide.$x; +import static org.openqa.selenium.By.id; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.codeborne.selenide.WebDriverRunner; @@ -7,133 +12,130 @@ import com.provectus.kafka.ui.api.model.SchemaType; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import org.openqa.selenium.Keys; -import org.openqa.selenium.interactions.Actions; - import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; - -import static com.codeborne.selenide.Selenide.*; -import static org.openqa.selenium.By.id; +import org.openqa.selenium.Keys; +import org.openqa.selenium.interactions.Actions; public class SchemaCreateForm extends BasePage { - protected SelenideElement schemaNameField = $x("//input[@name='subject']"); - protected SelenideElement pageTitle = $x("//h1['Edit']"); - protected SelenideElement schemaTextArea = $x("//textarea[@name='schema']"); - protected SelenideElement newSchemaInput = $("#newSchema [wrap]"); - 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 leftVersionDdl = $(id("left-select")); - protected SelenideElement rightVersionDdl = $(id("right-select")); - protected List visibleMarkers = $$x("//div[@class='ace_scroller']//div[contains(@class,'codeMarker')]"); - protected List elementsCompareVersionDdl = $$x("//ul[@role='listbox']/ul/li"); - protected String ddlElementLocator = "//li[@value='%s']"; - - @Step - public SchemaCreateForm waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - pageTitle.shouldBe(Condition.visible); - return this; - } - - @Step - public SchemaCreateForm setSubjectName(String name) { - schemaNameField.setValue(name); - return this; - } - - @Step - public SchemaCreateForm setSchemaField(String text) { - schemaTextArea.setValue(text); - return this; - } - - @Step - public SchemaCreateForm selectSchemaTypeFromDropdown(SchemaType schemaType) { - schemaTypeDdl.shouldBe(Condition.enabled).click(); - $x(String.format(ddlElementLocator, schemaType.getValue())).shouldBe(Condition.visible).click(); - return this; - } - - @Step - public SchemaCreateForm clickSubmitButton() { - clickSubmitBtn(); - return this; - } - - @Step - public SchemaCreateForm selectCompatibilityLevelFromDropdown(CompatibilityLevel.CompatibilityEnum level) { - compatibilityLevelList.shouldBe(Condition.enabled).click(); - $x(String.format(ddlElementLocator, level.getValue())).shouldBe(Condition.visible).click(); - return this; - } - - @Step - public SchemaCreateForm openLeftVersionDdl() { - leftVersionDdl.shouldBe(Condition.enabled).click(); - return this; - } - - @Step - public SchemaCreateForm openRightVersionDdl() { - rightVersionDdl.shouldBe(Condition.enabled).click(); - return this; - } - - @Step - public int getVersionsNumberFromList() { - return elementsCompareVersionDdl.size(); - } - - @Step - public SchemaCreateForm selectVersionFromDropDown(int versionNumberDd) { - $x(String.format(ddlElementLocator, versionNumberDd)).shouldBe(Condition.visible).click(); - return this; - } - - @Step - public int getMarkedLinesNumber() { - return visibleMarkers.size(); - } - - @Step - public SchemaCreateForm setNewSchemaValue(String configJson) { - newSchemaTextArea.shouldBe(Condition.visible).click(); - newSchemaInput.shouldBe(Condition.enabled); - new Actions(WebDriverRunner.getWebDriver()) - .sendKeys(Keys.PAGE_UP) - .keyDown(Keys.SHIFT) - .sendKeys(Keys.PAGE_DOWN) - .keyUp(Keys.SHIFT) - .sendKeys(Keys.DELETE) - .perform(); - setJsonInputValue(newSchemaInput, configJson); - return this; - } - - @Step - public List 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"); - enabled = false; - } catch (Throwable ignored) { - } - return enabled; + protected SelenideElement schemaNameField = $x("//input[@name='subject']"); + protected SelenideElement pageTitle = $x("//h1['Edit']"); + protected SelenideElement schemaTextArea = $x("//textarea[@name='schema']"); + protected SelenideElement newSchemaInput = $("#newSchema [wrap]"); + 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 leftVersionDdl = $(id("left-select")); + protected SelenideElement rightVersionDdl = $(id("right-select")); + protected List visibleMarkers = + $$x("//div[@class='ace_scroller']//div[contains(@class,'codeMarker')]"); + protected List elementsCompareVersionDdl = $$x("//ul[@role='listbox']/ul/li"); + protected String ddlElementLocator = "//li[@value='%s']"; + + @Step + public SchemaCreateForm waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + pageTitle.shouldBe(Condition.visible); + return this; + } + + @Step + public SchemaCreateForm setSubjectName(String name) { + schemaNameField.setValue(name); + return this; + } + + @Step + public SchemaCreateForm setSchemaField(String text) { + schemaTextArea.setValue(text); + return this; + } + + @Step + public SchemaCreateForm selectSchemaTypeFromDropdown(SchemaType schemaType) { + schemaTypeDdl.shouldBe(Condition.enabled).click(); + $x(String.format(ddlElementLocator, schemaType.getValue())).shouldBe(Condition.visible).click(); + return this; + } + + @Step + public SchemaCreateForm clickSubmitButton() { + clickSubmitBtn(); + return this; + } + + @Step + public SchemaCreateForm selectCompatibilityLevelFromDropdown(CompatibilityLevel.CompatibilityEnum level) { + compatibilityLevelList.shouldBe(Condition.enabled).click(); + $x(String.format(ddlElementLocator, level.getValue())).shouldBe(Condition.visible).click(); + return this; + } + + @Step + public SchemaCreateForm openLeftVersionDdl() { + leftVersionDdl.shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public SchemaCreateForm openRightVersionDdl() { + rightVersionDdl.shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public int getVersionsNumberFromList() { + return elementsCompareVersionDdl.size(); + } + + @Step + public SchemaCreateForm selectVersionFromDropDown(int versionNumberDd) { + $x(String.format(ddlElementLocator, versionNumberDd)).shouldBe(Condition.visible).click(); + return this; + } + + @Step + public int getMarkedLinesNumber() { + return visibleMarkers.size(); + } + + @Step + public SchemaCreateForm setNewSchemaValue(String configJson) { + newSchemaTextArea.shouldBe(Condition.visible).click(); + newSchemaInput.shouldBe(Condition.enabled); + new Actions(WebDriverRunner.getWebDriver()) + .sendKeys(Keys.PAGE_UP) + .keyDown(Keys.SHIFT) + .sendKeys(Keys.PAGE_DOWN) + .keyUp(Keys.SHIFT) + .sendKeys(Keys.DELETE) + .perform(); + setJsonInputValue(newSchemaInput, configJson); + return this; + } + + @Step + public List 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"); + enabled = false; + } catch (Throwable ignored) { } + return enabled; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaDetails.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaDetails.java index fc7013d46..11c2d4a7b 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaDetails.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaDetails.java @@ -1,69 +1,69 @@ package com.provectus.kafka.ui.pages.schemas; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import static com.codeborne.selenide.Selenide.$x; - public class SchemaDetails extends BasePage { - protected SelenideElement actualVersionTextArea = $x("//div[@id='schema']"); - protected SelenideElement compatibilityField = $x("//h4[contains(text(),'Compatibility')]/../p"); - protected SelenideElement editSchemaBtn = $x("//button[contains(text(),'Edit Schema')]"); - protected SelenideElement removeBtn = $x("//*[contains(text(),'Remove')]"); - protected SelenideElement confirmBtn = $x("//div[@role='dialog']//button[contains(text(),'Confirm')]"); - protected SelenideElement schemaTypeField = $x("//h4[contains(text(),'Type')]/../p"); - protected SelenideElement latestVersionField = $x("//h4[contains(text(),'Latest version')]/../p"); - protected SelenideElement compareVersionBtn = $x("//button[text()='Compare Versions']"); - protected String schemaHeaderLocator = "//h1[contains(text(),'%s')]"; + protected SelenideElement actualVersionTextArea = $x("//div[@id='schema']"); + protected SelenideElement compatibilityField = $x("//h4[contains(text(),'Compatibility')]/../p"); + protected SelenideElement editSchemaBtn = $x("//button[contains(text(),'Edit Schema')]"); + protected SelenideElement removeBtn = $x("//*[contains(text(),'Remove')]"); + protected SelenideElement confirmBtn = $x("//div[@role='dialog']//button[contains(text(),'Confirm')]"); + protected SelenideElement schemaTypeField = $x("//h4[contains(text(),'Type')]/../p"); + protected SelenideElement latestVersionField = $x("//h4[contains(text(),'Latest version')]/../p"); + protected SelenideElement compareVersionBtn = $x("//button[text()='Compare Versions']"); + protected String schemaHeaderLocator = "//h1[contains(text(),'%s')]"; - @Step - public SchemaDetails waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - actualVersionTextArea.shouldBe(Condition.visible); - return this; - } + @Step + public SchemaDetails waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + actualVersionTextArea.shouldBe(Condition.visible); + return this; + } - @Step - public String getCompatibility() { - return compatibilityField.getText(); - } + @Step + public String getCompatibility() { + return compatibilityField.getText(); + } - @Step - public boolean isSchemaHeaderVisible(String schemaName) { - return isVisible($x(String.format(schemaHeaderLocator, schemaName))); - } + @Step + public boolean isSchemaHeaderVisible(String schemaName) { + return isVisible($x(String.format(schemaHeaderLocator, schemaName))); + } - @Step - public int getLatestVersion() { - return Integer.parseInt(latestVersionField.getText()); - } + @Step + public int getLatestVersion() { + return Integer.parseInt(latestVersionField.getText()); + } - @Step - public String getSchemaType() { - return schemaTypeField.getText(); - } + @Step + public String getSchemaType() { + return schemaTypeField.getText(); + } - @Step - public SchemaDetails openEditSchema() { - editSchemaBtn.shouldBe(Condition.visible).click(); - return this; - } + @Step + public SchemaDetails openEditSchema() { + editSchemaBtn.shouldBe(Condition.visible).click(); + return this; + } - @Step - public SchemaDetails openCompareVersionMenu() { - compareVersionBtn.shouldBe(Condition.enabled).click(); - return this; - } + @Step + public SchemaDetails openCompareVersionMenu() { + compareVersionBtn.shouldBe(Condition.enabled).click(); + return this; + } - @Step - public SchemaDetails removeSchema() { - clickByJavaScript(dotMenuBtn); - removeBtn.shouldBe(Condition.enabled).click(); - confirmBtn.shouldBe(Condition.visible).click(); - confirmBtn.shouldBe(Condition.disappear); - return this; - } + @Step + public SchemaDetails removeSchema() { + clickByJavaScript(dotMenuBtn); + removeBtn.shouldBe(Condition.enabled).click(); + confirmBtn.shouldBe(Condition.visible).click(); + confirmBtn.shouldBe(Condition.disappear); + return this; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaRegistryList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaRegistryList.java index 4f06bb995..f2d2f4b98 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaRegistryList.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schemas/SchemaRegistryList.java @@ -1,42 +1,42 @@ package com.provectus.kafka.ui.pages.schemas; +import static com.codeborne.selenide.Selenide.$x; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.SCHEMA_REGISTRY; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; -import static com.codeborne.selenide.Selenide.$x; -import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.SCHEMA_REGISTRY; - public class SchemaRegistryList extends BasePage { - protected SelenideElement createSchemaBtn = $x("//button[contains(text(),'Create Schema')]"); - - @Step - public SchemaRegistryList waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - getPageTitleFromHeader(SCHEMA_REGISTRY).shouldBe(Condition.visible); - return this; - } - - @Step - public SchemaRegistryList clickCreateSchema() { - clickByJavaScript(createSchemaBtn); - return this; - } - - @Step - public SchemaRegistryList openSchema(String schemaName) { - getTableElement(schemaName) - .shouldBe(Condition.enabled).click(); - return this; - } - - @Step - public boolean isSchemaVisible(String schemaName) { - tableGrid.shouldBe(Condition.visible); - return isVisible(getTableElement(schemaName)); - } + protected SelenideElement createSchemaBtn = $x("//button[contains(text(),'Create Schema')]"); + + @Step + public SchemaRegistryList waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + getPageTitleFromHeader(SCHEMA_REGISTRY).shouldBe(Condition.visible); + return this; + } + + @Step + public SchemaRegistryList clickCreateSchema() { + clickByJavaScript(createSchemaBtn); + return this; + } + + @Step + public SchemaRegistryList openSchema(String schemaName) { + getTableElement(schemaName) + .shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public boolean isSchemaVisible(String schemaName) { + tableGrid.shouldBe(Condition.visible); + return isVisible(getTableElement(schemaName)); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/ProduceMessagePanel.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/ProduceMessagePanel.java index 651c514ee..e407d4fe3 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/ProduceMessagePanel.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/ProduceMessagePanel.java @@ -1,57 +1,56 @@ package com.provectus.kafka.ui.pages.topics; +import static com.codeborne.selenide.Selenide.$x; +import static com.codeborne.selenide.Selenide.refresh; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; - import java.util.Arrays; -import static com.codeborne.selenide.Selenide.$x; -import static com.codeborne.selenide.Selenide.refresh; - public class ProduceMessagePanel extends BasePage { - protected SelenideElement keyTextArea = $x("//div[@id='key']/textarea"); - protected SelenideElement contentTextArea = $x("//div[@id='content']/textarea"); - protected SelenideElement headersTextArea = $x("//div[@id='headers']/textarea"); - protected SelenideElement submitBtn = headersTextArea.$x("../../../..//button[@type='submit']"); - protected SelenideElement partitionDdl = $x("//ul[@name='partition']"); - protected SelenideElement keySerdeDdl = $x("//ul[@name='keySerde']"); - protected SelenideElement contentSerdeDdl = $x("//ul[@name='valueSerde']"); - - @Step - public ProduceMessagePanel waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - Arrays.asList(partitionDdl, keySerdeDdl, contentSerdeDdl).forEach(element -> element.shouldBe(Condition.visible)); - return this; - } - - @Step - public ProduceMessagePanel setKeyField(String value) { - clearByKeyboard(keyTextArea); - keyTextArea.setValue(value); - return this; - } - - @Step - public ProduceMessagePanel setContentFiled(String value) { - clearByKeyboard(contentTextArea); - contentTextArea.setValue(value); - return this; - } - - @Step - public ProduceMessagePanel setHeaderFiled(String value) { - headersTextArea.setValue(value); - return this; - } - - @Step - public ProduceMessagePanel submitProduceMessage() { - clickByActions(submitBtn); - submitBtn.shouldBe(Condition.disappear); - refresh(); - return this; - } + protected SelenideElement keyTextArea = $x("//div[@id='key']/textarea"); + protected SelenideElement contentTextArea = $x("//div[@id='content']/textarea"); + protected SelenideElement headersTextArea = $x("//div[@id='headers']/textarea"); + protected SelenideElement submitBtn = headersTextArea.$x("../../../..//button[@type='submit']"); + protected SelenideElement partitionDdl = $x("//ul[@name='partition']"); + protected SelenideElement keySerdeDdl = $x("//ul[@name='keySerde']"); + protected SelenideElement contentSerdeDdl = $x("//ul[@name='valueSerde']"); + + @Step + public ProduceMessagePanel waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + Arrays.asList(partitionDdl, keySerdeDdl, contentSerdeDdl).forEach(element -> element.shouldBe(Condition.visible)); + return this; + } + + @Step + public ProduceMessagePanel setKeyField(String value) { + clearByKeyboard(keyTextArea); + keyTextArea.setValue(value); + return this; + } + + @Step + public ProduceMessagePanel setContentFiled(String value) { + clearByKeyboard(contentTextArea); + contentTextArea.setValue(value); + return this; + } + + @Step + public ProduceMessagePanel setHeaderFiled(String value) { + headersTextArea.setValue(value); + return this; + } + + @Step + public ProduceMessagePanel submitProduceMessage() { + clickByActions(submitBtn); + submitBtn.shouldBe(Condition.disappear); + refresh(); + return this; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicCreateEditForm.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicCreateEditForm.java index 9c255d571..57f5930d6 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicCreateEditForm.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicCreateEditForm.java @@ -1,6 +1,15 @@ package com.provectus.kafka.ui.pages.topics; -import com.codeborne.selenide.*; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$$; +import static com.codeborne.selenide.Selenide.$x; +import static org.openqa.selenium.By.id; + +import com.codeborne.selenide.ClickOptions; +import com.codeborne.selenide.CollectionCondition; +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import com.provectus.kafka.ui.pages.topics.enums.CleanupPolicyValue; import com.provectus.kafka.ui.pages.topics.enums.CustomParameterType; @@ -8,267 +17,264 @@ import com.provectus.kafka.ui.pages.topics.enums.TimeToRetain; import io.qameta.allure.Step; -import static com.codeborne.selenide.Selenide.*; -import static org.openqa.selenium.By.id; - public class TopicCreateEditForm extends BasePage { - protected SelenideElement timeToRetainField = $x("//input[@id='timeToRetain']"); - protected SelenideElement partitionsField = $x("//input[@name='partitions']"); - protected SelenideElement nameField = $(id("topicFormName")); - protected SelenideElement maxMessageBytesField = $x("//input[@name='maxMessageBytes']"); - protected SelenideElement minInSyncReplicasField = $x("//input[@name='minInSyncReplicas']"); - protected SelenideElement cleanUpPolicyDdl = $x("//ul[@id='topicFormCleanupPolicy']"); - protected SelenideElement maxSizeOnDiscDdl = $x("//ul[@id='topicFormRetentionBytes']"); - protected SelenideElement customParameterDdl = $x("//ul[contains(@name,'customParams')]"); - protected SelenideElement deleteCustomParameterBtn = $x("//span[contains(@title,'Delete customParam')]"); - protected SelenideElement addCustomParameterTypeBtn = $x("//button[contains(text(),'Add Custom Parameter')]"); - protected SelenideElement customParameterValueField = $x("//input[@placeholder='Value']"); - protected SelenideElement validationCustomParameterValueMsg = $x("//p[contains(text(),'Value is required')]"); - protected String ddlElementLocator = "//li[@value='%s']"; - protected String btnTimeToRetainLocator = "//button[@class][text()='%s']"; - - - @Step - public TopicCreateEditForm waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - nameField.shouldBe(Condition.visible); - return this; - } - - public boolean isCreateTopicButtonEnabled() { - return isEnabled(submitBtn); - } - - public boolean isDeleteCustomParameterButtonEnabled() { - return isEnabled(deleteCustomParameterBtn); - } - - public boolean isNameFieldEnabled() { - return isEnabled(nameField); - } - - @Step - public TopicCreateEditForm setTopicName(String topicName) { - sendKeysAfterClear(nameField, topicName); - return this; - } - - @Step - public TopicCreateEditForm setMinInsyncReplicas(Integer minInsyncReplicas) { - minInSyncReplicasField.setValue(minInsyncReplicas.toString()); - return this; - } - - @Step - public TopicCreateEditForm setTimeToRetainDataInMs(Long ms) { - timeToRetainField.setValue(ms.toString()); - return this; - } - - @Step - public TopicCreateEditForm setTimeToRetainDataInMs(String ms) { - timeToRetainField.setValue(ms); - return this; - } - - @Step - public TopicCreateEditForm setMaxSizeOnDiskInGB(MaxSizeOnDisk MaxSizeOnDisk) { - maxSizeOnDiscDdl.shouldBe(Condition.visible).click(); - $x(String.format(ddlElementLocator, MaxSizeOnDisk.getOptionValue())).shouldBe(Condition.visible).click(); - return this; - } - - @Step - public TopicCreateEditForm clickAddCustomParameterTypeButton() { - addCustomParameterTypeBtn.click(); - return this; - } - - @Step - public TopicCreateEditForm openCustomParameterTypeDdl() { - customParameterDdl.shouldBe(Condition.visible).click(); - ddlOptions.shouldHave(CollectionCondition.sizeGreaterThan(0)); - return this; - } - - @Step - public ElementsCollection getAllDdlOptions() { - return getDdlOptions(); - } - - @Step - public TopicCreateEditForm setCustomParameterType(CustomParameterType customParameterType) { - openCustomParameterTypeDdl(); - $x(String.format(ddlElementLocator, customParameterType.getOptionValue())).shouldBe(Condition.visible).click(); - return this; - } - - @Step - public TopicCreateEditForm clearCustomParameterValue() { - clearByKeyboard(customParameterValueField); - return this; - } - - @Step - public TopicCreateEditForm setNumberOfPartitions(int partitions) { - partitionsField.shouldBe(Condition.enabled).clear(); - partitionsField.sendKeys(String.valueOf(partitions)); - return this; - } - - @Step - public TopicCreateEditForm setTimeToRetainDataByButtons(TimeToRetain timeToRetain) { - $x(String.format(btnTimeToRetainLocator, timeToRetain.getButton())).shouldBe(Condition.enabled).click(); - return this; - } - - @Step - public TopicCreateEditForm selectCleanupPolicy(CleanupPolicyValue cleanupPolicyOptionValue) { - cleanUpPolicyDdl.shouldBe(Condition.visible).click(); - $x(String.format(ddlElementLocator, cleanupPolicyOptionValue.getOptionValue())).shouldBe(Condition.visible).click(); - return this; - } - - @Step - public TopicCreateEditForm selectRetentionBytes(String visibleValue) { - return selectFromDropDownByVisibleText("retentionBytes", visibleValue); - } - - @Step - public TopicCreateEditForm selectRetentionBytes(Long optionValue) { - return selectFromDropDownByOptionValue("retentionBytes", optionValue.toString()); - } - - @Step - public TopicCreateEditForm clickCreateTopicBtn() { - clickSubmitBtn(); - return this; - } - - @Step - public TopicCreateEditForm addCustomParameter(String customParameterName, - String customParameterValue) { - ElementsCollection customParametersElements = - $$("ul[role=listbox][name^=customParams][name$=name]"); - KafkaUISelectElement kafkaUISelectElement = null; - if (customParametersElements.size() == 1) { - if ("Select".equals(customParametersElements.first().getText())) { - kafkaUISelectElement = new KafkaUISelectElement(customParametersElements.first()); - } - } else { - $$("button") - .find(Condition.exactText("Add Custom Parameter")) - .click(); - customParametersElements = $$("ul[role=listbox][name^=customParams][name$=name]"); - kafkaUISelectElement = new KafkaUISelectElement(customParametersElements.last()); - } - if (kafkaUISelectElement != null) { - kafkaUISelectElement.selectByVisibleText(customParameterName); - } - $(String.format("input[name=\"customParams.%d.value\"]", customParametersElements.size() - 1)) - .setValue(customParameterValue); - return this; - } - - @Step - public TopicCreateEditForm updateCustomParameter(String customParameterName, - String customParameterValue) { - SelenideElement selenideElement = $$("ul[role=listbox][name^=customParams][name$=name]") - .find(Condition.exactText(customParameterName)); - String name = selenideElement.getAttribute("name"); - if (name != null) { - name = name.substring(0, name.lastIndexOf(".")); - } - $(String.format("input[name^=%s]", name)).setValue(customParameterValue); - return this; - } - - @Step - public String getCleanupPolicy() { - return new KafkaUISelectElement("cleanupPolicy").getCurrentValue(); - } - - @Step - public String getTimeToRetain() { - return timeToRetainField.getValue(); - } - - @Step - public String getMaxSizeOnDisk() { - return new KafkaUISelectElement("retentionBytes").getCurrentValue(); - } - - @Step - public String getMaxMessageBytes() { - return maxMessageBytesField.getValue(); - } - - @Step - public TopicCreateEditForm setMaxMessageBytes(Long bytes) { - maxMessageBytesField.setValue(bytes.toString()); - return this; - } - - @Step - public TopicCreateEditForm setMaxMessageBytes(String bytes) { - return setMaxMessageBytes(Long.parseLong(bytes)); - } - - @Step - public boolean isValidationMessageCustomParameterValueVisible() { - return isVisible(validationCustomParameterValueMsg); - } - - @Step - public String getCustomParameterValue() { - return customParameterValueField.getValue(); - } - - private TopicCreateEditForm selectFromDropDownByOptionValue(String dropDownElementName, - String optionValue) { - KafkaUISelectElement select = new KafkaUISelectElement(dropDownElementName); - select.selectByOptionValue(optionValue); - return this; - } - - private TopicCreateEditForm selectFromDropDownByVisibleText(String dropDownElementName, - String visibleText) { - KafkaUISelectElement select = new KafkaUISelectElement(dropDownElementName); - select.selectByVisibleText(visibleText); - return this; - } - - private static class KafkaUISelectElement { - - private final SelenideElement selectElement; - - public KafkaUISelectElement(String selectElementName) { - this.selectElement = $("ul[role=listbox][name=" + selectElementName + "]"); - } - - public KafkaUISelectElement(SelenideElement selectElement) { - this.selectElement = selectElement; - } - - public void selectByOptionValue(String optionValue) { - selectElement.click(); - selectElement - .$$x(".//ul/li[@role='option']") - .find(Condition.attribute("value", optionValue)) - .click(ClickOptions.usingJavaScript()); - } - - public void selectByVisibleText(String visibleText) { - selectElement.click(); - selectElement - .$$("ul>li[role=option]") - .find(Condition.exactText(visibleText)) - .click(); - } - - public String getCurrentValue() { - return selectElement.$("li").getText(); - } - } + protected SelenideElement timeToRetainField = $x("//input[@id='timeToRetain']"); + protected SelenideElement partitionsField = $x("//input[@name='partitions']"); + protected SelenideElement nameField = $(id("topicFormName")); + protected SelenideElement maxMessageBytesField = $x("//input[@name='maxMessageBytes']"); + protected SelenideElement minInSyncReplicasField = $x("//input[@name='minInSyncReplicas']"); + protected SelenideElement cleanUpPolicyDdl = $x("//ul[@id='topicFormCleanupPolicy']"); + protected SelenideElement maxSizeOnDiscDdl = $x("//ul[@id='topicFormRetentionBytes']"); + protected SelenideElement customParameterDdl = $x("//ul[contains(@name,'customParams')]"); + protected SelenideElement deleteCustomParameterBtn = $x("//span[contains(@title,'Delete customParam')]"); + protected SelenideElement addCustomParameterTypeBtn = $x("//button[contains(text(),'Add Custom Parameter')]"); + protected SelenideElement customParameterValueField = $x("//input[@placeholder='Value']"); + protected SelenideElement validationCustomParameterValueMsg = $x("//p[contains(text(),'Value is required')]"); + protected String ddlElementLocator = "//li[@value='%s']"; + protected String btnTimeToRetainLocator = "//button[@class][text()='%s']"; + + + @Step + public TopicCreateEditForm waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + nameField.shouldBe(Condition.visible); + return this; + } + + public boolean isCreateTopicButtonEnabled() { + return isEnabled(submitBtn); + } + + public boolean isDeleteCustomParameterButtonEnabled() { + return isEnabled(deleteCustomParameterBtn); + } + + public boolean isNameFieldEnabled() { + return isEnabled(nameField); + } + + @Step + public TopicCreateEditForm setTopicName(String topicName) { + sendKeysAfterClear(nameField, topicName); + return this; + } + + @Step + public TopicCreateEditForm setMinInsyncReplicas(Integer minInsyncReplicas) { + minInSyncReplicasField.setValue(minInsyncReplicas.toString()); + return this; + } + + @Step + public TopicCreateEditForm setTimeToRetainDataInMs(Long ms) { + timeToRetainField.setValue(ms.toString()); + return this; + } + + @Step + public TopicCreateEditForm setTimeToRetainDataInMs(String ms) { + timeToRetainField.setValue(ms); + return this; + } + + @Step + public TopicCreateEditForm setMaxSizeOnDiskInGB(MaxSizeOnDisk maxSizeOnDisk) { + maxSizeOnDiscDdl.shouldBe(Condition.visible).click(); + $x(String.format(ddlElementLocator, maxSizeOnDisk.getOptionValue())).shouldBe(Condition.visible).click(); + return this; + } + + @Step + public TopicCreateEditForm clickAddCustomParameterTypeButton() { + addCustomParameterTypeBtn.click(); + return this; + } + + @Step + public TopicCreateEditForm openCustomParameterTypeDdl() { + customParameterDdl.shouldBe(Condition.visible).click(); + ddlOptions.shouldHave(CollectionCondition.sizeGreaterThan(0)); + return this; + } + + @Step + public ElementsCollection getAllDdlOptions() { + return getDdlOptions(); + } + + @Step + public TopicCreateEditForm setCustomParameterType(CustomParameterType customParameterType) { + openCustomParameterTypeDdl(); + $x(String.format(ddlElementLocator, customParameterType.getOptionValue())).shouldBe(Condition.visible).click(); + return this; + } + + @Step + public TopicCreateEditForm clearCustomParameterValue() { + clearByKeyboard(customParameterValueField); + return this; + } + + @Step + public TopicCreateEditForm setNumberOfPartitions(int partitions) { + partitionsField.shouldBe(Condition.enabled).clear(); + partitionsField.sendKeys(String.valueOf(partitions)); + return this; + } + + @Step + public TopicCreateEditForm setTimeToRetainDataByButtons(TimeToRetain timeToRetain) { + $x(String.format(btnTimeToRetainLocator, timeToRetain.getButton())).shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public TopicCreateEditForm selectCleanupPolicy(CleanupPolicyValue cleanupPolicyOptionValue) { + cleanUpPolicyDdl.shouldBe(Condition.visible).click(); + $x(String.format(ddlElementLocator, cleanupPolicyOptionValue.getOptionValue())).shouldBe(Condition.visible).click(); + return this; + } + + @Step + public TopicCreateEditForm selectRetentionBytes(String visibleValue) { + return selectFromDropDownByVisibleText("retentionBytes", visibleValue); + } + + @Step + public TopicCreateEditForm selectRetentionBytes(Long optionValue) { + return selectFromDropDownByOptionValue("retentionBytes", optionValue.toString()); + } + + @Step + public TopicCreateEditForm clickSaveTopicBtn() { + clickSubmitBtn(); + return this; + } + + @Step + public TopicCreateEditForm addCustomParameter(String customParameterName, + String customParameterValue) { + ElementsCollection customParametersElements = + $$("ul[role=listbox][name^=customParams][name$=name]"); + KafkaUiSelectElement kafkaUiSelectElement = null; + if (customParametersElements.size() == 1) { + if ("Select".equals(customParametersElements.first().getText())) { + kafkaUiSelectElement = new KafkaUiSelectElement(customParametersElements.first()); + } + } else { + $$("button") + .find(Condition.exactText("Add Custom Parameter")) + .click(); + customParametersElements = $$("ul[role=listbox][name^=customParams][name$=name]"); + kafkaUiSelectElement = new KafkaUiSelectElement(customParametersElements.last()); + } + if (kafkaUiSelectElement != null) { + kafkaUiSelectElement.selectByVisibleText(customParameterName); + } + $(String.format("input[name=\"customParams.%d.value\"]", customParametersElements.size() - 1)) + .setValue(customParameterValue); + return this; + } + + @Step + public TopicCreateEditForm updateCustomParameter(String customParameterName, + String customParameterValue) { + SelenideElement selenideElement = $$("ul[role=listbox][name^=customParams][name$=name]") + .find(Condition.exactText(customParameterName)); + String name = selenideElement.getAttribute("name"); + if (name != null) { + name = name.substring(0, name.lastIndexOf(".")); + } + $(String.format("input[name^=%s]", name)).setValue(customParameterValue); + return this; + } + + @Step + public String getCleanupPolicy() { + return new KafkaUiSelectElement("cleanupPolicy").getCurrentValue(); + } + + @Step + public String getTimeToRetain() { + return timeToRetainField.getValue(); + } + + @Step + public String getMaxSizeOnDisk() { + return new KafkaUiSelectElement("retentionBytes").getCurrentValue(); + } + + @Step + public String getMaxMessageBytes() { + return maxMessageBytesField.getValue(); + } + + @Step + public TopicCreateEditForm setMaxMessageBytes(Long bytes) { + maxMessageBytesField.setValue(bytes.toString()); + return this; + } + + @Step + public TopicCreateEditForm setMaxMessageBytes(String bytes) { + return setMaxMessageBytes(Long.parseLong(bytes)); + } + + @Step + public boolean isValidationMessageCustomParameterValueVisible() { + return isVisible(validationCustomParameterValueMsg); + } + + @Step + public String getCustomParameterValue() { + return customParameterValueField.getValue(); + } + + private TopicCreateEditForm selectFromDropDownByOptionValue(String dropDownElementName, + String optionValue) { + KafkaUiSelectElement select = new KafkaUiSelectElement(dropDownElementName); + select.selectByOptionValue(optionValue); + return this; + } + + private TopicCreateEditForm selectFromDropDownByVisibleText(String dropDownElementName, + String visibleText) { + KafkaUiSelectElement select = new KafkaUiSelectElement(dropDownElementName); + select.selectByVisibleText(visibleText); + return this; + } + + private static class KafkaUiSelectElement { + + private final SelenideElement selectElement; + + public KafkaUiSelectElement(String selectElementName) { + this.selectElement = $("ul[role=listbox][name=" + selectElementName + "]"); + } + + public KafkaUiSelectElement(SelenideElement selectElement) { + this.selectElement = selectElement; + } + + public void selectByOptionValue(String optionValue) { + selectElement.click(); + selectElement + .$$x(".//ul/li[@role='option']") + .find(Condition.attribute("value", optionValue)) + .click(ClickOptions.usingJavaScript()); + } + + public void selectByVisibleText(String visibleText) { + selectElement.click(); + selectElement + .$$("ul>li[role=option]") + .find(Condition.exactText(visibleText)) + .click(); + } + + public String getCurrentValue() { + return selectElement.$("li").getText(); + } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicDetails.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicDetails.java index d9c010531..a171c728e 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicDetails.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicDetails.java @@ -1,462 +1,479 @@ package com.provectus.kafka.ui.pages.topics; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$$x; +import static com.codeborne.selenide.Selenide.$x; +import static com.codeborne.selenide.Selenide.sleep; +import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.OVERVIEW; +import static org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils.nextInt; + import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; - import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; -import java.util.*; - -import static com.codeborne.selenide.Selenide.*; -import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.OVERVIEW; -import static org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils.nextInt; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Objects; public class TopicDetails extends BasePage { - protected SelenideElement clearMessagesBtn = $x(("//div[contains(text(), 'Clear messages')]")); - protected SelenideElement recreateTopicBtn = $x("//div[text()='Recreate Topic']"); - protected SelenideElement messageAmountCell = $x("//tbody/tr/td[5]"); - protected SelenideElement seekTypeDdl = $x("//ul[@id='selectSeekType']/li"); - protected SelenideElement seekTypeField = $x("//label[text()='Seek Type']//..//div/input"); - protected SelenideElement addFiltersBtn = $x("//button[text()='Add Filters']"); - protected SelenideElement savedFiltersLink = $x("//div[text()='Saved Filters']"); - protected SelenideElement addFilterCodeModalTitle = $x("//label[text()='Filter code']"); - protected SelenideElement addFilterCodeInput = $x("//div[@id='ace-editor']//textarea"); - protected SelenideElement saveThisFilterCheckBoxAddFilterMdl = $x("//input[@name='saveFilter']"); - protected SelenideElement displayNameInputAddFilterMdl = $x("//input[@placeholder='Enter Name']"); - protected SelenideElement cancelBtnAddFilterMdl = $x("//button[text()='Cancel']"); - protected SelenideElement addFilterBtnAddFilterMdl = $x("//button[text()='Add filter']"); - protected SelenideElement addFiltersBtnMessages = $x("//button[text()='Add Filters']"); - protected SelenideElement selectFilterBtnAddFilterMdl = $x("//button[text()='Select filter']"); - protected SelenideElement editSettingsMenu = $x("//li[@role][contains(text(),'Edit settings')]"); - protected SelenideElement removeTopicBtn = $x("//ul[@role='menu']//div[contains(text(),'Remove Topic')]"); - protected SelenideElement produceMessageBtn = $x("//div//button[text()='Produce Message']"); - protected SelenideElement contentMessageTab = $x("//html//div[@id='root']/div/main//table//p"); - protected SelenideElement cleanUpPolicyField = $x("//div[contains(text(),'Clean Up Policy')]/../span/*"); - protected SelenideElement partitionsField = $x("//div[contains(text(),'Partitions')]/../span"); - protected SelenideElement backToCreateFiltersLink = $x("//div[text()='Back To create filters']"); - protected ElementsCollection messageGridItems = $$x("//tbody//tr"); - protected SelenideElement actualCalendarDate = $x("//div[@class='react-datepicker__current-month']"); - protected SelenideElement previousMonthButton = $x("//button[@aria-label='Previous Month']"); - protected SelenideElement nextMonthButton = $x("//button[@aria-label='Next Month']"); - protected SelenideElement calendarTimeFld = $x("//input[@placeholder='Time']"); - protected String detailsTabLtr = "//nav//a[contains(text(),'%s')]"; - protected String dayCellLtr = "//div[@role='option'][contains(text(),'%d')]"; - protected String seekFilterDdlLocator = "//ul[@id='selectSeekType']/ul/li[text()='%s']"; - protected String savedFilterNameLocator = "//div[@role='savedFilter']/div[contains(text(),'%s')]"; - protected String consumerIdLocator = "//a[@title='%s']"; - protected String topicHeaderLocator = "//h1[contains(text(),'%s')]"; - protected String activeFilterNameLocator = "//div[@data-testid='activeSmartFilter'][contains(text(),'%s')]"; - protected String settingsGridValueLocator = "//tbody/tr/td/span[text()='%s']//ancestor::tr/td[2]/span"; - - @Step - public TopicDetails waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - $x(String.format(detailsTabLtr, OVERVIEW)).shouldBe(Condition.visible); - return this; - } - - @Step - public TopicDetails openDetailsTab(TopicMenu menu) { - $x(String.format(detailsTabLtr, menu.toString())).shouldBe(Condition.enabled).click(); - waitUntilSpinnerDisappear(); - return this; - } - - @Step - public String getSettingsGridValueByKey(String key) { - return $x(String.format(settingsGridValueLocator, key)).scrollTo().shouldBe(Condition.visible).getText(); - } - - @Step - public TopicDetails openDotMenu() { - clickByJavaScript(dotMenuBtn); - return this; - } - - @Step - public boolean isAlertWithMessageVisible(AlertHeader header, String message) { - return isAlertVisible(header, message); - } - - @Step - public TopicDetails clickEditSettingsMenu() { - editSettingsMenu.shouldBe(Condition.visible).click(); - return this; - } - - @Step - public boolean isConfirmationMdlVisible() { - return isConfirmationModalVisible(); - } - - @Step - public TopicDetails clickClearMessagesMenu() { - clearMessagesBtn.shouldBe(Condition.visible).click(); - return this; - } + protected SelenideElement clearMessagesBtn = $x(("//div[contains(text(), 'Clear messages')]")); + protected SelenideElement recreateTopicBtn = $x("//div[text()='Recreate Topic']"); + protected SelenideElement messageAmountCell = $x("//tbody/tr/td[5]"); + protected SelenideElement overviewTab = $x("//a[contains(text(),'Overview')]"); + protected SelenideElement messagesTab = $x("//a[contains(text(),'Messages')]"); + protected SelenideElement seekTypeDdl = $x("//ul[@id='selectSeekType']//li"); + protected SelenideElement seekTypeField = $x("//label[text()='Seek Type']//..//div/input"); + protected SelenideElement addFiltersBtn = $x("//button[text()='Add Filters']"); + protected SelenideElement savedFiltersLink = $x("//div[text()='Saved Filters']"); + protected SelenideElement addFilterCodeModalTitle = $x("//label[text()='Filter code']"); + protected SelenideElement addFilterCodeInput = $x("//div[@id='ace-editor']//textarea"); + protected SelenideElement saveThisFilterCheckBoxAddFilterMdl = $x("//input[@name='saveFilter']"); + protected SelenideElement displayNameInputAddFilterMdl = $x("//input[@placeholder='Enter Name']"); + protected SelenideElement cancelBtnAddFilterMdl = $x("//button[text()='Cancel']"); + protected SelenideElement addFilterBtnAddFilterMdl = $x("//button[text()='Add filter']"); + protected SelenideElement addFiltersBtnMessages = $x("//button[text()='Add Filters']"); + protected SelenideElement selectFilterBtnAddFilterMdl = $x("//button[text()='Select filter']"); + protected SelenideElement editSettingsMenu = $x("//li[@role][contains(text(),'Edit settings')]"); + protected SelenideElement removeTopicBtn = $x("//ul[@role='menu']//div[contains(text(),'Remove Topic')]"); + protected SelenideElement produceMessageBtn = $x("//div//button[text()='Produce Message']"); + protected SelenideElement contentMessageTab = $x("//html//div[@id='root']/div/main//table//p"); + protected SelenideElement cleanUpPolicyField = $x("//div[contains(text(),'Clean Up Policy')]/../span/*"); + protected SelenideElement partitionsField = $x("//div[contains(text(),'Partitions')]/../span"); + protected SelenideElement backToCreateFiltersLink = $x("//div[text()='Back To create filters']"); + protected ElementsCollection messageGridItems = $$x("//tbody//tr"); + protected SelenideElement actualCalendarDate = $x("//div[@class='react-datepicker__current-month']"); + protected SelenideElement previousMonthButton = $x("//button[@aria-label='Previous Month']"); + protected SelenideElement nextMonthButton = $x("//button[@aria-label='Next Month']"); + protected SelenideElement calendarTimeFld = $x("//input[@placeholder='Time']"); + protected String detailsTabLtr = "//nav//a[contains(text(),'%s')]"; + protected String dayCellLtr = "//div[@role='option'][contains(text(),'%d')]"; + protected String seekFilterDdlLocator = "//ul[@id='selectSeekType']/ul/li[text()='%s']"; + protected String savedFilterNameLocator = "//div[@role='savedFilter']/div[contains(text(),'%s')]"; + protected String consumerIdLocator = "//a[@title='%s']"; + protected String topicHeaderLocator = "//h1[contains(text(),'%s')]"; + protected String activeFilterNameLocator = "//div[@data-testid='activeSmartFilter'][contains(text(),'%s')]"; + protected String settingsGridValueLocator = "//tbody/tr/td/span[text()='%s']//ancestor::tr/td[2]/span"; + + @Step + public TopicDetails waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + $x(String.format(detailsTabLtr, OVERVIEW)).shouldBe(Condition.visible); + return this; + } + + @Step + public TopicDetails openDetailsTab(TopicMenu menu) { + $x(String.format(detailsTabLtr, menu.toString())).shouldBe(Condition.enabled).click(); + waitUntilSpinnerDisappear(); + return this; + } + + @Step + public String getSettingsGridValueByKey(String key) { + return $x(String.format(settingsGridValueLocator, key)).scrollTo().shouldBe(Condition.visible).getText(); + } + + @Step + public TopicDetails openDotMenu() { + clickByJavaScript(dotMenuBtn); + return this; + } + + @Step + public boolean isAlertWithMessageVisible(AlertHeader header, String message) { + return isAlertVisible(header, message); + } + + @Step + public TopicDetails clickEditSettingsMenu() { + editSettingsMenu.shouldBe(Condition.visible).click(); + return this; + } + + @Step + public boolean isConfirmationMdlVisible() { + return isConfirmationModalVisible(); + } + + @Step + public TopicDetails clickClearMessagesMenu() { + clearMessagesBtn.shouldBe(Condition.visible).click(); + return this; + } + + @Step + public boolean isClearMessagesMenuEnabled() { + return !Objects.requireNonNull(clearMessagesBtn.shouldBe(Condition.visible) + .$x("./..").getAttribute("class")) + .contains("disabled"); + } + + @Step + public TopicDetails clickRecreateTopicMenu() { + recreateTopicBtn.shouldBe(Condition.visible).click(); + return this; + } + + @Step + public String getCleanUpPolicy() { + return cleanUpPolicyField.getText(); + } + + @Step + public int getPartitions() { + return Integer.parseInt(partitionsField.getText().trim()); + } + + @Step + public boolean isTopicHeaderVisible(String topicName) { + return isVisible($x(String.format(topicHeaderLocator, topicName))); + } + + @Step + public TopicDetails clickDeleteTopicMenu() { + removeTopicBtn.shouldBe(Condition.visible).click(); + return this; + } + + @Step + public TopicDetails clickConfirmBtnMdl() { + clickConfirmButton(); + return this; + } + + @Step + public TopicDetails clickProduceMessageBtn() { + clickByJavaScript(produceMessageBtn); + return this; + } + + @Step + public TopicDetails selectSeekTypeDdlMessagesTab(String seekTypeName) { + seekTypeDdl.shouldBe(Condition.enabled).click(); + $x(String.format(seekFilterDdlLocator, seekTypeName)).shouldBe(Condition.visible).click(); + return this; + } + + @Step + public TopicDetails setSeekTypeValueFldMessagesTab(String seekTypeValue) { + seekTypeField.shouldBe(Condition.enabled).sendKeys(seekTypeValue); + return this; + } + + @Step + public TopicDetails clickSubmitFiltersBtnMessagesTab() { + clickByJavaScript(submitBtn); + waitUntilSpinnerDisappear(); + return this; + } + + @Step + public TopicDetails clickMessagesAddFiltersBtn() { + addFiltersBtn.shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public TopicDetails clickNextButton() { + nextBtn.shouldBe(Condition.enabled).click(); + waitUntilSpinnerDisappear(); + return this; + } + + @Step + public TopicDetails openSavedFiltersListMdl() { + savedFiltersLink.shouldBe(Condition.enabled).click(); + backToCreateFiltersLink.shouldBe(Condition.visible); + return this; + } + + @Step + public boolean isFilterVisibleAtSavedFiltersMdl(String filterName) { + return isVisible($x(String.format(savedFilterNameLocator, filterName))); + } + + @Step + public TopicDetails selectFilterAtSavedFiltersMdl(String filterName) { + $x(String.format(savedFilterNameLocator, filterName)).shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public TopicDetails clickSelectFilterBtnAtSavedFiltersMdl() { + selectFilterBtnAddFilterMdl.shouldBe(Condition.enabled).click(); + addFilterCodeModalTitle.shouldBe(Condition.disappear); + return this; + } + + @Step + public TopicDetails waitUntilAddFiltersMdlVisible() { + addFilterCodeModalTitle.shouldBe(Condition.visible); + return this; + } + + @Step + public TopicDetails setFilterCodeFieldAddFilterMdl(String filterCode) { + addFilterCodeInput.shouldBe(Condition.enabled).sendKeys(filterCode); + return this; + } + + @Step + public TopicDetails selectSaveThisFilterCheckboxMdl(boolean select) { + selectElement(saveThisFilterCheckBoxAddFilterMdl, select); + return this; + } + + @Step + public boolean isSaveThisFilterCheckBoxSelected() { + return isSelected(saveThisFilterCheckBoxAddFilterMdl); + } + + @Step + public TopicDetails setDisplayNameFldAddFilterMdl(String displayName) { + displayNameInputAddFilterMdl.shouldBe(Condition.enabled).sendKeys(displayName); + return this; + } + + @Step + public TopicDetails clickAddFilterBtnAndCloseMdl(boolean closeModal) { + addFilterBtnAddFilterMdl.shouldBe(Condition.enabled).click(); + if (closeModal) { + addFilterCodeModalTitle.shouldBe(Condition.hidden); + } else { + addFilterCodeModalTitle.shouldBe(Condition.visible); + } + return this; + } + + @Step + public boolean isAddFilterBtnAddFilterMdlEnabled() { + return isEnabled(addFilterBtnAddFilterMdl); + } + + @Step + public boolean isBackButtonEnabled() { + return isEnabled(backBtn); + } + + @Step + public boolean isNextButtonEnabled() { + return isEnabled(nextBtn); + } + + @Step + public boolean isActiveFilterVisible(String activeFilterName) { + return isVisible($x(String.format(activeFilterNameLocator, activeFilterName))); + } + + public List getAllAddFilterModalVisibleElements() { + return Arrays.asList(savedFiltersLink, displayNameInputAddFilterMdl, addFilterBtnAddFilterMdl, + cancelBtnAddFilterMdl); + } + + public List getAllAddFilterModalEnabledElements() { + return Arrays.asList(displayNameInputAddFilterMdl, cancelBtnAddFilterMdl); + } + + public List getAllAddFilterModalDisabledElements() { + return Collections.singletonList(addFilterBtnAddFilterMdl); + } + + @Step + public TopicDetails openConsumerGroup(String consumerId) { + $x(String.format(consumerIdLocator, consumerId)).click(); + return this; + } + + @Step + public boolean isKeyMessageVisible(String keyMessage) { + return keyMessage.equals($("td[title]").getText()); + } + + @Step + public boolean isContentMessageVisible(String contentMessage) { + return contentMessage.matches(contentMessageTab.getText().trim()); + } + + private void selectYear(int expectedYear) { + while (getActualCalendarDate().getYear() > expectedYear) { + clickByJavaScript(previousMonthButton); + sleep(1000); + if (LocalTime.now().plusMinutes(3).isBefore(LocalTime.now())) { + throw new IllegalArgumentException("Unable to select year"); + } + } + } + + private void selectMonth(int expectedMonth) { + while (getActualCalendarDate().getMonthValue() > expectedMonth) { + clickByJavaScript(previousMonthButton); + sleep(1000); + if (LocalTime.now().plusMinutes(3).isBefore(LocalTime.now())) { + throw new IllegalArgumentException("Unable to select month"); + } + } + } + + private void selectDay(int expectedDay) { + Objects.requireNonNull($$x(String.format(dayCellLtr, expectedDay)).stream() + .filter(day -> !Objects.requireNonNull(day.getAttribute("class")).contains("outside-month")) + .findFirst().orElseThrow()).shouldBe(Condition.enabled).click(); + } + + private void setTime(LocalDateTime dateTime) { + calendarTimeFld.shouldBe(Condition.enabled) + .sendKeys(String.valueOf(dateTime.getHour()), String.valueOf(dateTime.getMinute())); + } + + @Step + public TopicDetails selectDateAndTimeByCalendar(LocalDateTime dateTime) { + setTime(dateTime); + selectYear(dateTime.getYear()); + selectMonth(dateTime.getMonthValue()); + selectDay(dateTime.getDayOfMonth()); + return this; + } - @Step - public TopicDetails clickRecreateTopicMenu() { - recreateTopicBtn.shouldBe(Condition.visible).click(); - return this; - } + private LocalDate getActualCalendarDate() { + String monthAndYearStr = actualCalendarDate.getText().trim(); + DateTimeFormatter formatter = new DateTimeFormatterBuilder() + .parseCaseInsensitive() + .append(DateTimeFormatter.ofPattern("MMMM yyyy")) + .toFormatter(Locale.ENGLISH); + YearMonth yearMonth = formatter.parse(monthAndYearStr, YearMonth::from); + return yearMonth.atDay(1); + } - @Step - public String getCleanUpPolicy() { - return cleanUpPolicyField.getText(); - } + @Step + public TopicDetails openCalendarSeekType() { + seekTypeField.shouldBe(Condition.enabled).click(); + actualCalendarDate.shouldBe(Condition.visible); + return this; + } - @Step - public int getPartitions() { - return Integer.parseInt(partitionsField.getText().trim()); - } + @Step + public int getMessageCountAmount() { + return Integer.parseInt(messageAmountCell.getText().trim()); + } - @Step - public boolean isTopicHeaderVisible(String topicName) { - return isVisible($x(String.format(topicHeaderLocator, topicName))); - } + private List initItems() { + List gridItemList = new ArrayList<>(); + gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) + .forEach(item -> gridItemList.add(new TopicDetails.MessageGridItem(item))); + return gridItemList; + } - @Step - public TopicDetails clickDeleteTopicMenu() { - removeTopicBtn.shouldBe(Condition.visible).click(); - return this; - } + @Step + public TopicDetails.MessageGridItem getMessageByOffset(int offset) { + return initItems().stream() + .filter(e -> e.getOffset() == offset) + .findFirst().orElseThrow(); + } - @Step - public TopicDetails clickConfirmBtnMdl() { - clickConfirmButton(); - return this; - } + @Step + public List getAllMessages() { + return initItems(); + } - @Step - public TopicDetails clickProduceMessageBtn() { - clickByJavaScript(produceMessageBtn); - return this; - } + @Step + public TopicDetails.MessageGridItem getRandomMessage() { + return getMessageByOffset(nextInt(0, initItems().size() - 1)); + } - @Step - public TopicDetails selectSeekTypeDdlMessagesTab(String seekTypeName) { - seekTypeDdl.shouldBe(Condition.enabled).click(); - $x(String.format(seekFilterDdlLocator, seekTypeName)).shouldBe(Condition.visible).click(); - return this; - } + public enum TopicMenu { + OVERVIEW("Overview"), + MESSAGES("Messages"), + CONSUMERS("Consumers"), + SETTINGS("Settings"); - @Step - public TopicDetails setSeekTypeValueFldMessagesTab(String seekTypeValue) { - seekTypeField.shouldBe(Condition.enabled).sendKeys(seekTypeValue); - return this; - } + private final String value; - @Step - public TopicDetails clickSubmitFiltersBtnMessagesTab() { - clickByJavaScript(submitBtn); - waitUntilSpinnerDisappear(); - return this; + TopicMenu(String value) { + this.value = value; } - @Step - public TopicDetails clickMessagesAddFiltersBtn() { - addFiltersBtn.shouldBe(Condition.enabled).click(); - return this; + public String toString() { + return value; } + } - @Step - public TopicDetails clickNextButton() { - nextBtn.shouldBe(Condition.enabled).click(); - waitUntilSpinnerDisappear(); - return this; - } + public static class MessageGridItem extends BasePage { - @Step - public TopicDetails openSavedFiltersListMdl() { - savedFiltersLink.shouldBe(Condition.enabled).click(); - backToCreateFiltersLink.shouldBe(Condition.visible); - return this; - } + private final SelenideElement element; - @Step - public boolean isFilterVisibleAtSavedFiltersMdl(String filterName) { - return isVisible($x(String.format(savedFilterNameLocator, filterName))); + private MessageGridItem(SelenideElement element) { + this.element = element; } @Step - public TopicDetails selectFilterAtSavedFiltersMdl(String filterName) { - $x(String.format(savedFilterNameLocator, filterName)).shouldBe(Condition.enabled).click(); - return this; + public MessageGridItem clickExpand() { + clickByJavaScript(element.$x("./td[1]/span")); + return this; } - @Step - public TopicDetails clickSelectFilterBtnAtSavedFiltersMdl() { - selectFilterBtnAddFilterMdl.shouldBe(Condition.enabled).click(); - addFilterCodeModalTitle.shouldBe(Condition.disappear); - return this; + private SelenideElement getOffsetElm() { + return element.$x("./td[2]"); } @Step - public TopicDetails waitUntilAddFiltersMdlVisible() { - addFilterCodeModalTitle.shouldBe(Condition.visible); - return this; + public int getOffset() { + return Integer.parseInt(getOffsetElm().getText().trim()); } @Step - public TopicDetails setFilterCodeFieldAddFilterMdl(String filterCode) { - addFilterCodeInput.shouldBe(Condition.enabled).sendKeys(filterCode); - return this; + public int getPartition() { + return Integer.parseInt(element.$x("./td[3]").getText().trim()); } @Step - public TopicDetails selectSaveThisFilterCheckboxMdl(boolean select) { - selectElement(saveThisFilterCheckBoxAddFilterMdl, select); - return this; + public LocalDateTime getTimestamp() { + String timestampValue = element.$x("./td[4]/div").getText().trim(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy, HH:mm:ss"); + return LocalDateTime.parse(timestampValue, formatter); } @Step - public boolean isSaveThisFilterCheckBoxSelected() { - return isSelected(saveThisFilterCheckBoxAddFilterMdl); + public String getKey() { + return element.$x("./td[5]").getText().trim(); } @Step - public TopicDetails setDisplayNameFldAddFilterMdl(String displayName) { - displayNameInputAddFilterMdl.shouldBe(Condition.enabled).sendKeys(displayName); - return this; + public String getValue() { + return element.$x("./td[6]/span/p").getText().trim(); } @Step - public TopicDetails clickAddFilterBtnAndCloseMdl(boolean closeModal) { - addFilterBtnAddFilterMdl.shouldBe(Condition.enabled).click(); - if (closeModal) { - addFilterCodeModalTitle.shouldBe(Condition.hidden); - } else { - addFilterCodeModalTitle.shouldBe(Condition.visible); - } - return this; + public MessageGridItem openDotMenu() { + getOffsetElm().hover(); + element.$x("./td[7]/div/button[@aria-label='Dropdown Toggle']") + .shouldBe(Condition.visible).click(); + return this; } @Step - public boolean isAddFilterBtnAddFilterMdlEnabled() { - return isEnabled(addFilterBtnAddFilterMdl); + public MessageGridItem clickCopyToClipBoard() { + clickByJavaScript(element.$x("./td[7]//li[text() = 'Copy to clipboard']") + .shouldBe(Condition.visible)); + return this; } @Step - public boolean isBackButtonEnabled() { - return isEnabled(backBtn); - } - - @Step - public boolean isNextButtonEnabled() { - return isEnabled(nextBtn); - } - - @Step - public boolean isActiveFilterVisible(String activeFilterName) { - return isVisible($x(String.format(activeFilterNameLocator, activeFilterName))); - } - - public List getAllAddFilterModalVisibleElements() { - return Arrays.asList(savedFiltersLink, displayNameInputAddFilterMdl, addFilterBtnAddFilterMdl, cancelBtnAddFilterMdl); - } - - public List getAllAddFilterModalEnabledElements() { - return Arrays.asList(displayNameInputAddFilterMdl, cancelBtnAddFilterMdl); - } - - public List getAllAddFilterModalDisabledElements() { - return Collections.singletonList(addFilterBtnAddFilterMdl); - } - - @Step - public TopicDetails openConsumerGroup(String consumerId) { - $x(String.format(consumerIdLocator, consumerId)).click(); - return this; - } - - @Step - public boolean isKeyMessageVisible(String keyMessage) { - return keyMessage.equals($("td[title]").getText()); - } - - @Step - public boolean isContentMessageVisible(String contentMessage) { - return contentMessage.matches(contentMessageTab.getText().trim()); - } - - private void selectYear(int expectedYear) { - while (getActualCalendarDate().getYear() > expectedYear) { - clickByJavaScript(previousMonthButton); - sleep(1000); - if (LocalTime.now().plusMinutes(3).isBefore(LocalTime.now())) { - throw new IllegalArgumentException("Unable to select year"); - } - } - } - - private void selectMonth(int expectedMonth) { - while (getActualCalendarDate().getMonthValue() > expectedMonth) { - clickByJavaScript(previousMonthButton); - sleep(1000); - if (LocalTime.now().plusMinutes(3).isBefore(LocalTime.now())) { - throw new IllegalArgumentException("Unable to select month"); - } - } - } - - private void selectDay(int expectedDay) { - Objects.requireNonNull($$x(String.format(dayCellLtr, expectedDay)).stream() - .filter(day -> !Objects.requireNonNull(day.getAttribute("class")).contains("outside-month")) - .findFirst().orElseThrow()).shouldBe(Condition.enabled).click(); - } - - private void setTime(LocalDateTime dateTime) { - calendarTimeFld.shouldBe(Condition.enabled) - .sendKeys(String.valueOf(dateTime.getHour()), String.valueOf(dateTime.getMinute())); - } - - @Step - public TopicDetails selectDateAndTimeByCalendar(LocalDateTime dateTime) { - setTime(dateTime); - selectYear(dateTime.getYear()); - selectMonth(dateTime.getMonthValue()); - selectDay(dateTime.getDayOfMonth()); - return this; - } - - private LocalDate getActualCalendarDate() { - String monthAndYearStr = actualCalendarDate.getText().trim(); - DateTimeFormatter formatter = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(DateTimeFormatter.ofPattern("MMMM yyyy")) - .toFormatter(Locale.ENGLISH); - YearMonth yearMonth = formatter.parse(monthAndYearStr, YearMonth::from); - return yearMonth.atDay(1); - } - - @Step - public TopicDetails openCalendarSeekType() { - seekTypeField.shouldBe(Condition.enabled).click(); - actualCalendarDate.shouldBe(Condition.visible); - return this; - } - - @Step - public int getMessageCountAmount() { - return Integer.parseInt(messageAmountCell.getText().trim()); - } - - private List initItems() { - List gridItemList = new ArrayList<>(); - gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) - .forEach(item -> gridItemList.add(new TopicDetails.MessageGridItem(item))); - return gridItemList; - } - - @Step - public TopicDetails.MessageGridItem getMessageByOffset(int offset) { - return initItems().stream() - .filter(e -> e.getOffset() == offset) - .findFirst().orElseThrow(); - } - - @Step - public List getAllMessages() { - return initItems(); - } - - @Step - public TopicDetails.MessageGridItem getRandomMessage() { - return getMessageByOffset(nextInt(0, initItems().size() - 1)); - } - - public enum TopicMenu { - OVERVIEW("Overview"), - MESSAGES("Messages"), - CONSUMERS("Consumers"), - SETTINGS("Settings"); - - private final String value; - - TopicMenu(String value) { - this.value = value; - } - - public String toString() { - return value; - } - } - - public static class MessageGridItem extends BasePage { - - private final SelenideElement element; - - private MessageGridItem(SelenideElement element) { - this.element = element; - } - - @Step - public MessageGridItem clickExpand() { - clickByJavaScript(element.$x("./td[1]/span")); - return this; - } - - private SelenideElement getOffsetElm() { - return element.$x("./td[2]"); - } - - @Step - public int getOffset() { - return Integer.parseInt(getOffsetElm().getText().trim()); - } - - @Step - public int getPartition() { - return Integer.parseInt(element.$x("./td[3]").getText().trim()); - } - - @Step - public LocalDateTime getTimestamp() { - String timestampValue = element.$x("./td[4]/div").getText().trim(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy, HH:mm:ss"); - return LocalDateTime.parse(timestampValue, formatter); - } - - @Step - public String getKey() { - return element.$x("./td[5]").getText().trim(); - } - - @Step - public String getValue() { - return element.$x("./td[6]/span/p").getText().trim(); - } - - @Step - public MessageGridItem openDotMenu() { - getOffsetElm().hover(); - element.$x("./td[7]/div/button[@aria-label='Dropdown Toggle']") - .shouldBe(Condition.visible).click(); - return this; - } - - @Step - public MessageGridItem clickCopyToClipBoard() { - clickByJavaScript(element.$x("./td[7]//li[text() = 'Copy to clipboard']") - .shouldBe(Condition.visible)); - return this; - } - - @Step - public MessageGridItem clickSaveAsFile() { - clickByJavaScript(element.$x("./td[7]//li[text() = 'Save as a file']") - .shouldBe(Condition.visible)); - return this; - } + public MessageGridItem clickSaveAsFile() { + clickByJavaScript(element.$x("./td[7]//li[text() = 'Save as a file']") + .shouldBe(Condition.visible)); + return this; } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicSettingsTab.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicSettingsTab.java index 3c0fcac21..c36e84237 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicSettingsTab.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicSettingsTab.java @@ -1,66 +1,65 @@ package com.provectus.kafka.ui.pages.topics; +import static com.codeborne.selenide.Selenide.$x; + import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; - import java.util.ArrayList; import java.util.List; -import static com.codeborne.selenide.Selenide.$x; - public class TopicSettingsTab extends BasePage { - protected SelenideElement defaultValueColumnHeaderLocator = $x("//div[text() = 'Default Value']"); + protected SelenideElement defaultValueColumnHeaderLocator = $x("//div[text() = 'Default Value']"); - @Step - public TopicSettingsTab waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - defaultValueColumnHeaderLocator.shouldBe(Condition.visible); - return this; - } + @Step + public TopicSettingsTab waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + defaultValueColumnHeaderLocator.shouldBe(Condition.visible); + return this; + } - private List initGridItems() { - List gridItemList = new ArrayList<>(); - gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) - .forEach(item -> gridItemList.add(new SettingsGridItem(item))); - return gridItemList; - } + private List initGridItems() { + List gridItemList = new ArrayList<>(); + gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) + .forEach(item -> gridItemList.add(new SettingsGridItem(item))); + return gridItemList; + } - private TopicSettingsTab.SettingsGridItem getItemByKey(String key) { - return initGridItems().stream() - .filter(e -> e.getKey().equals(key)) - .findFirst().orElseThrow(); - } + private TopicSettingsTab.SettingsGridItem getItemByKey(String key) { + return initGridItems().stream() + .filter(e -> e.getKey().equals(key)) + .findFirst().orElseThrow(); + } - @Step - public String getValueByKey(String key) { - return getItemByKey(key).getValue(); - } + @Step + public String getValueByKey(String key) { + return getItemByKey(key).getValue(); + } - public static class SettingsGridItem extends BasePage { + public static class SettingsGridItem extends BasePage { - private final SelenideElement element; + private final SelenideElement element; - public SettingsGridItem(SelenideElement element) { - this.element = element; - } + public SettingsGridItem(SelenideElement element) { + this.element = element; + } - @Step - public String getKey() { - return element.$x("./td[1]/span").getText().trim(); - } + @Step + public String getKey() { + return element.$x("./td[1]/span").getText().trim(); + } - @Step - public String getValue() { - return element.$x("./td[2]/span").getText().trim(); - } + @Step + public String getValue() { + return element.$x("./td[2]/span").getText().trim(); + } - @Step - public String getDefaultValue() { - return element.$x("./td[3]/span").getText().trim(); - } + @Step + public String getDefaultValue() { + return element.$x("./td[3]/span").getText().trim(); } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicsList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicsList.java index 538f714e8..184178423 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicsList.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/TopicsList.java @@ -1,282 +1,283 @@ package com.provectus.kafka.ui.pages.topics; +import static com.codeborne.selenide.Condition.visible; +import static com.codeborne.selenide.Selenide.$x; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.TOPICS; + import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.provectus.kafka.ui.pages.BasePage; import io.qameta.allure.Step; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$x; -import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.TOPICS; - public class TopicsList extends BasePage { - protected SelenideElement addTopicBtn = $x("//button[normalize-space(text()) ='Add a Topic']"); - protected SelenideElement searchField = $x("//input[@placeholder='Search by Topic Name']"); - protected SelenideElement showInternalRadioBtn = $x("//input[@name='ShowInternalTopics']"); - protected SelenideElement deleteSelectedTopicsBtn = $x("//button[text()='Delete selected topics']"); - protected SelenideElement copySelectedTopicBtn = $x("//button[text()='Copy selected topic']"); - protected SelenideElement purgeMessagesOfSelectedTopicsBtn = $x("//button[text()='Purge messages of selected topics']"); - protected SelenideElement clearMessagesBtn = $x("//ul[contains(@class ,'open')]//div[text()='Clear Messages']"); - protected SelenideElement recreateTopicBtn = $x("//ul[contains(@class ,'open')]//div[text()='Recreate Topic']"); - protected SelenideElement removeTopicBtn = $x("//ul[contains(@class ,'open')]//div[text()='Remove Topic']"); - - @Step - public TopicsList waitUntilScreenReady() { - waitUntilSpinnerDisappear(); - getPageTitleFromHeader(TOPICS).shouldBe(visible); - return this; - } - - @Step - public TopicsList clickAddTopicBtn() { - clickByJavaScript(addTopicBtn); - return this; - } - - @Step - public boolean isTopicVisible(String topicName) { - tableGrid.shouldBe(visible); - return isVisible(getTableElement(topicName)); - } - - @Step - public boolean isShowInternalRadioBtnSelected() { - return isSelected(showInternalRadioBtn); - } - - @Step - public TopicsList setShowInternalRadioButton(boolean select) { - if (select) { - if (!showInternalRadioBtn.isSelected()) { - clickByJavaScript(showInternalRadioBtn); - waitUntilSpinnerDisappear(1); - } - } else { - if (showInternalRadioBtn.isSelected()) { - clickByJavaScript(showInternalRadioBtn); - waitUntilSpinnerDisappear(1); - } - } - return this; - } - - @Step - public TopicsList openTopic(String topicName) { - getTopicItem(topicName).openItem(); - return this; - } - - @Step - public TopicsList openDotMenuByTopicName(String topicName) { - getTopicItem(topicName).openDotMenu(); - return this; + protected SelenideElement addTopicBtn = $x("//button[normalize-space(text()) ='Add a Topic']"); + protected SelenideElement searchField = $x("//input[@placeholder='Search by Topic Name']"); + protected SelenideElement showInternalRadioBtn = $x("//input[@name='ShowInternalTopics']"); + protected SelenideElement deleteSelectedTopicsBtn = $x("//button[text()='Delete selected topics']"); + protected SelenideElement copySelectedTopicBtn = $x("//button[text()='Copy selected topic']"); + protected SelenideElement purgeMessagesOfSelectedTopicsBtn = + $x("//button[text()='Purge messages of selected topics']"); + protected SelenideElement clearMessagesBtn = $x("//ul[contains(@class ,'open')]//div[text()='Clear Messages']"); + protected SelenideElement recreateTopicBtn = $x("//ul[contains(@class ,'open')]//div[text()='Recreate Topic']"); + protected SelenideElement removeTopicBtn = $x("//ul[contains(@class ,'open')]//div[text()='Remove Topic']"); + + @Step + public TopicsList waitUntilScreenReady() { + waitUntilSpinnerDisappear(); + getPageTitleFromHeader(TOPICS).shouldBe(visible); + return this; + } + + @Step + public TopicsList clickAddTopicBtn() { + clickByJavaScript(addTopicBtn); + return this; + } + + @Step + public boolean isTopicVisible(String topicName) { + tableGrid.shouldBe(visible); + return isVisible(getTableElement(topicName)); + } + + @Step + public boolean isShowInternalRadioBtnSelected() { + return isSelected(showInternalRadioBtn); + } + + @Step + public TopicsList setShowInternalRadioButton(boolean select) { + if (select) { + if (!showInternalRadioBtn.isSelected()) { + clickByJavaScript(showInternalRadioBtn); + waitUntilSpinnerDisappear(1); + } + } else { + if (showInternalRadioBtn.isSelected()) { + clickByJavaScript(showInternalRadioBtn); + waitUntilSpinnerDisappear(1); + } } - - @Step - public boolean isCopySelectedTopicBtnEnabled() { - return isEnabled(copySelectedTopicBtn); + return this; + } + + @Step + public TopicsList openTopic(String topicName) { + getTopicItem(topicName).openItem(); + return this; + } + + @Step + public TopicsList openDotMenuByTopicName(String topicName) { + getTopicItem(topicName).openDotMenu(); + return this; + } + + @Step + public boolean isCopySelectedTopicBtnEnabled() { + return isEnabled(copySelectedTopicBtn); + } + + @Step + public List getActionButtons() { + return Stream.of(deleteSelectedTopicsBtn, copySelectedTopicBtn, purgeMessagesOfSelectedTopicsBtn) + .collect(Collectors.toList()); + } + + @Step + public TopicsList clickCopySelectedTopicBtn() { + copySelectedTopicBtn.shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public TopicsList clickPurgeMessagesOfSelectedTopicsBtn() { + purgeMessagesOfSelectedTopicsBtn.shouldBe(Condition.enabled).click(); + return this; + } + + @Step + public TopicsList clickClearMessagesBtn() { + clickByJavaScript(clearMessagesBtn.shouldBe(visible)); + return this; + } + + @Step + public TopicsList clickRecreateTopicBtn() { + clickByJavaScript(recreateTopicBtn.shouldBe(visible)); + return this; + } + + @Step + public TopicsList clickRemoveTopicBtn() { + clickByJavaScript(removeTopicBtn.shouldBe(visible)); + return this; + } + + @Step + public TopicsList clickConfirmBtnMdl() { + clickConfirmButton(); + return this; + } + + @Step + public TopicsList clickCancelBtnMdl() { + clickCancelButton(); + return this; + } + + @Step + public boolean isConfirmationMdlVisible() { + return isConfirmationModalVisible(); + } + + @Step + public boolean isAlertWithMessageVisible(AlertHeader header, String message) { + return isAlertVisible(header, message); + } + + private List getVisibleColumnHeaders() { + return Stream.of("Replication Factor", "Number of messages", "Topic Name", "Partitions", "Out of sync replicas", + "Size") + .map(name -> $x(String.format(columnHeaderLocator, name))) + .collect(Collectors.toList()); + } + + private List getEnabledColumnHeaders() { + return Stream.of("Topic Name", "Partitions", "Out of sync replicas", "Size") + .map(name -> $x(String.format(columnHeaderLocator, name))) + .collect(Collectors.toList()); + } + + @Step + public List getAllVisibleElements() { + List visibleElements = new ArrayList<>(getVisibleColumnHeaders()); + visibleElements.addAll(Arrays.asList(searchField, addTopicBtn, tableGrid)); + visibleElements.addAll(getActionButtons()); + return visibleElements; + } + + @Step + public List getAllEnabledElements() { + List enabledElements = new ArrayList<>(getEnabledColumnHeaders()); + enabledElements.addAll(Arrays.asList(searchField, showInternalRadioBtn, addTopicBtn)); + return enabledElements; + } + + private List initGridItems() { + List gridItemList = new ArrayList<>(); + gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) + .forEach(item -> gridItemList.add(new TopicGridItem(item))); + return gridItemList; + } + + @Step + public TopicGridItem getTopicItem(String name) { + TopicGridItem topicGridItem = initGridItems().stream() + .filter(e -> e.getName().equals(name)) + .findFirst().orElse(null); + if (topicGridItem == null) { + searchItem(name); + topicGridItem = initGridItems().stream() + .filter(e -> e.getName().equals(name)) + .findFirst().orElseThrow(); } - - @Step - public List getActionButtons() { - return Stream.of(deleteSelectedTopicsBtn, copySelectedTopicBtn, purgeMessagesOfSelectedTopicsBtn) - .collect(Collectors.toList()); + return topicGridItem; + } + + @Step + public TopicGridItem getAnyNonInternalTopic() { + return getNonInternalTopics().stream() + .findAny().orElseThrow(); + } + + @Step + public List getNonInternalTopics() { + return initGridItems().stream() + .filter(e -> !e.isInternal()) + .collect(Collectors.toList()); + } + + @Step + public List getInternalTopics() { + return initGridItems().stream() + .filter(TopicGridItem::isInternal) + .collect(Collectors.toList()); + } + + public static class TopicGridItem extends BasePage { + + private final SelenideElement element; + + public TopicGridItem(SelenideElement element) { + this.element = element; } @Step - public TopicsList clickCopySelectedTopicBtn() { - copySelectedTopicBtn.shouldBe(Condition.enabled).click(); - return this; + public TopicsList selectItem(boolean select) { + selectElement(element.$x("./td[1]/input"), select); + return new TopicsList(); } - @Step - public TopicsList clickPurgeMessagesOfSelectedTopicsBtn() { - purgeMessagesOfSelectedTopicsBtn.shouldBe(Condition.enabled).click(); - return this; + private SelenideElement getNameElm() { + return element.$x("./td[2]"); } @Step - public TopicsList clickClearMessagesBtn() { - clickByJavaScript(clearMessagesBtn.shouldBe(visible)); - return this; + public boolean isInternal() { + boolean internal = false; + try { + internal = getNameElm().$x("./a/span").isDisplayed(); + } catch (Throwable ignored) { + } + return internal; } @Step - public TopicsList clickRecreateTopicBtn() { - clickByJavaScript(recreateTopicBtn.shouldBe(visible)); - return this; + public String getName() { + return getNameElm().$x("./a").getAttribute("title"); } @Step - public TopicsList clickRemoveTopicBtn() { - clickByJavaScript(removeTopicBtn.shouldBe(visible)); - return this; + public void openItem() { + getNameElm().click(); } @Step - public TopicsList clickConfirmBtnMdl() { - clickConfirmButton(); - return this; + public int getPartition() { + return Integer.parseInt(element.$x("./td[3]").getText().trim()); } @Step - public TopicsList clickCancelBtnMdl() { - clickCancelButton(); - return this; + public int getOutOfSyncReplicas() { + return Integer.parseInt(element.$x("./td[4]").getText().trim()); } @Step - public boolean isConfirmationMdlVisible() { - return isConfirmationModalVisible(); + public int getReplicationFactor() { + return Integer.parseInt(element.$x("./td[5]").getText().trim()); } @Step - public boolean isAlertWithMessageVisible(AlertHeader header, String message) { - return isAlertVisible(header, message); - } - - private List getVisibleColumnHeaders() { - return Stream.of("Replication Factor", "Number of messages", "Topic Name", "Partitions", "Out of sync replicas", "Size") - .map(name -> $x(String.format(columnHeaderLocator, name))) - .collect(Collectors.toList()); - } - - private List getEnabledColumnHeaders() { - return Stream.of("Topic Name", "Partitions", "Out of sync replicas", "Size") - .map(name -> $x(String.format(columnHeaderLocator, name))) - .collect(Collectors.toList()); + public int getNumberOfMessages() { + return Integer.parseInt(element.$x("./td[6]").getText().trim()); } @Step - public List getAllVisibleElements() { - List visibleElements = new ArrayList<>(getVisibleColumnHeaders()); - visibleElements.addAll(Arrays.asList(searchField, addTopicBtn, tableGrid)); - visibleElements.addAll(getActionButtons()); - return visibleElements; + public int getSize() { + return Integer.parseInt(element.$x("./td[7]").getText().trim()); } @Step - public List getAllEnabledElements() { - List enabledElements = new ArrayList<>(getEnabledColumnHeaders()); - enabledElements.addAll(Arrays.asList(searchField, showInternalRadioBtn, addTopicBtn)); - return enabledElements; - } - - private List initGridItems() { - List gridItemList = new ArrayList<>(); - gridItems.shouldHave(CollectionCondition.sizeGreaterThan(0)) - .forEach(item -> gridItemList.add(new TopicGridItem(item))); - return gridItemList; - } - - @Step - public TopicGridItem getTopicItem(String name) { - TopicGridItem topicGridItem = initGridItems().stream() - .filter(e -> e.getName().equals(name)) - .findFirst().orElse(null); - if (topicGridItem == null) { - searchItem(name); - topicGridItem = initGridItems().stream() - .filter(e -> e.getName().equals(name)) - .findFirst().orElseThrow(); - } - return topicGridItem; - } - - @Step - public TopicGridItem getAnyNonInternalTopic() { - return getNonInternalTopics().stream() - .findAny().orElseThrow(); - } - - @Step - public List getNonInternalTopics() { - return initGridItems().stream() - .filter(e -> !e.isInternal()) - .collect(Collectors.toList()); - } - - @Step - public List getInternalTopics() { - return initGridItems().stream() - .filter(TopicGridItem::isInternal) - .collect(Collectors.toList()); - } - - public static class TopicGridItem extends BasePage { - - private final SelenideElement element; - - public TopicGridItem(SelenideElement element) { - this.element = element; - } - - @Step - public TopicsList selectItem(boolean select) { - selectElement(element.$x("./td[1]/input"), select); - return new TopicsList(); - } - - private SelenideElement getNameElm() { - return element.$x("./td[2]"); - } - - @Step - public boolean isInternal() { - boolean internal = false; - try { - internal = getNameElm().$x("./a/span").isDisplayed(); - } catch (Throwable ignored) { - } - return internal; - } - - @Step - public String getName() { - return getNameElm().$x("./a").getAttribute("title"); - } - - @Step - public void openItem() { - getNameElm().click(); - } - - @Step - public int getPartition() { - return Integer.parseInt(element.$x("./td[3]").getText().trim()); - } - - @Step - public int getOutOfSyncReplicas() { - return Integer.parseInt(element.$x("./td[4]").getText().trim()); - } - - @Step - public int getReplicationFactor() { - return Integer.parseInt(element.$x("./td[5]").getText().trim()); - } - - @Step - public int getNumberOfMessages() { - return Integer.parseInt(element.$x("./td[6]").getText().trim()); - } - - @Step - public int getSize() { - return Integer.parseInt(element.$x("./td[7]").getText().trim()); - } - - @Step - public void openDotMenu() { - element.$x("./td[8]//button").click(); - } + public void openDotMenu() { + element.$x("./td[8]//button").click(); } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/CleanupPolicyValue.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/CleanupPolicyValue.java index 48c0c0fbc..6e4d31a3a 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/CleanupPolicyValue.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/CleanupPolicyValue.java @@ -2,24 +2,24 @@ public enum CleanupPolicyValue { - DELETE("delete", "Delete"), - COMPACT("compact", "Compact"), - COMPACT_DELETE("compact,delete", "Compact,Delete"); + DELETE("delete", "Delete"), + COMPACT("compact", "Compact"), + COMPACT_DELETE("compact,delete", "Compact,Delete"); - private final String optionValue; - private final String visibleText; + private final String optionValue; + private final String visibleText; - CleanupPolicyValue(String optionValue, String visibleText) { - this.optionValue = optionValue; - this.visibleText = visibleText; - } + CleanupPolicyValue(String optionValue, String visibleText) { + this.optionValue = optionValue; + this.visibleText = visibleText; + } - public String getOptionValue() { - return optionValue; - } + public String getOptionValue() { + return optionValue; + } - public String getVisibleText() { - return visibleText; - } + public String getVisibleText() { + return visibleText; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/CustomParameterType.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/CustomParameterType.java index f4cb5cb95..4ed3e8996 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/CustomParameterType.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/CustomParameterType.java @@ -2,36 +2,36 @@ public enum CustomParameterType { - COMPRESSION_TYPE("compression.type"), - DELETE_RETENTION_MS("delete.retention.ms"), - FILE_DELETE_DELAY_MS("file.delete.delay.ms"), - FLUSH_MESSAGES("flush.messages"), - FLUSH_MS("flush.ms"), - FOLLOWER_REPLICATION_THROTTLED_REPLICAS("follower.replication.throttled.replicas"), - INDEX_INTERVAL_BYTES("index.interval.bytes"), - LEADER_REPLICATION_THROTTLED_REPLICAS("leader.replication.throttled.replicas"), - MAX_COMPACTION_LAG_MS("max.compaction.lag.ms"), - MESSAGE_DOWNCONVERSION_ENABLE("message.downconversion.enable"), - MESSAGE_FORMAT_VERSION("message.format.version"), - MESSAGE_TIMESTAMP_DIFFERENCE_MAX_MS("message.timestamp.difference.max.ms"), - MESSAGE_TIMESTAMP_TYPE("message.timestamp.type"), - MIN_CLEANABLE_DIRTY_RATIO("min.cleanable.dirty.ratio"), - MIN_COMPACTION_LAG_MS("min.compaction.lag.ms"), - PREALLOCATE("preallocate"), - RETENTION_BYTES("retention.bytes"), - SEGMENT_BYTES("segment.bytes"), - SEGMENT_INDEX_BYTES("segment.index.bytes"), - SEGMENT_JITTER_MS("segment.jitter.ms"), - SEGMENT_MS("segment.ms"), - UNCLEAN_LEADER_ELECTION_ENABLE("unclean.leader.election.enable"); + COMPRESSION_TYPE("compression.type"), + DELETE_RETENTION_MS("delete.retention.ms"), + FILE_DELETE_DELAY_MS("file.delete.delay.ms"), + FLUSH_MESSAGES("flush.messages"), + FLUSH_MS("flush.ms"), + FOLLOWER_REPLICATION_THROTTLED_REPLICAS("follower.replication.throttled.replicas"), + INDEX_INTERVAL_BYTES("index.interval.bytes"), + LEADER_REPLICATION_THROTTLED_REPLICAS("leader.replication.throttled.replicas"), + MAX_COMPACTION_LAG_MS("max.compaction.lag.ms"), + MESSAGE_DOWNCONVERSION_ENABLE("message.downconversion.enable"), + MESSAGE_FORMAT_VERSION("message.format.version"), + MESSAGE_TIMESTAMP_DIFFERENCE_MAX_MS("message.timestamp.difference.max.ms"), + MESSAGE_TIMESTAMP_TYPE("message.timestamp.type"), + MIN_CLEANABLE_DIRTY_RATIO("min.cleanable.dirty.ratio"), + MIN_COMPACTION_LAG_MS("min.compaction.lag.ms"), + PREALLOCATE("preallocate"), + RETENTION_BYTES("retention.bytes"), + SEGMENT_BYTES("segment.bytes"), + SEGMENT_INDEX_BYTES("segment.index.bytes"), + SEGMENT_JITTER_MS("segment.jitter.ms"), + SEGMENT_MS("segment.ms"), + UNCLEAN_LEADER_ELECTION_ENABLE("unclean.leader.election.enable"); - private final String optionValue; + private final String optionValue; - CustomParameterType(String optionValue) { - this.optionValue = optionValue; - } + CustomParameterType(String optionValue) { + this.optionValue = optionValue; + } - public String getOptionValue() { - return optionValue; - } + public String getOptionValue() { + return optionValue; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/MaxSizeOnDisk.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/MaxSizeOnDisk.java index 8f459eea7..c77c1a962 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/MaxSizeOnDisk.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/MaxSizeOnDisk.java @@ -2,26 +2,26 @@ public enum MaxSizeOnDisk { - NOT_SET("-1", "Not Set"), - SIZE_1_GB("1073741824", "1 GB"), - SIZE_10_GB("10737418240", "10 GB"), - SIZE_20_GB("21474836480", "20 GB"), - SIZE_50_GB("53687091200", "50 GB"); + NOT_SET("-1", "Not Set"), + SIZE_1_GB("1073741824", "1 GB"), + SIZE_10_GB("10737418240", "10 GB"), + SIZE_20_GB("21474836480", "20 GB"), + SIZE_50_GB("53687091200", "50 GB"); - private final String optionValue; - private final String visibleText; + private final String optionValue; + private final String visibleText; - MaxSizeOnDisk(String optionValue, String visibleText) { - this.optionValue = optionValue; - this.visibleText = visibleText; - } + MaxSizeOnDisk(String optionValue, String visibleText) { + this.optionValue = optionValue; + this.visibleText = visibleText; + } - public String getOptionValue() { - return optionValue; - } + public String getOptionValue() { + return optionValue; + } - public String getVisibleText() { - return visibleText; - } + public String getVisibleText() { + return visibleText; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/TimeToRetain.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/TimeToRetain.java index c07abdc17..c2768ca24 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/TimeToRetain.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topics/enums/TimeToRetain.java @@ -2,25 +2,25 @@ public enum TimeToRetain { - BTN_12_HOURS("12 hours", "43200000"), - BTN_1_DAY("1 day", "86400000"), - BTN_2_DAYS("2 days", "172800000"), - BTN_7_DAYS("7 days", "604800000"), - BTN_4_WEEKS("4 weeks", "2419200000"); + BTN_12_HOURS("12 hours", "43200000"), + BTN_1_DAY("1 day", "86400000"), + BTN_2_DAYS("2 days", "172800000"), + BTN_7_DAYS("7 days", "604800000"), + BTN_4_WEEKS("4 weeks", "2419200000"); - private final String button; - private final String value; + private final String button; + private final String value; - TimeToRetain(String button, String value) { - this.button = button; - this.value = value; - } + TimeToRetain(String button, String value) { + this.button = button; + this.value = value; + } - public String getButton() { - return button; - } + public String getButton() { + return button; + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/services/ApiService.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/services/ApiService.java index 808f0fdbc..ea08f57fe 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/services/ApiService.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/services/ApiService.java @@ -1,272 +1,282 @@ package com.provectus.kafka.ui.services; +import static com.codeborne.selenide.Selenide.sleep; +import static com.provectus.kafka.ui.utilities.FileUtils.fileToString; + import com.fasterxml.jackson.databind.ObjectMapper; import com.provectus.kafka.ui.api.ApiClient; -import com.provectus.kafka.ui.api.api.*; -import com.provectus.kafka.ui.api.model.*; +import com.provectus.kafka.ui.api.api.KafkaConnectApi; +import com.provectus.kafka.ui.api.api.KsqlApi; +import com.provectus.kafka.ui.api.api.MessagesApi; +import com.provectus.kafka.ui.api.api.SchemasApi; +import com.provectus.kafka.ui.api.api.TopicsApi; +import com.provectus.kafka.ui.api.model.CreateTopicMessage; +import com.provectus.kafka.ui.api.model.KsqlCommandV2; +import com.provectus.kafka.ui.api.model.KsqlCommandV2Response; +import com.provectus.kafka.ui.api.model.KsqlResponse; +import com.provectus.kafka.ui.api.model.NewConnector; +import com.provectus.kafka.ui.api.model.NewSchemaSubject; +import com.provectus.kafka.ui.api.model.TopicCreation; import com.provectus.kafka.ui.models.Connector; import com.provectus.kafka.ui.models.Schema; import com.provectus.kafka.ui.models.Topic; -import com.provectus.kafka.ui.pages.ksqlDb.models.Stream; -import com.provectus.kafka.ui.pages.ksqlDb.models.Table; +import com.provectus.kafka.ui.pages.ksqldb.models.Stream; +import com.provectus.kafka.ui.pages.ksqldb.models.Table; import com.provectus.kafka.ui.settings.BaseSource; import io.qameta.allure.Step; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.reactive.function.client.WebClientResponseException; - import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; - -import static com.codeborne.selenide.Selenide.sleep; -import static com.provectus.kafka.ui.utilities.FileUtils.fileToString; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.reactive.function.client.WebClientResponseException; @Slf4j public class ApiService extends BaseSource { - @SneakyThrows - private TopicsApi topicApi() { - return new TopicsApi(new ApiClient().setBasePath(BASE_API_URL)); - } + @SneakyThrows + private TopicsApi topicApi() { + return new TopicsApi(new ApiClient().setBasePath(BASE_API_URL)); + } - @SneakyThrows - private SchemasApi schemaApi() { - return new SchemasApi(new ApiClient().setBasePath(BASE_API_URL)); - } + @SneakyThrows + private SchemasApi schemaApi() { + return new SchemasApi(new ApiClient().setBasePath(BASE_API_URL)); + } - @SneakyThrows - private KafkaConnectApi connectorApi() { - return new KafkaConnectApi(new ApiClient().setBasePath(BASE_API_URL)); - } + @SneakyThrows + private KafkaConnectApi connectorApi() { + return new KafkaConnectApi(new ApiClient().setBasePath(BASE_API_URL)); + } - @SneakyThrows - private MessagesApi messageApi() { - return new MessagesApi(new ApiClient().setBasePath(BASE_API_URL)); - } + @SneakyThrows + private MessagesApi messageApi() { + return new MessagesApi(new ApiClient().setBasePath(BASE_API_URL)); + } - @SneakyThrows - private KsqlApi ksqlApi() { - return new KsqlApi(new ApiClient().setBasePath(BASE_API_URL)); - } + @SneakyThrows + private KsqlApi ksqlApi() { + return new KsqlApi(new ApiClient().setBasePath(BASE_API_URL)); + } - @SneakyThrows - private void createTopic(String clusterName, String topicName) { - TopicCreation topic = new TopicCreation(); - topic.setName(topicName); - topic.setPartitions(1); - topic.setReplicationFactor(1); - try { - topicApi().createTopic(clusterName, topic).block(); - sleep(2000); - } catch (WebClientResponseException ex) { - ex.printStackTrace(); - } + @SneakyThrows + private void createTopic(String clusterName, String topicName) { + TopicCreation topic = new TopicCreation(); + topic.setName(topicName); + topic.setPartitions(1); + topic.setReplicationFactor(1); + try { + topicApi().createTopic(clusterName, topic).block(); + sleep(2000); + } catch (WebClientResponseException ex) { + ex.printStackTrace(); } + } - @Step - public ApiService createTopic(Topic topic) { - createTopic(CLUSTER_NAME, topic.getName()); - return this; - } + @Step + public ApiService createTopic(Topic topic) { + createTopic(CLUSTER_NAME, topic.getName()); + return this; + } - @SneakyThrows - private void deleteTopic(String clusterName, String topicName) { - try { - topicApi().deleteTopic(clusterName, topicName).block(); - } catch (WebClientResponseException ignore) { - } + @SneakyThrows + private void deleteTopic(String clusterName, String topicName) { + try { + topicApi().deleteTopic(clusterName, topicName).block(); + } catch (WebClientResponseException ignored) { } + } - @Step - public ApiService deleteTopic(String topicName) { - deleteTopic(CLUSTER_NAME, topicName); - return this; - } + @Step + public ApiService deleteTopic(String topicName) { + deleteTopic(CLUSTER_NAME, topicName); + return this; + } - @SneakyThrows - private void createSchema(String clusterName, Schema schema) { - NewSchemaSubject schemaSubject = new NewSchemaSubject(); - schemaSubject.setSubject(schema.getName()); - schemaSubject.setSchema(fileToString(schema.getValuePath())); - schemaSubject.setSchemaType(schema.getType()); - try { - schemaApi().createNewSchema(clusterName, schemaSubject).block(); - } catch (WebClientResponseException ex) { - ex.printStackTrace(); - } + @SneakyThrows + private void createSchema(String clusterName, Schema schema) { + NewSchemaSubject schemaSubject = new NewSchemaSubject(); + schemaSubject.setSubject(schema.getName()); + schemaSubject.setSchema(fileToString(schema.getValuePath())); + schemaSubject.setSchemaType(schema.getType()); + try { + schemaApi().createNewSchema(clusterName, schemaSubject).block(); + } catch (WebClientResponseException ex) { + ex.printStackTrace(); } + } - @Step - public ApiService createSchema(Schema schema) { - createSchema(CLUSTER_NAME, schema); - return this; - } + @Step + public ApiService createSchema(Schema schema) { + createSchema(CLUSTER_NAME, schema); + return this; + } - @SneakyThrows - private void deleteSchema(String clusterName, String schemaName) { - try { - schemaApi().deleteSchema(clusterName, schemaName).block(); - } catch (WebClientResponseException ignore) { - } + @SneakyThrows + private void deleteSchema(String clusterName, String schemaName) { + try { + schemaApi().deleteSchema(clusterName, schemaName).block(); + } catch (WebClientResponseException ignored) { } + } - @Step - public ApiService deleteSchema(String schemaName) { - deleteSchema(CLUSTER_NAME, schemaName); - return this; - } + @Step + public ApiService deleteSchema(String schemaName) { + deleteSchema(CLUSTER_NAME, schemaName); + return this; + } - @SneakyThrows - private void deleteConnector(String clusterName, String connectName, String connectorName) { - try { - connectorApi().deleteConnector(clusterName, connectName, connectorName).block(); - } catch (WebClientResponseException ignore) { - } + @SneakyThrows + private void deleteConnector(String clusterName, String connectName, String connectorName) { + try { + connectorApi().deleteConnector(clusterName, connectName, connectorName).block(); + } catch (WebClientResponseException ignored) { } + } - @Step - public ApiService deleteConnector(String connectName, String connectorName) { - deleteConnector(CLUSTER_NAME, connectName, connectorName); - return this; - } + @Step + public ApiService deleteConnector(String connectName, String connectorName) { + deleteConnector(CLUSTER_NAME, connectName, connectorName); + return this; + } - @Step - public ApiService deleteConnector(String connectorName) { - deleteConnector(CLUSTER_NAME, CONNECT_NAME, connectorName); - return this; - } + @Step + public ApiService deleteConnector(String connectorName) { + deleteConnector(CLUSTER_NAME, CONNECT_NAME, connectorName); + return this; + } - @SneakyThrows - private void createConnector(String clusterName, String connectName, Connector connector) { - NewConnector connectorProperties = new NewConnector(); - connectorProperties.setName(connector.getName()); - Map configMap = new ObjectMapper().readValue(connector.getConfig(), HashMap.class); - connectorProperties.setConfig(configMap); - try { - connectorApi().deleteConnector(clusterName, connectName, connector.getName()).block(); - } catch (WebClientResponseException ignored) { - } - connectorApi().createConnector(clusterName, connectName, connectorProperties).block(); + @SneakyThrows + private void createConnector(String clusterName, String connectName, Connector connector) { + NewConnector connectorProperties = new NewConnector(); + connectorProperties.setName(connector.getName()); + Map configMap = new ObjectMapper().readValue(connector.getConfig(), HashMap.class); + connectorProperties.setConfig(configMap); + try { + connectorApi().deleteConnector(clusterName, connectName, connector.getName()).block(); + } catch (WebClientResponseException ignored) { } + connectorApi().createConnector(clusterName, connectName, connectorProperties).block(); + } - @Step - public ApiService createConnector(String connectName, Connector connector) { - createConnector(CLUSTER_NAME, connectName, connector); - return this; - } + @Step + public ApiService createConnector(String connectName, Connector connector) { + createConnector(CLUSTER_NAME, connectName, connector); + return this; + } - @Step - public ApiService createConnector(Connector connector) { - createConnector(CLUSTER_NAME, CONNECT_NAME, connector); - return this; - } + @Step + public ApiService createConnector(Connector connector) { + createConnector(CLUSTER_NAME, CONNECT_NAME, connector); + return this; + } - @Step - public String getFirstConnectName(String clusterName) { - return Objects.requireNonNull(connectorApi().getConnects(clusterName).blockFirst()).getName(); - } + @Step + public String getFirstConnectName(String clusterName) { + return Objects.requireNonNull(connectorApi().getConnects(clusterName).blockFirst()).getName(); + } - @SneakyThrows - private void sendMessage(String clusterName, Topic topic) { - CreateTopicMessage createMessage = new CreateTopicMessage(); - createMessage.setPartition(0); - createMessage.setKeySerde("String"); - createMessage.setValueSerde("String"); - createMessage.setKey(topic.getMessageKey()); - createMessage.setContent(topic.getMessageContent()); - try { - messageApi().sendTopicMessages(clusterName, topic.getName(), createMessage).block(); - } catch (WebClientResponseException ex) { - ex.getRawStatusCode(); - } + @SneakyThrows + private void sendMessage(String clusterName, Topic topic) { + CreateTopicMessage createMessage = new CreateTopicMessage(); + createMessage.setPartition(0); + createMessage.setKeySerde("String"); + createMessage.setValueSerde("String"); + createMessage.setKey(topic.getMessageKey()); + createMessage.setContent(topic.getMessageContent()); + try { + messageApi().sendTopicMessages(clusterName, topic.getName(), createMessage).block(); + } catch (WebClientResponseException ex) { + ex.getRawStatusCode(); } + } - @Step - public ApiService sendMessage(Topic topic) { - sendMessage(CLUSTER_NAME, topic); - return this; - } + @Step + public ApiService sendMessage(Topic topic) { + sendMessage(CLUSTER_NAME, topic); + return this; + } - @Step - public ApiService createStream(Stream stream) { - KsqlCommandV2Response pipeIdStream = ksqlApi() - .executeKsql(CLUSTER_NAME, new KsqlCommandV2() - .ksql(String.format("CREATE STREAM %s (profileId VARCHAR, latitude DOUBLE, longitude DOUBLE) ", - stream.getName()) - + String.format("WITH (kafka_topic='%s', value_format='json', partitions=1);", - stream.getTopicName()))) - .block(); - assert pipeIdStream != null; - List responseListStream = ksqlApi() - .openKsqlResponsePipe(CLUSTER_NAME, pipeIdStream.getPipeId()) - .collectList() - .block(); - assert Objects.requireNonNull(responseListStream).size() != 0; - return this; - } + @Step + public ApiService createStream(Stream stream) { + KsqlCommandV2Response pipeIdStream = ksqlApi() + .executeKsql(CLUSTER_NAME, new KsqlCommandV2() + .ksql(String.format("CREATE STREAM %s (profileId VARCHAR, latitude DOUBLE, longitude DOUBLE) ", + stream.getName()) + + String.format("WITH (kafka_topic='%s', value_format='json', partitions=1);", + stream.getTopicName()))) + .block(); + assert pipeIdStream != null; + List responseListStream = ksqlApi() + .openKsqlResponsePipe(CLUSTER_NAME, pipeIdStream.getPipeId()) + .collectList() + .block(); + assert Objects.requireNonNull(responseListStream).size() != 0; + return this; + } - @Step - public ApiService createTables(Table firstTable, Table secondTable) { - KsqlCommandV2Response pipeIdTable1 = ksqlApi() - .executeKsql(CLUSTER_NAME, new KsqlCommandV2() - .ksql(String.format("CREATE TABLE %s AS ", firstTable.getName()) - + " SELECT profileId, " - + " LATEST_BY_OFFSET(latitude) AS la, " - + " LATEST_BY_OFFSET(longitude) AS lo " - + String.format(" FROM %s ", firstTable.getStreamName()) - + " GROUP BY profileId " - + " EMIT CHANGES;")) - .block(); - assert pipeIdTable1 != null; - List responseListTable = ksqlApi() - .openKsqlResponsePipe(CLUSTER_NAME, pipeIdTable1.getPipeId()) - .collectList() - .block(); - assert Objects.requireNonNull(responseListTable).size() != 0; - KsqlCommandV2Response pipeIdTable2 = ksqlApi() - .executeKsql(CLUSTER_NAME, new KsqlCommandV2() - .ksql(String.format("CREATE TABLE %s AS ", secondTable.getName()) - + " SELECT ROUND(GEO_DISTANCE(la, lo, 37.4133, -122.1162), -1) AS distanceInMiles, " - + " COLLECT_LIST(profileId) AS riders, " - + " COUNT(*) AS count " - + String.format(" FROM %s ", firstTable.getName()) - + " GROUP BY ROUND(GEO_DISTANCE(la, lo, 37.4133, -122.1162), -1);")) - .block(); - assert pipeIdTable2 != null; - List responseListTable2 = ksqlApi() - .openKsqlResponsePipe(CLUSTER_NAME, pipeIdTable2.getPipeId()) - .collectList() - .block(); - assert Objects.requireNonNull(responseListTable2).size() != 0; - return this; - } + @Step + public ApiService createTables(Table firstTable, Table secondTable) { + KsqlCommandV2Response pipeIdTable1 = ksqlApi() + .executeKsql(CLUSTER_NAME, new KsqlCommandV2() + .ksql(String.format("CREATE TABLE %s AS ", firstTable.getName()) + + " SELECT profileId, " + + " LATEST_BY_OFFSET(latitude) AS la, " + + " LATEST_BY_OFFSET(longitude) AS lo " + + String.format(" FROM %s ", firstTable.getStreamName()) + + " GROUP BY profileId " + + " EMIT CHANGES;")) + .block(); + assert pipeIdTable1 != null; + List responseListTable = ksqlApi() + .openKsqlResponsePipe(CLUSTER_NAME, pipeIdTable1.getPipeId()) + .collectList() + .block(); + assert Objects.requireNonNull(responseListTable).size() != 0; + KsqlCommandV2Response pipeIdTable2 = ksqlApi() + .executeKsql(CLUSTER_NAME, new KsqlCommandV2() + .ksql(String.format("CREATE TABLE %s AS ", secondTable.getName()) + + " SELECT ROUND(GEO_DISTANCE(la, lo, 37.4133, -122.1162), -1) AS distanceInMiles, " + + " COLLECT_LIST(profileId) AS riders, " + + " COUNT(*) AS count " + + String.format(" FROM %s ", firstTable.getName()) + + " GROUP BY ROUND(GEO_DISTANCE(la, lo, 37.4133, -122.1162), -1);")) + .block(); + assert pipeIdTable2 != null; + List responseListTable2 = ksqlApi() + .openKsqlResponsePipe(CLUSTER_NAME, pipeIdTable2.getPipeId()) + .collectList() + .block(); + assert Objects.requireNonNull(responseListTable2).size() != 0; + return this; + } - @Step - public ApiService insertInto(Stream stream) { - String streamName = stream.getName(); - KsqlCommandV2Response pipeIdInsert = ksqlApi() - .executeKsql(CLUSTER_NAME, new KsqlCommandV2() - .ksql("INSERT INTO " + streamName + " (profileId, latitude, longitude) VALUES ('c2309eec', 37.7877, -122.4205);" - + "INSERT INTO " + streamName + - " (profileId, latitude, longitude) VALUES ('18f4ea86', 37.3903, -122.0643); " - + "INSERT INTO " + streamName + - " (profileId, latitude, longitude) VALUES ('4ab5cbad', 37.3952, -122.0813); " - + "INSERT INTO " + streamName + - " (profileId, latitude, longitude) VALUES ('8b6eae59', 37.3944, -122.0813); " - + "INSERT INTO " + streamName + - " (profileId, latitude, longitude) VALUES ('4a7c7b41', 37.4049, -122.0822); " - + "INSERT INTO " + streamName + - " (profileId, latitude, longitude) VALUES ('4ddad000', 37.7857, -122.4011);")) - .block(); - assert pipeIdInsert != null; - List responseListInsert = ksqlApi() - .openKsqlResponsePipe(CLUSTER_NAME, pipeIdInsert.getPipeId()) - .collectList() - .block(); - assert Objects.requireNonNull(responseListInsert).size() != 0; - return this; - } + @Step + public ApiService insertInto(Stream stream) { + String streamName = stream.getName(); + KsqlCommandV2Response pipeIdInsert = ksqlApi() + .executeKsql(CLUSTER_NAME, new KsqlCommandV2() + .ksql("INSERT INTO " + streamName + + " (profileId, latitude, longitude) VALUES ('c2309eec', 37.7877, -122.4205);" + + "INSERT INTO " + streamName + + " (profileId, latitude, longitude) VALUES ('18f4ea86', 37.3903, -122.0643); " + + "INSERT INTO " + streamName + + " (profileId, latitude, longitude) VALUES ('4ab5cbad', 37.3952, -122.0813); " + + "INSERT INTO " + streamName + + " (profileId, latitude, longitude) VALUES ('8b6eae59', 37.3944, -122.0813); " + + "INSERT INTO " + streamName + + " (profileId, latitude, longitude) VALUES ('4a7c7b41', 37.4049, -122.0822); " + + "INSERT INTO " + streamName + + " (profileId, latitude, longitude) VALUES ('4ddad000', 37.7857, -122.4011);")) + .block(); + assert pipeIdInsert != null; + List responseListInsert = ksqlApi() + .openKsqlResponsePipe(CLUSTER_NAME, pipeIdInsert.getPipeId()) + .collectList() + .block(); + assert Objects.requireNonNull(responseListInsert).size() != 0; + return this; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/BaseSource.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/BaseSource.java index cbb1bc234..821f2ba64 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/BaseSource.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/BaseSource.java @@ -1,29 +1,29 @@ package com.provectus.kafka.ui.settings; +import static com.provectus.kafka.ui.variables.Browser.LOCAL; + import com.provectus.kafka.ui.settings.configs.Config; import org.aeonbits.owner.ConfigFactory; -import static com.provectus.kafka.ui.variables.Browser.LOCAL; - public abstract class BaseSource { - public static final String CLUSTER_NAME = "local"; - public static final String CONNECT_NAME = "first"; - private static final String LOCAL_HOST = "localhost"; - private static Config config; - public static final String BROWSER = config().browser(); - public static final String SUITE_NAME = config().suite(); - public static final String BASE_HOST = BROWSER.equals(LOCAL) - ? LOCAL_HOST - : "host.docker.internal"; - public static final String REMOTE_URL = String.format("http://%s:4444/wd/hub", LOCAL_HOST); - public static final String BASE_API_URL = String.format("http://%s:8080", LOCAL_HOST); - public static final String BASE_UI_URL = String.format("http://%s:8080", BASE_HOST); + public static final String CLUSTER_NAME = "local"; + public static final String CONNECT_NAME = "first"; + private static final String LOCAL_HOST = "localhost"; + public static final String REMOTE_URL = String.format("http://%s:4444/wd/hub", LOCAL_HOST); + public static final String BASE_API_URL = String.format("http://%s:8080", LOCAL_HOST); + private static Config config; + public static final String BROWSER = config().browser(); + public static final String BASE_HOST = BROWSER.equals(LOCAL) + ? LOCAL_HOST + : "host.docker.internal"; + public static final String BASE_UI_URL = String.format("http://%s:8080", BASE_HOST); + public static final String SUITE_NAME = config().suite(); - private static Config config() { - if (config == null) { - config = ConfigFactory.create(Config.class, System.getProperties()); - } - return config; + private static Config config() { + if (config == null) { + config = ConfigFactory.create(Config.class, System.getProperties()); } + return config; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/configs/Profiles.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/configs/Profiles.java index ef61d7d77..fb9f9c1b1 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/configs/Profiles.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/configs/Profiles.java @@ -1,17 +1,17 @@ package com.provectus.kafka.ui.settings.configs; -import org.aeonbits.owner.Config; - import static com.provectus.kafka.ui.variables.Browser.CONTAINER; import static com.provectus.kafka.ui.variables.Suite.CUSTOM; +import org.aeonbits.owner.Config; + public interface Profiles extends Config { - @Key("browser") - @DefaultValue(CONTAINER) - String browser(); + @Key("browser") + @DefaultValue(CONTAINER) + String browser(); - @Key("suite") - @DefaultValue(CUSTOM) - String suite(); + @Key("suite") + @DefaultValue(CUSTOM) + String suite(); } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/drivers/WebDriver.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/drivers/WebDriver.java index 2b210e91e..df1c55bc2 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/drivers/WebDriver.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/drivers/WebDriver.java @@ -1,96 +1,101 @@ package com.provectus.kafka.ui.settings.drivers; +import static com.codeborne.selenide.Selenide.clearBrowserCookies; +import static com.codeborne.selenide.Selenide.clearBrowserLocalStorage; +import static com.codeborne.selenide.Selenide.refresh; +import static com.provectus.kafka.ui.settings.BaseSource.BROWSER; +import static com.provectus.kafka.ui.settings.BaseSource.REMOTE_URL; +import static com.provectus.kafka.ui.variables.Browser.CONTAINER; +import static com.provectus.kafka.ui.variables.Browser.LOCAL; + import com.codeborne.selenide.Configuration; import com.codeborne.selenide.Selenide; import com.codeborne.selenide.WebDriverRunner; import com.codeborne.selenide.logevents.SelenideLogger; import io.qameta.allure.Step; import io.qameta.allure.selenide.AllureSelenide; +import lombok.extern.slf4j.Slf4j; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.DesiredCapabilities; -import static com.codeborne.selenide.Selenide.*; -import static com.provectus.kafka.ui.settings.BaseSource.BROWSER; -import static com.provectus.kafka.ui.settings.BaseSource.REMOTE_URL; -import static com.provectus.kafka.ui.variables.Browser.CONTAINER; -import static com.provectus.kafka.ui.variables.Browser.LOCAL; - +@Slf4j public abstract class WebDriver { - @Step - public static void browserSetup() { - Configuration.headless = false; - Configuration.browser = "chrome"; - Configuration.browserSize = "1920x1080"; - /**screenshots and savePageSource config is needed for local debug - * optionally can be set as 'false' to not duplicate Allure report - */ - Configuration.screenshots = true; - Configuration.savePageSource = false; - Configuration.pageLoadTimeout = 120000; - ChromeOptions options = new ChromeOptions() - .addArguments("--no-sandbox") - .addArguments("--verbose") - .addArguments("--remote-allow-origins=*") - .addArguments("--disable-dev-shm-usage") - .addArguments("--disable-gpu") - .addArguments("--lang=en_US"); - switch (BROWSER) { - case (LOCAL) -> Configuration.browserCapabilities = options; - case (CONTAINER) -> { - Configuration.remote = REMOTE_URL; - Configuration.remoteConnectionTimeout = 180000; - DesiredCapabilities capabilities = new DesiredCapabilities(); - capabilities.setCapability("enableVNC", true); - capabilities.setCapability("enableVideo", false); - Configuration.browserCapabilities = capabilities.merge(options); - } - default -> throw new IllegalStateException("Unexpected value: " + BROWSER); - } + @Step + public static void browserSetup() { + Configuration.headless = false; + Configuration.browser = "chrome"; + Configuration.browserSize = "1920x1080"; + Configuration.screenshots = true; + Configuration.savePageSource = false; + Configuration.pageLoadTimeout = 120000; + ChromeOptions options = new ChromeOptions() + .addArguments("--no-sandbox") + .addArguments("--verbose") + .addArguments("--remote-allow-origins=*") + .addArguments("--disable-dev-shm-usage") + .addArguments("--disable-gpu") + .addArguments("--lang=en_US"); + switch (BROWSER) { + case (LOCAL) -> Configuration.browserCapabilities = options; + case (CONTAINER) -> { + Configuration.remote = REMOTE_URL; + Configuration.remoteConnectionTimeout = 180000; + DesiredCapabilities capabilities = new DesiredCapabilities(); + capabilities.setCapability("enableVNC", true); + capabilities.setCapability("enableVideo", false); + Configuration.browserCapabilities = capabilities.merge(options); + } + default -> throw new IllegalStateException("Unexpected value: " + BROWSER); } + } - private static org.openqa.selenium.WebDriver getWebDriver() { - try { - return WebDriverRunner.getWebDriver(); - } catch (IllegalStateException ex) { - browserSetup(); - Selenide.open(); - return WebDriverRunner.getWebDriver(); - } + private static org.openqa.selenium.WebDriver getWebDriver() { + try { + return WebDriverRunner.getWebDriver(); + } catch (IllegalStateException ex) { + browserSetup(); + Selenide.open(); + return WebDriverRunner.getWebDriver(); } + } - @Step - public static void openUrl(String url) { - org.openqa.selenium.WebDriver driver = getWebDriver(); - if (!driver.getCurrentUrl().equals(url)) driver.get(url); + @Step + public static void openUrl(String url) { + org.openqa.selenium.WebDriver driver = getWebDriver(); + if (!driver.getCurrentUrl().equals(url)) { + driver.get(url); } + } - @Step - public static void browserInit() { - getWebDriver(); - } + @Step + public static void browserInit() { + getWebDriver(); + } - @Step - public static void browserClear() { - clearBrowserLocalStorage(); - clearBrowserCookies(); - refresh(); - } + @Step + public static void browserClear() { + clearBrowserLocalStorage(); + clearBrowserCookies(); + refresh(); + } - @Step - public static void browserQuit() { - org.openqa.selenium.WebDriver driver = null; - try { - driver = WebDriverRunner.getWebDriver(); - } catch (Throwable ignored) { - } - if (driver != null) driver.quit(); + @Step + public static void browserQuit() { + org.openqa.selenium.WebDriver driver = null; + try { + driver = WebDriverRunner.getWebDriver(); + } catch (Throwable ignored) { } - - @Step - public static void loggerSetup() { - SelenideLogger.addListener("AllureSelenide", new AllureSelenide() - .screenshots(true) - .savePageSource(false)); + if (driver != null) { + driver.quit(); } + } + + @Step + public static void loggerSetup() { + SelenideLogger.addListener("AllureSelenide", new AllureSelenide() + .screenshots(true) + .savePageSource(false)); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/AllureListener.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/AllureListener.java index 74119f848..61125408c 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/AllureListener.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/AllureListener.java @@ -1,35 +1,39 @@ package com.provectus.kafka.ui.settings.listeners; +import static java.nio.file.Files.newInputStream; + import com.codeborne.selenide.Screenshots; import io.qameta.allure.Allure; import io.qameta.allure.testng.AllureTestNg; -import org.testng.ITestListener; -import org.testng.ITestResult; - import java.io.File; import java.io.IOException; -import java.util.Objects; - -import static java.nio.file.Files.newInputStream; +import lombok.extern.slf4j.Slf4j; +import org.testng.ITestListener; +import org.testng.ITestResult; +@Slf4j public class AllureListener extends AllureTestNg implements ITestListener { - private void takeScreenshot() { - File screenshot = Screenshots.takeScreenShotAsFile(); - try { - Allure.addAttachment(Objects.requireNonNull(screenshot).getName(), newInputStream(screenshot.toPath())); - } catch (IOException e) { - throw new RuntimeException(e); - } + private void takeScreenshot() { + File screenshot = Screenshots.takeScreenShotAsFile(); + try { + if (screenshot != null) { + Allure.addAttachment(screenshot.getName(), newInputStream(screenshot.toPath())); + } else { + log.warn("Unable to take screenshot"); + } + } catch (IOException e) { + throw new RuntimeException(e); } + } - @Override - public void onTestFailure(ITestResult result) { - takeScreenshot(); - } + @Override + public void onTestFailure(ITestResult result) { + takeScreenshot(); + } - @Override - public void onTestSkipped(ITestResult result) { - takeScreenshot(); - } + @Override + public void onTestSkipped(ITestResult result) { + takeScreenshot(); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/LoggerListener.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/LoggerListener.java index ca096cd23..81f510f75 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/LoggerListener.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/LoggerListener.java @@ -7,31 +7,31 @@ @Slf4j public class LoggerListener extends TestListenerAdapter { - @Override - public void onTestStart(final ITestResult testResult) { - log.info(String.format("\n------------------------------------------------------------------------ " + - "\nTEST STARTED: %s.%s \n------------------------------------------------------------------------ \n", - testResult.getInstanceName(), testResult.getName())); - } + @Override + public void onTestStart(final ITestResult testResult) { + log.info(String.format("\n------------------------------------------------------------------------ " + + "\nTEST STARTED: %s.%s \n------------------------------------------------------------------------ \n", + testResult.getInstanceName(), testResult.getName())); + } - @Override - public void onTestSuccess(final ITestResult testResult) { - log.info(String.format("\n------------------------------------------------------------------------ " + - "\nTEST PASSED: %s.%s \n------------------------------------------------------------------------ \n", - testResult.getInstanceName(), testResult.getName())); - } + @Override + public void onTestSuccess(final ITestResult testResult) { + log.info(String.format("\n------------------------------------------------------------------------ " + + "\nTEST PASSED: %s.%s \n------------------------------------------------------------------------ \n", + testResult.getInstanceName(), testResult.getName())); + } - @Override - public void onTestFailure(final ITestResult testResult) { - log.info(String.format("\n------------------------------------------------------------------------ " + - "\nTEST FAILED: %s.%s \n------------------------------------------------------------------------ \n", - testResult.getInstanceName(), testResult.getName())); - } + @Override + public void onTestFailure(final ITestResult testResult) { + log.info(String.format("\n------------------------------------------------------------------------ " + + "\nTEST FAILED: %s.%s \n------------------------------------------------------------------------ \n", + testResult.getInstanceName(), testResult.getName())); + } - @Override - public void onTestSkipped(final ITestResult testResult) { - log.info(String.format("\n------------------------------------------------------------------------ " + - "\nTEST SKIPPED: %s.%s \n------------------------------------------------------------------------ \n", - testResult.getInstanceName(), testResult.getName())); - } + @Override + public void onTestSkipped(final ITestResult testResult) { + log.info(String.format("\n------------------------------------------------------------------------ " + + "\nTEST SKIPPED: %s.%s \n------------------------------------------------------------------------ \n", + testResult.getInstanceName(), testResult.getName())); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/QaseCreateListener.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/QaseCreateListener.java index c40481c30..ac3f84eba 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/QaseCreateListener.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/QaseCreateListener.java @@ -1,14 +1,28 @@ package com.provectus.kafka.ui.settings.listeners; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Status; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Suite; +import static io.qase.api.utils.IntegrationUtils.getCaseTitle; + +import com.provectus.kafka.ui.utilities.qase.annotations.Automation; +import com.provectus.kafka.ui.utilities.qase.annotations.Status; +import com.provectus.kafka.ui.utilities.qase.annotations.Suite; import io.qase.api.QaseClient; import io.qase.api.StepStorage; import io.qase.api.annotation.QaseId; import io.qase.client.ApiClient; import io.qase.client.api.CasesApi; -import io.qase.client.model.*; +import io.qase.client.model.GetCasesFiltersParameter; +import io.qase.client.model.ResultCreateStepsInner; +import io.qase.client.model.TestCase; +import io.qase.client.model.TestCaseCreate; +import io.qase.client.model.TestCaseCreateStepsInner; +import io.qase.client.model.TestCaseListResponse; +import io.qase.client.model.TestCaseListResponseAllOfResult; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.testng.Assert; @@ -16,108 +30,107 @@ import org.testng.ITestResult; import org.testng.TestListenerAdapter; -import java.lang.reflect.Method; -import java.util.*; - -import static io.qase.api.utils.IntegrationUtils.getCaseTitle; - @Slf4j public class QaseCreateListener extends TestListenerAdapter implements ITestListener { - private static final CasesApi QASE_API = getQaseApi(); + private static final CasesApi QASE_API = getQaseApi(); - private static CasesApi getQaseApi() { - ApiClient apiClient = QaseClient.getApiClient(); - apiClient.setApiKey(System.getProperty("QASEIO_API_TOKEN")); - return new CasesApi(apiClient); - } + private static CasesApi getQaseApi() { + ApiClient apiClient = QaseClient.getApiClient(); + apiClient.setApiKey(System.getProperty("QASEIO_API_TOKEN")); + return new CasesApi(apiClient); + } - private static int getStatus(Method method) { - if (method.isAnnotationPresent(Status.class)) - return method.getDeclaredAnnotation(Status.class).status().getValue(); - return 1; + private static int getStatus(Method method) { + if (method.isAnnotationPresent(Status.class)) { + return method.getDeclaredAnnotation(Status.class).status().getValue(); } + return 1; + } - private static int getAutomation(Method method) { - if (method.isAnnotationPresent(Automation.class)) - return method.getDeclaredAnnotation(Automation.class).state().getValue(); - return 0; + private static int getAutomation(Method method) { + if (method.isAnnotationPresent(Automation.class)) { + return method.getDeclaredAnnotation(Automation.class).state().getValue(); } + return 0; + } - @SneakyThrows - private static HashMap getCaseTitlesAndIdsFromQase() { - HashMap cases = new HashMap<>(); - boolean getCases = true; - int offSet = 0; - while (getCases) { - getCases = false; - TestCaseListResponse response = QASE_API.getCases(System.getProperty("QASE_PROJECT_CODE"), - new GetCasesFiltersParameter().status(GetCasesFiltersParameter.SERIALIZED_NAME_STATUS), 100, offSet); - TestCaseListResponseAllOfResult result = response.getResult(); - Assert.assertNotNull(result); - List entities = result.getEntities(); - Assert.assertNotNull(entities); - if (entities.size() > 0) { - for (TestCase testCase : entities) { - cases.put(testCase.getId(), testCase.getTitle()); - } - offSet = offSet + 100; - getCases = true; - } + @SneakyThrows + private static HashMap getCaseTitlesAndIdsFromQase() { + HashMap cases = new HashMap<>(); + boolean getCases = true; + int offSet = 0; + while (getCases) { + getCases = false; + TestCaseListResponse response = QASE_API.getCases(System.getProperty("QASE_PROJECT_CODE"), + new GetCasesFiltersParameter().status(GetCasesFiltersParameter.SERIALIZED_NAME_STATUS), 100, offSet); + TestCaseListResponseAllOfResult result = response.getResult(); + Assert.assertNotNull(result); + List entities = result.getEntities(); + Assert.assertNotNull(entities); + if (entities.size() > 0) { + for (TestCase testCase : entities) { + cases.put(testCase.getId(), testCase.getTitle()); } - return cases; + offSet = offSet + 100; + getCases = true; + } } + return cases; + } - private static boolean isCaseWithTitleExistInQase(Method method) { - HashMap cases = getCaseTitlesAndIdsFromQase(); - String title = getCaseTitle(method); - if (cases.containsValue(title)) { - for (Map.Entry map : cases.entrySet()) { - if (map.getValue().matches(title)) { - long id = map.getKey(); - log.warn(String.format("Test case with @QaseTitle='%s' already exists with @QaseId=%d. " + - "Please verify @QaseTitle annotation", title, id)); - return true; - } - } + private static boolean isCaseWithTitleExistInQase(Method method) { + HashMap cases = getCaseTitlesAndIdsFromQase(); + String title = getCaseTitle(method); + if (cases.containsValue(title)) { + for (Map.Entry map : cases.entrySet()) { + if (map.getValue().matches(title)) { + long id = map.getKey(); + log.warn(String.format("Test case with @QaseTitle='%s' already exists with @QaseId=%d. " + + "Please verify @QaseTitle annotation", title, id)); + return true; } - return false; + } } + return false; + } - @Override - @SneakyThrows - public void onTestSuccess(final ITestResult testResult) { - Method method = testResult.getMethod() - .getConstructorOrMethod() - .getMethod(); - String title = getCaseTitle(method); - if (!method.isAnnotationPresent(QaseId.class)) { - if (title != null) { - if (!isCaseWithTitleExistInQase(method)) { - LinkedList resultSteps = StepStorage.stopSteps(); - LinkedList createSteps = new LinkedList<>(); - resultSteps.forEach(step -> { - TestCaseCreateStepsInner caseStep = new TestCaseCreateStepsInner(); - caseStep.setAction(step.getAction()); - caseStep.setExpectedResult(step.getExpectedResult()); - createSteps.add(caseStep); - }); - TestCaseCreate newCase = new TestCaseCreate(); - newCase.setTitle(title); - newCase.setStatus(getStatus(method)); - newCase.setAutomation(getAutomation(method)); - newCase.setSteps(createSteps); - if (method.isAnnotationPresent(Suite.class)) { - long suiteId = method.getDeclaredAnnotation(Suite.class).id(); - newCase.suiteId(suiteId); - } - Long id = Objects.requireNonNull(QASE_API.createCase(System.getProperty("QASE_PROJECT_CODE"), - newCase).getResult()).getId(); - log.info(String.format("New test case '%s' was created with @QaseId=%d", title, id)); - } - } else - log.warn("To create new test case in Qase.io please add @QaseTitle annotation"); - } else - log.warn("To create new test case in Qase.io please remove @QaseId annotation"); + @Override + @SneakyThrows + public void onTestSuccess(final ITestResult testResult) { + Method method = testResult.getMethod() + .getConstructorOrMethod() + .getMethod(); + String title = getCaseTitle(method); + if (!method.isAnnotationPresent(QaseId.class)) { + if (title != null) { + if (!isCaseWithTitleExistInQase(method)) { + LinkedList resultSteps = StepStorage.stopSteps(); + LinkedList createSteps = new LinkedList<>(); + resultSteps.forEach(step -> { + TestCaseCreateStepsInner caseStep = new TestCaseCreateStepsInner(); + caseStep.setAction(step.getAction()); + caseStep.setExpectedResult(step.getExpectedResult()); + createSteps.add(caseStep); + }); + TestCaseCreate newCase = new TestCaseCreate(); + newCase.setTitle(title); + newCase.setStatus(getStatus(method)); + newCase.setAutomation(getAutomation(method)); + newCase.setSteps(createSteps); + if (method.isAnnotationPresent(Suite.class)) { + long suiteId = method.getDeclaredAnnotation(Suite.class).id(); + newCase.suiteId(suiteId); + } + Long id = Objects.requireNonNull(QASE_API.createCase(System.getProperty("QASE_PROJECT_CODE"), + newCase).getResult()).getId(); + log.info(String.format("New test case '%s' was created with @QaseId=%d", title, id)); + } + } else { + log.warn("To create new test case in Qase.io please add @QaseTitle annotation"); + } + } else { + log.warn("To create new test case in Qase.io please remove @QaseId annotation"); } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/QaseResultListener.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/QaseResultListener.java index 72056db92..d413ca4a2 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/QaseResultListener.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/settings/listeners/QaseResultListener.java @@ -1,5 +1,12 @@ package com.provectus.kafka.ui.settings.listeners; +import static io.qase.api.utils.IntegrationUtils.getCaseId; +import static io.qase.api.utils.IntegrationUtils.getCaseTitle; +import static io.qase.api.utils.IntegrationUtils.getStacktrace; +import static io.qase.client.model.ResultCreate.StatusEnum.FAILED; +import static io.qase.client.model.ResultCreate.StatusEnum.PASSED; +import static io.qase.client.model.ResultCreate.StatusEnum.SKIPPED; + import io.qase.api.StepStorage; import io.qase.api.config.QaseConfig; import io.qase.api.services.QaseTestCaseListener; @@ -7,6 +14,9 @@ import io.qase.client.model.ResultCreateCase; import io.qase.client.model.ResultCreateStepsInner; import io.qase.testng.guice.module.TestNgModule; +import java.lang.reflect.Method; +import java.util.LinkedList; +import java.util.Optional; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -15,88 +25,81 @@ import org.testng.ITestResult; import org.testng.TestListenerAdapter; -import java.lang.reflect.Method; -import java.util.LinkedList; -import java.util.Optional; - -import static io.qase.api.utils.IntegrationUtils.*; -import static io.qase.client.model.ResultCreate.StatusEnum.*; - @Slf4j public class QaseResultListener extends TestListenerAdapter implements ITestListener { - private static final String REPORTER_NAME = "TestNG"; + private static final String REPORTER_NAME = "TestNG"; - static { - System.setProperty(QaseConfig.QASE_CLIENT_REPORTER_NAME_KEY, REPORTER_NAME); - } + static { + System.setProperty(QaseConfig.QASE_CLIENT_REPORTER_NAME_KEY, REPORTER_NAME); + } - @Getter(lazy = true, value = AccessLevel.PRIVATE) - private final QaseTestCaseListener qaseTestCaseListener = createQaseListener(); + @Getter(lazy = true, value = AccessLevel.PRIVATE) + private final QaseTestCaseListener qaseTestCaseListener = createQaseListener(); - private static QaseTestCaseListener createQaseListener() { - return TestNgModule.getInjector().getInstance(QaseTestCaseListener.class); - } + private static QaseTestCaseListener createQaseListener() { + return TestNgModule.getInjector().getInstance(QaseTestCaseListener.class); + } - @Override - public void onTestStart(ITestResult tr) { - getQaseTestCaseListener().onTestCaseStarted(); - super.onTestStart(tr); - } + @Override + public void onTestStart(ITestResult tr) { + getQaseTestCaseListener().onTestCaseStarted(); + super.onTestStart(tr); + } - @Override - public void onTestSuccess(ITestResult tr) { - getQaseTestCaseListener() - .onTestCaseFinished(resultCreate -> setupResultItem(resultCreate, tr, PASSED)); - super.onTestSuccess(tr); - } + @Override + public void onTestSuccess(ITestResult tr) { + getQaseTestCaseListener() + .onTestCaseFinished(resultCreate -> setupResultItem(resultCreate, tr, PASSED)); + super.onTestSuccess(tr); + } - @Override - public void onTestSkipped(ITestResult tr) { - getQaseTestCaseListener() - .onTestCaseFinished(resultCreate -> setupResultItem(resultCreate, tr, SKIPPED)); - super.onTestSuccess(tr); - } + @Override + public void onTestSkipped(ITestResult tr) { + getQaseTestCaseListener() + .onTestCaseFinished(resultCreate -> setupResultItem(resultCreate, tr, SKIPPED)); + super.onTestSuccess(tr); + } - @Override - public void onTestFailure(ITestResult tr) { - getQaseTestCaseListener() - .onTestCaseFinished(resultCreate -> setupResultItem(resultCreate, tr, FAILED)); - super.onTestFailure(tr); - } + @Override + public void onTestFailure(ITestResult tr) { + getQaseTestCaseListener() + .onTestCaseFinished(resultCreate -> setupResultItem(resultCreate, tr, FAILED)); + super.onTestFailure(tr); + } - @Override - public void onFinish(ITestContext testContext) { - getQaseTestCaseListener().onTestCasesSetFinished(); - super.onFinish(testContext); - } + @Override + public void onFinish(ITestContext testContext) { + getQaseTestCaseListener().onTestCasesSetFinished(); + super.onFinish(testContext); + } - private void setupResultItem(ResultCreate resultCreate, ITestResult result, ResultCreate.StatusEnum status) { - Optional resultThrowable = Optional.ofNullable(result.getThrowable()); - String comment = resultThrowable - .flatMap(throwable -> Optional.of(throwable.toString())).orElse(null); - Boolean isDefect = resultThrowable - .flatMap(throwable -> Optional.of(throwable instanceof AssertionError)) - .orElse(false); - String stacktrace = resultThrowable - .flatMap(throwable -> Optional.of(getStacktrace(throwable))) - .orElse(null); - Method method = result.getMethod() - .getConstructorOrMethod() - .getMethod(); - Long caseId = getCaseId(method); - String caseTitle = null; - if (caseId == null) { - caseTitle = getCaseTitle(method); - } - LinkedList steps = StepStorage.stopSteps(); - resultCreate - ._case(caseTitle == null ? null : new ResultCreateCase().title(caseTitle)) - .caseId(caseId) - .status(status) - .comment(comment) - .stacktrace(stacktrace) - .steps(steps.isEmpty() ? null : steps) - .defect(isDefect); + private void setupResultItem(ResultCreate resultCreate, ITestResult result, ResultCreate.StatusEnum status) { + Optional resultThrowable = Optional.ofNullable(result.getThrowable()); + String comment = resultThrowable + .flatMap(throwable -> Optional.of(throwable.toString())).orElse(null); + Boolean isDefect = resultThrowable + .flatMap(throwable -> Optional.of(throwable instanceof AssertionError)) + .orElse(false); + String stacktrace = resultThrowable + .flatMap(throwable -> Optional.of(getStacktrace(throwable))) + .orElse(null); + Method method = result.getMethod() + .getConstructorOrMethod() + .getMethod(); + Long caseId = getCaseId(method); + String caseTitle = null; + if (caseId == null) { + caseTitle = getCaseTitle(method); } + LinkedList steps = StepStorage.stopSteps(); + resultCreate + ._case(caseTitle == null ? null : new ResultCreateCase().title(caseTitle)) + .caseId(caseId) + .status(status) + .comment(comment) + .stacktrace(stacktrace) + .steps(steps.isEmpty() ? null : steps) + .defect(isDefect); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/FileUtils.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/FileUtils.java index c2489a86c..8bb57809b 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/FileUtils.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/FileUtils.java @@ -1,27 +1,26 @@ package com.provectus.kafka.ui.utilities; -import org.testcontainers.shaded.org.apache.commons.io.IOUtils; +import static org.apache.kafka.common.utils.Utils.readFileAsString; import java.io.IOException; import java.nio.charset.StandardCharsets; - -import static org.apache.kafka.common.utils.Utils.readFileAsString; +import org.testcontainers.shaded.org.apache.commons.io.IOUtils; public class FileUtils { - public static String getResourceAsString(String resourceFileName) { - try { - return IOUtils.resourceToString("/" + resourceFileName, StandardCharsets.UTF_8); - } catch (IOException e) { - throw new RuntimeException(e); - } + public static String getResourceAsString(String resourceFileName) { + try { + return IOUtils.resourceToString("/" + resourceFileName, StandardCharsets.UTF_8); + } catch (IOException e) { + throw new RuntimeException(e); } + } - public static String fileToString(String path) { - try { - return readFileAsString(path); - } catch (IOException e) { - throw new RuntimeException(e); - } + public static String fileToString(String path) { + try { + return readFileAsString(path); + } catch (IOException e) { + throw new RuntimeException(e); } + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/TimeUtils.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/TimeUtils.java index f53e8897e..7f72f8a4d 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/TimeUtils.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/TimeUtils.java @@ -1,17 +1,16 @@ package com.provectus.kafka.ui.utilities; -import lombok.extern.slf4j.Slf4j; +import static com.codeborne.selenide.Selenide.sleep; import java.time.LocalTime; - -import static com.codeborne.selenide.Selenide.sleep; +import lombok.extern.slf4j.Slf4j; @Slf4j public class TimeUtils { - public static void waitUntilNewMinuteStarted() { - int secondsLeft = 60 - LocalTime.now().getSecond(); - log.debug("\nwaitUntilNewMinuteStarted: {}s", secondsLeft); - sleep(secondsLeft * 1000); - } + public static void waitUntilNewMinuteStarted() { + int secondsLeft = 60 - LocalTime.now().getSecond(); + log.debug("\nwaitUntilNewMinuteStarted: {}s", secondsLeft); + sleep(secondsLeft * 1000); + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java index 427662d9d..fef5ef654 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/WebUtils.java @@ -1,105 +1,110 @@ package com.provectus.kafka.ui.utilities; +import static com.codeborne.selenide.Selenide.executeJavaScript; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.codeborne.selenide.WebDriverRunner; +import java.time.Duration; import lombok.extern.slf4j.Slf4j; import org.openqa.selenium.Keys; import org.openqa.selenium.interactions.Actions; -import java.time.Duration; - -import static com.codeborne.selenide.Selenide.executeJavaScript; - @Slf4j public class WebUtils { - public static int getTimeout(int... timeoutInSeconds) { - return (timeoutInSeconds != null && timeoutInSeconds.length > 0) ? timeoutInSeconds[0] : 4; - } + public static int getTimeout(int... timeoutInSeconds) { + return (timeoutInSeconds != null && timeoutInSeconds.length > 0) ? timeoutInSeconds[0] : 4; + } - public static void sendKeysAfterClear(SelenideElement element, String keys) { - log.debug("\nsendKeysAfterClear: {} \nsend keys '{}'", element.getSearchCriteria(), keys); - element.shouldBe(Condition.enabled).clear(); - if (keys != null) element.sendKeys(keys); + public static void sendKeysAfterClear(SelenideElement element, String keys) { + log.debug("\nsendKeysAfterClear: {} \nsend keys '{}'", element.getSearchCriteria(), keys); + element.shouldBe(Condition.enabled).clear(); + if (keys != null) { + element.sendKeys(keys); } + } - public static void clickByActions(SelenideElement element) { - log.debug("\nclickByActions: {}", element.getSearchCriteria()); - element.shouldBe(Condition.enabled); - new Actions(WebDriverRunner.getWebDriver()) - .moveToElement(element) - .click(element) - .perform(); - } + public static void clickByActions(SelenideElement element) { + log.debug("\nclickByActions: {}", element.getSearchCriteria()); + element.shouldBe(Condition.enabled); + new Actions(WebDriverRunner.getWebDriver()) + .moveToElement(element) + .click(element) + .perform(); + } - public static void sendKeysByActions(SelenideElement element, String keys) { - log.debug("\nsendKeysByActions: {} \nsend keys '{}'", element.getSearchCriteria(), keys); - element.shouldBe(Condition.enabled); - new Actions(WebDriverRunner.getWebDriver()) - .moveToElement(element) - .sendKeys(element, keys) - .perform(); - } + public static void sendKeysByActions(SelenideElement element, String keys) { + log.debug("\nsendKeysByActions: {} \nsend keys '{}'", element.getSearchCriteria(), keys); + element.shouldBe(Condition.enabled); + new Actions(WebDriverRunner.getWebDriver()) + .moveToElement(element) + .sendKeys(element, keys) + .perform(); + } - public static void clickByJavaScript(SelenideElement element) { - log.debug("\nclickByJavaScript: {}", element.getSearchCriteria()); - element.shouldBe(Condition.enabled); - String script = "arguments[0].click();"; - executeJavaScript(script, element); - } + public static void clickByJavaScript(SelenideElement element) { + log.debug("\nclickByJavaScript: {}", element.getSearchCriteria()); + element.shouldBe(Condition.enabled); + String script = "arguments[0].click();"; + executeJavaScript(script, element); + } - public static void clearByKeyboard(SelenideElement field) { - log.debug("\nclearByKeyboard: {}", field.getSearchCriteria()); - field.shouldBe(Condition.enabled).sendKeys(Keys.END); - field.sendKeys(Keys.chord(Keys.CONTROL + "a"), Keys.DELETE); - } + public static void clearByKeyboard(SelenideElement field) { + log.debug("\nclearByKeyboard: {}", field.getSearchCriteria()); + field.shouldBe(Condition.enabled).sendKeys(Keys.END); + field.sendKeys(Keys.chord(Keys.CONTROL + "a"), Keys.DELETE); + } - public static boolean isVisible(SelenideElement element, int... timeoutInSeconds) { - log.debug("\nisVisible: {}", element.getSearchCriteria()); - boolean isVisible = false; - try { - element.shouldBe(Condition.visible, - Duration.ofSeconds(getTimeout(timeoutInSeconds))); - isVisible = true; - } catch (Throwable e) { - log.debug("{} is not visible", element.getSearchCriteria()); - } - return isVisible; + public static boolean isVisible(SelenideElement element, int... timeoutInSeconds) { + log.debug("\nisVisible: {}", element.getSearchCriteria()); + boolean isVisible = false; + try { + element.shouldBe(Condition.visible, + Duration.ofSeconds(getTimeout(timeoutInSeconds))); + isVisible = true; + } catch (Throwable e) { + log.debug("{} is not visible", element.getSearchCriteria()); } + return isVisible; + } - public static boolean isEnabled(SelenideElement element, int... timeoutInSeconds) { - log.debug("\nisEnabled: {}", element.getSearchCriteria()); - boolean isEnabled = false; - try { - element.shouldBe(Condition.enabled, - Duration.ofSeconds(getTimeout(timeoutInSeconds))); - isEnabled = true; - } catch (Throwable e) { - log.debug("{} is not enabled", element.getSearchCriteria()); - } - return isEnabled; + public static boolean isEnabled(SelenideElement element, int... timeoutInSeconds) { + log.debug("\nisEnabled: {}", element.getSearchCriteria()); + boolean isEnabled = false; + try { + element.shouldBe(Condition.enabled, + Duration.ofSeconds(getTimeout(timeoutInSeconds))); + isEnabled = true; + } catch (Throwable e) { + log.debug("{} is not enabled", element.getSearchCriteria()); } + return isEnabled; + } - public static boolean isSelected(SelenideElement element, int... timeoutInSeconds) { - log.debug("\nisSelected: {}", element.getSearchCriteria()); - boolean isSelected = false; - try { - element.shouldBe(Condition.selected, - Duration.ofSeconds(getTimeout(timeoutInSeconds))); - isSelected = true; - } catch (Throwable e) { - log.debug("{} is not selected", element.getSearchCriteria()); - } - return isSelected; + public static boolean isSelected(SelenideElement element, int... timeoutInSeconds) { + log.debug("\nisSelected: {}", element.getSearchCriteria()); + boolean isSelected = false; + try { + element.shouldBe(Condition.selected, + Duration.ofSeconds(getTimeout(timeoutInSeconds))); + isSelected = true; + } catch (Throwable e) { + log.debug("{} is not selected", element.getSearchCriteria()); } + return isSelected; + } - public static boolean selectElement(SelenideElement element, boolean select) { - if (select) { - if (!element.isSelected()) clickByJavaScript(element); - } else { - if (element.isSelected()) clickByJavaScript(element); - } - return true; + public static boolean selectElement(SelenideElement element, boolean select) { + if (select) { + if (!element.isSelected()) { + clickByJavaScript(element); + } + } else { + if (element.isSelected()) { + clickByJavaScript(element); + } } + return true; + } } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/QaseSetup.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/QaseSetup.java new file mode 100644 index 000000000..f0ed509aa --- /dev/null +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/QaseSetup.java @@ -0,0 +1,33 @@ +package com.provectus.kafka.ui.utilities.qase; + +import static com.provectus.kafka.ui.settings.BaseSource.SUITE_NAME; +import static com.provectus.kafka.ui.variables.Suite.MANUAL; +import static org.apache.commons.lang3.BooleanUtils.FALSE; +import static org.apache.commons.lang3.BooleanUtils.TRUE; +import static org.apache.commons.lang3.StringUtils.isEmpty; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class QaseSetup { + + public static void qaseIntegrationSetup() { + String qaseApiToken = System.getProperty("QASEIO_API_TOKEN"); + if (isEmpty(qaseApiToken)) { + log.warn("Integration with Qase is disabled due to run config or token wasn't defined."); + System.setProperty("QASE_ENABLE", FALSE); + } else { + log.warn("Integration with Qase is enabled. Find this run at https://app.qase.io/run/KAFKAUI."); + String automation = SUITE_NAME.equalsIgnoreCase(MANUAL) ? "" : "Automation "; + System.setProperty("QASE_ENABLE", TRUE); + System.setProperty("QASE_PROJECT_CODE", "KAFKAUI"); + System.setProperty("QASE_API_TOKEN", qaseApiToken); + System.setProperty("QASE_USE_BULK", TRUE); + System.setProperty("QASE_RUN_NAME", DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm") + .format(OffsetDateTime.now(ZoneOffset.UTC)) + ": " + automation + SUITE_NAME.toUpperCase() + " suite"); + } + } +} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Automation.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Automation.java similarity index 63% rename from kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Automation.java rename to kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Automation.java index 556263c11..1b8d5b65b 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Automation.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Automation.java @@ -1,7 +1,6 @@ -package com.provectus.kafka.ui.utilities.qaseUtils.annotations; - -import com.provectus.kafka.ui.utilities.qaseUtils.enums.State; +package com.provectus.kafka.ui.utilities.qase.annotations; +import com.provectus.kafka.ui.utilities.qase.enums.State; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -11,5 +10,5 @@ @Retention(RetentionPolicy.RUNTIME) public @interface Automation { - State state(); + State state(); } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Status.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Status.java similarity index 65% rename from kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Status.java rename to kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Status.java index 3c31f2345..df078d043 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Status.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Status.java @@ -1,4 +1,4 @@ -package com.provectus.kafka.ui.utilities.qaseUtils.annotations; +package com.provectus.kafka.ui.utilities.qase.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -9,5 +9,5 @@ @Retention(RetentionPolicy.RUNTIME) public @interface Status { - com.provectus.kafka.ui.utilities.qaseUtils.enums.Status status(); + com.provectus.kafka.ui.utilities.qase.enums.Status status(); } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Suite.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Suite.java similarity index 76% rename from kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Suite.java rename to kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Suite.java index fa1c2c3dd..fcaff0974 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/annotations/Suite.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/annotations/Suite.java @@ -1,4 +1,4 @@ -package com.provectus.kafka.ui.utilities.qaseUtils.annotations; +package com.provectus.kafka.ui.utilities.qase.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -9,5 +9,5 @@ @Retention(RetentionPolicy.RUNTIME) public @interface Suite { - long id(); + long id(); } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/enums/State.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/enums/State.java new file mode 100644 index 000000000..11f49d564 --- /dev/null +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/enums/State.java @@ -0,0 +1,18 @@ +package com.provectus.kafka.ui.utilities.qase.enums; + +public enum State { + + NOT_AUTOMATED(0), + TO_BE_AUTOMATED(1), + AUTOMATED(2); + + private final int value; + + State(int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/enums/Status.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/enums/Status.java new file mode 100644 index 000000000..a4e7e0cce --- /dev/null +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qase/enums/Status.java @@ -0,0 +1,18 @@ +package com.provectus.kafka.ui.utilities.qase.enums; + +public enum Status { + + ACTUAL(0), + DRAFT(1), + DEPRECATED(2); + + private final int value; + + Status(int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/QaseSetup.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/QaseSetup.java deleted file mode 100644 index 60be014a0..000000000 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/QaseSetup.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.provectus.kafka.ui.utilities.qaseUtils; - -import lombok.extern.slf4j.Slf4j; - -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; - -import static com.provectus.kafka.ui.settings.BaseSource.SUITE_NAME; -import static com.provectus.kafka.ui.variables.Suite.MANUAL; -import static org.apache.commons.lang3.BooleanUtils.FALSE; -import static org.apache.commons.lang3.BooleanUtils.TRUE; -import static org.apache.commons.lang3.StringUtils.isEmpty; - -@Slf4j -public class QaseSetup { - - public static void qaseIntegrationSetup() { - String qaseApiToken = System.getProperty("QASEIO_API_TOKEN"); - if (isEmpty(qaseApiToken)) { - log.warn("Integration with Qase is disabled due to run config or token wasn't defined."); - System.setProperty("QASE_ENABLE", FALSE); - } else { - log.warn("Integration with Qase is enabled. Find this run at https://app.qase.io/run/KAFKAUI."); - String automation = SUITE_NAME.equalsIgnoreCase(MANUAL) ? "" : "Automation "; - System.setProperty("QASE_ENABLE", TRUE); - System.setProperty("QASE_PROJECT_CODE", "KAFKAUI"); - System.setProperty("QASE_API_TOKEN", qaseApiToken); - System.setProperty("QASE_USE_BULK", TRUE); - System.setProperty("QASE_RUN_NAME", DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm") - .format(OffsetDateTime.now(ZoneOffset.UTC)) + ": " + automation + SUITE_NAME.toUpperCase() + " suite"); - } - } -} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/enums/State.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/enums/State.java deleted file mode 100644 index cdbbaf38d..000000000 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/enums/State.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.provectus.kafka.ui.utilities.qaseUtils.enums; - -public enum State { - - NOT_AUTOMATED(0), - TO_BE_AUTOMATED(1), - AUTOMATED(2); - - private final int value; - - State(int value) { - this.value = value; - } - - public int getValue() { - return value; - } -} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/enums/Status.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/enums/Status.java deleted file mode 100644 index adc8bf24b..000000000 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/utilities/qaseUtils/enums/Status.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.provectus.kafka.ui.utilities.qaseUtils.enums; - -public enum Status { - - ACTUAL(0), - DRAFT(1), - DEPRECATED(2); - - private final int value; - - Status(int value) { - this.value = value; - } - - public int getValue() { - return value; - } -} diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Browser.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Browser.java index cb3873cdb..f435dcbf0 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Browser.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Browser.java @@ -2,6 +2,6 @@ public interface Browser { - String CONTAINER = "container"; - String LOCAL = "local"; + String CONTAINER = "container"; + String LOCAL = "local"; } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Suite.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Suite.java index 74f60dd0d..3d337548c 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Suite.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Suite.java @@ -2,9 +2,9 @@ public interface Suite { - String CUSTOM = "custom"; - String MANUAL = "manual"; - String REGRESSION = "regression"; - String SANITY = "sanity"; - String SMOKE = "smoke"; + String CUSTOM = "custom"; + String MANUAL = "manual"; + String REGRESSION = "regression"; + String SANITY = "sanity"; + String SMOKE = "smoke"; } diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Url.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Url.java index 8800463bd..5b800608f 100644 --- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Url.java +++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/variables/Url.java @@ -2,10 +2,10 @@ public interface Url { - String BROKERS_LIST_URL = "http://%s:8080/ui/clusters/local/brokers"; - String TOPICS_LIST_URL = "http://%s:8080/ui/clusters/local/all-topics"; - String CONSUMERS_LIST_URL = "http://%s:8080/ui/clusters/local/consumer-groups"; - String SCHEMA_REGISTRY_LIST_URL = "http://%s:8080/ui/clusters/local/schemas"; - String KAFKA_CONNECT_LIST_URL = "http://%s:8080/ui/clusters/local/connectors"; - String KSQL_DB_LIST_URL = "http://%s:8080/ui/clusters/local/ksqldb/tables"; + String BROKERS_LIST_URL = "http://%s:8080/ui/clusters/local/brokers"; + String TOPICS_LIST_URL = "http://%s:8080/ui/clusters/local/all-topics"; + String CONSUMERS_LIST_URL = "http://%s:8080/ui/clusters/local/consumer-groups"; + String SCHEMA_REGISTRY_LIST_URL = "http://%s:8080/ui/clusters/local/schemas"; + String KAFKA_CONNECT_LIST_URL = "http://%s:8080/ui/clusters/local/connectors"; + String KSQL_DB_LIST_URL = "http://%s:8080/ui/clusters/local/ksqldb/tables"; } diff --git a/kafka-ui-e2e-checks/src/main/resources/testData/connectors/config_for_create_connector.json b/kafka-ui-e2e-checks/src/main/resources/testData/connectors/config_for_create_connector.json index fbe9fea65..096d4191e 100644 --- a/kafka-ui-e2e-checks/src/main/resources/testData/connectors/config_for_create_connector.json +++ b/kafka-ui-e2e-checks/src/main/resources/testData/connectors/config_for_create_connector.json @@ -15,4 +15,4 @@ "insert.mode": "upsert", "errors.log.enable": "true", "errors.log.include.messages": "true" -} \ No newline at end of file +} diff --git a/kafka-ui-e2e-checks/src/main/resources/testData/connectors/config_for_create_connector_via_api.json b/kafka-ui-e2e-checks/src/main/resources/testData/connectors/config_for_create_connector_via_api.json index 5c5b7aba8..dffd66cae 100644 --- a/kafka-ui-e2e-checks/src/main/resources/testData/connectors/config_for_create_connector_via_api.json +++ b/kafka-ui-e2e-checks/src/main/resources/testData/connectors/config_for_create_connector_via_api.json @@ -4,4 +4,4 @@ "connection.user": "dev_user", "connection.password": "12345", "topics": "topic_for_connector" -} \ No newline at end of file +} diff --git a/kafka-ui-e2e-checks/src/main/resources/testData/connectors/delete_connector_config.json b/kafka-ui-e2e-checks/src/main/resources/testData/connectors/delete_connector_config.json index c5adc9944..121613fc1 100644 --- a/kafka-ui-e2e-checks/src/main/resources/testData/connectors/delete_connector_config.json +++ b/kafka-ui-e2e-checks/src/main/resources/testData/connectors/delete_connector_config.json @@ -15,4 +15,4 @@ "insert.mode": "upsert", "errors.log.enable": "true", "errors.log.include.messages": "true" -} \ No newline at end of file +} diff --git a/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_avro_for_update.json b/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_avro_for_update.json index 9971559ba..bbfe011c9 100644 --- a/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_avro_for_update.json +++ b/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_avro_for_update.json @@ -14,4 +14,4 @@ "default": null } ] -} \ No newline at end of file +} diff --git a/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_avro_value.json b/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_avro_value.json index 1bc30f6d1..d84caf2ea 100644 --- a/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_avro_value.json +++ b/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_avro_value.json @@ -12,4 +12,4 @@ "type": "int" } ] -} \ No newline at end of file +} diff --git a/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_json_Value.json b/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_json_Value.json index 5c5b7aba8..dffd66cae 100644 --- a/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_json_Value.json +++ b/kafka-ui-e2e-checks/src/main/resources/testData/schemas/schema_json_Value.json @@ -4,4 +4,4 @@ "connection.user": "dev_user", "connection.password": "12345", "topics": "topic_for_connector" -} \ No newline at end of file +} diff --git a/kafka-ui-e2e-checks/src/main/resources/testData/topics/message_content_create_topic.json b/kafka-ui-e2e-checks/src/main/resources/testData/topics/message_content_create_topic.json index 8c8fabe5b..a4c0d940f 100644 --- a/kafka-ui-e2e-checks/src/main/resources/testData/topics/message_content_create_topic.json +++ b/kafka-ui-e2e-checks/src/main/resources/testData/topics/message_content_create_topic.json @@ -21,4 +21,4 @@ "id":"1", "value":"kafka" } -} \ No newline at end of file +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/BaseTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/BaseTest.java index 424c699f0..45daf6a4b 100644 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/BaseTest.java +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/BaseTest.java @@ -1,5 +1,18 @@ package com.provectus.kafka.ui; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.BROKERS; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.CONSUMERS; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KAFKA_CONNECT; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KSQL_DB; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.SCHEMA_REGISTRY; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.TOPICS; +import static com.provectus.kafka.ui.settings.BaseSource.BASE_UI_URL; +import static com.provectus.kafka.ui.settings.drivers.WebDriver.browserClear; +import static com.provectus.kafka.ui.settings.drivers.WebDriver.browserQuit; +import static com.provectus.kafka.ui.settings.drivers.WebDriver.browserSetup; +import static com.provectus.kafka.ui.settings.drivers.WebDriver.loggerSetup; +import static com.provectus.kafka.ui.utilities.qase.QaseSetup.qaseIntegrationSetup; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.Selenide; import com.codeborne.selenide.SelenideElement; @@ -7,136 +20,134 @@ import com.provectus.kafka.ui.settings.listeners.LoggerListener; import com.provectus.kafka.ui.settings.listeners.QaseResultListener; import io.qameta.allure.Step; +import java.util.List; import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Listeners; import org.testng.asserts.SoftAssert; -import java.util.List; - -import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.*; -import static com.provectus.kafka.ui.settings.BaseSource.BASE_UI_URL; -import static com.provectus.kafka.ui.settings.drivers.WebDriver.*; -import static com.provectus.kafka.ui.utilities.qaseUtils.QaseSetup.qaseIntegrationSetup; - @Slf4j @Listeners({AllureListener.class, LoggerListener.class, QaseResultListener.class}) public abstract class BaseTest extends Facade { - @BeforeSuite(alwaysRun = true) - public void beforeSuite() { - qaseIntegrationSetup(); - loggerSetup(); - browserSetup(); - } - - @AfterSuite(alwaysRun = true) - public void afterSuite() { - browserQuit(); - } - - @BeforeMethod(alwaysRun = true) - public void beforeMethod() { - Selenide.open(BASE_UI_URL); - naviSideBar.waitUntilScreenReady(); - } - - @AfterMethod(alwaysRun = true) - public void afterMethod() { - browserClear(); - } - - @Step - protected void navigateToBrokers() { - naviSideBar - .openSideMenu(BROKERS); - brokersList - .waitUntilScreenReady(); - } - - @Step - protected void navigateToBrokersAndOpenDetails(int brokerId) { - naviSideBar - .openSideMenu(BROKERS); - brokersList - .waitUntilScreenReady() - .openBroker(brokerId); - brokersDetails - .waitUntilScreenReady(); - } - - @Step - protected void navigateToTopics() { - naviSideBar - .openSideMenu(TOPICS); - topicsList - .waitUntilScreenReady() - .setShowInternalRadioButton(false); - } - - @Step - protected void navigateToTopicsAndOpenDetails(String topicName) { - navigateToTopics(); - topicsList - .openTopic(topicName); - topicDetails - .waitUntilScreenReady(); - } - - @Step - protected void navigateToConsumers() { - naviSideBar - .openSideMenu(CONSUMERS); - consumersList - .waitUntilScreenReady(); - } - - @Step - protected void navigateToSchemaRegistry() { - naviSideBar - .openSideMenu(SCHEMA_REGISTRY); - schemaRegistryList - .waitUntilScreenReady(); - } - - @Step - protected void navigateToSchemaRegistryAndOpenDetails(String schemaName) { - navigateToSchemaRegistry(); - schemaRegistryList - .openSchema(schemaName); - schemaDetails - .waitUntilScreenReady(); - } - - @Step - protected void navigateToConnectors() { - naviSideBar - .openSideMenu(KAFKA_CONNECT); - kafkaConnectList - .waitUntilScreenReady(); - } - - @Step - protected void navigateToConnectorsAndOpenDetails(String connectorName) { - navigateToConnectors(); - kafkaConnectList - .openConnector(connectorName); - connectorDetails - .waitUntilScreenReady(); - } - - @Step - protected void navigateToKsqlDb() { - naviSideBar - .openSideMenu(KSQL_DB); - ksqlDbList - .waitUntilScreenReady(); - } - - @Step - protected void verifyElementsCondition(List elementList, Condition expectedCondition) { - SoftAssert softly = new SoftAssert(); - elementList.forEach(element -> softly.assertTrue(element.is(expectedCondition), - element.getSearchCriteria() + " is " + expectedCondition)); - softly.assertAll(); - } + @BeforeSuite(alwaysRun = true) + public void beforeSuite() { + qaseIntegrationSetup(); + loggerSetup(); + browserSetup(); + } + + @AfterSuite(alwaysRun = true) + public void afterSuite() { + browserQuit(); + } + + @BeforeMethod(alwaysRun = true) + public void beforeMethod() { + Selenide.open(BASE_UI_URL); + naviSideBar.waitUntilScreenReady(); + } + + @AfterMethod(alwaysRun = true) + public void afterMethod() { + browserClear(); + } + + @Step + protected void navigateToBrokers() { + naviSideBar + .openSideMenu(BROKERS); + brokersList + .waitUntilScreenReady(); + } + + @Step + protected void navigateToBrokersAndOpenDetails(int brokerId) { + naviSideBar + .openSideMenu(BROKERS); + brokersList + .waitUntilScreenReady() + .openBroker(brokerId); + brokersDetails + .waitUntilScreenReady(); + } + + @Step + protected void navigateToTopics() { + naviSideBar + .openSideMenu(TOPICS); + topicsList + .waitUntilScreenReady() + .setShowInternalRadioButton(false); + } + + @Step + protected void navigateToTopicsAndOpenDetails(String topicName) { + navigateToTopics(); + topicsList + .openTopic(topicName); + topicDetails + .waitUntilScreenReady(); + } + + @Step + protected void navigateToConsumers() { + naviSideBar + .openSideMenu(CONSUMERS); + consumersList + .waitUntilScreenReady(); + } + + @Step + protected void navigateToSchemaRegistry() { + naviSideBar + .openSideMenu(SCHEMA_REGISTRY); + schemaRegistryList + .waitUntilScreenReady(); + } + + @Step + protected void navigateToSchemaRegistryAndOpenDetails(String schemaName) { + navigateToSchemaRegistry(); + schemaRegistryList + .openSchema(schemaName); + schemaDetails + .waitUntilScreenReady(); + } + + @Step + protected void navigateToConnectors() { + naviSideBar + .openSideMenu(KAFKA_CONNECT); + kafkaConnectList + .waitUntilScreenReady(); + } + + @Step + protected void navigateToConnectorsAndOpenDetails(String connectorName) { + navigateToConnectors(); + kafkaConnectList + .openConnector(connectorName); + connectorDetails + .waitUntilScreenReady(); + } + + @Step + protected void navigateToKsqlDb() { + naviSideBar + .openSideMenu(KSQL_DB); + ksqlDbList + .waitUntilScreenReady(); + } + + @Step + protected void verifyElementsCondition(List elementList, Condition expectedCondition) { + SoftAssert softly = new SoftAssert(); + elementList.forEach(element -> softly.assertTrue(element.is(expectedCondition), + element.getSearchCriteria() + " is " + expectedCondition)); + softly.assertAll(); + } } diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/Facade.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/Facade.java index 67468dbcb..abc0b0aa6 100644 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/Facade.java +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/Facade.java @@ -1,7 +1,5 @@ package com.provectus.kafka.ui; -import com.provectus.kafka.ui.pages.panels.NaviSideBar; -import com.provectus.kafka.ui.pages.panels.TopPanel; import com.provectus.kafka.ui.pages.brokers.BrokersConfigTab; import com.provectus.kafka.ui.pages.brokers.BrokersDetails; import com.provectus.kafka.ui.pages.brokers.BrokersList; @@ -10,35 +8,41 @@ import com.provectus.kafka.ui.pages.connectors.KafkaConnectList; import com.provectus.kafka.ui.pages.consumers.ConsumersDetails; import com.provectus.kafka.ui.pages.consumers.ConsumersList; -import com.provectus.kafka.ui.pages.ksqlDb.KsqlDbList; -import com.provectus.kafka.ui.pages.ksqlDb.KsqlQueryForm; +import com.provectus.kafka.ui.pages.ksqldb.KsqlDbList; +import com.provectus.kafka.ui.pages.ksqldb.KsqlQueryForm; +import com.provectus.kafka.ui.pages.panels.NaviSideBar; +import com.provectus.kafka.ui.pages.panels.TopPanel; import com.provectus.kafka.ui.pages.schemas.SchemaCreateForm; import com.provectus.kafka.ui.pages.schemas.SchemaDetails; import com.provectus.kafka.ui.pages.schemas.SchemaRegistryList; -import com.provectus.kafka.ui.pages.topics.*; +import com.provectus.kafka.ui.pages.topics.ProduceMessagePanel; +import com.provectus.kafka.ui.pages.topics.TopicCreateEditForm; +import com.provectus.kafka.ui.pages.topics.TopicDetails; +import com.provectus.kafka.ui.pages.topics.TopicSettingsTab; +import com.provectus.kafka.ui.pages.topics.TopicsList; import com.provectus.kafka.ui.services.ApiService; public abstract class Facade { - protected ApiService apiService = new ApiService(); - protected ConnectorCreateForm connectorCreateForm = new ConnectorCreateForm(); - protected KafkaConnectList kafkaConnectList = new KafkaConnectList(); - protected ConnectorDetails connectorDetails = new ConnectorDetails(); - protected SchemaCreateForm schemaCreateForm = new SchemaCreateForm(); - protected SchemaDetails schemaDetails = new SchemaDetails(); - protected SchemaRegistryList schemaRegistryList = new SchemaRegistryList(); - protected ProduceMessagePanel produceMessagePanel = new ProduceMessagePanel(); - protected TopicCreateEditForm topicCreateEditForm = new TopicCreateEditForm(); - protected TopicsList topicsList = new TopicsList(); - protected TopicDetails topicDetails = new TopicDetails(); - protected ConsumersDetails consumersDetails = new ConsumersDetails(); - protected ConsumersList consumersList = new ConsumersList(); - protected NaviSideBar naviSideBar = new NaviSideBar(); - protected TopPanel topPanel = new TopPanel(); - protected BrokersList brokersList = new BrokersList(); - protected BrokersDetails brokersDetails = new BrokersDetails(); - protected BrokersConfigTab brokersConfigTab = new BrokersConfigTab(); - protected TopicSettingsTab topicSettingsTab = new TopicSettingsTab(); - protected KsqlQueryForm ksqlQueryForm = new KsqlQueryForm(); - protected KsqlDbList ksqlDbList = new KsqlDbList(); + protected ApiService apiService = new ApiService(); + protected ConnectorCreateForm connectorCreateForm = new ConnectorCreateForm(); + protected KafkaConnectList kafkaConnectList = new KafkaConnectList(); + protected ConnectorDetails connectorDetails = new ConnectorDetails(); + protected SchemaCreateForm schemaCreateForm = new SchemaCreateForm(); + protected SchemaDetails schemaDetails = new SchemaDetails(); + protected SchemaRegistryList schemaRegistryList = new SchemaRegistryList(); + protected ProduceMessagePanel produceMessagePanel = new ProduceMessagePanel(); + protected TopicCreateEditForm topicCreateEditForm = new TopicCreateEditForm(); + protected TopicsList topicsList = new TopicsList(); + protected TopicDetails topicDetails = new TopicDetails(); + protected ConsumersDetails consumersDetails = new ConsumersDetails(); + protected ConsumersList consumersList = new ConsumersList(); + protected NaviSideBar naviSideBar = new NaviSideBar(); + protected TopPanel topPanel = new TopPanel(); + protected BrokersList brokersList = new BrokersList(); + protected BrokersDetails brokersDetails = new BrokersDetails(); + protected BrokersConfigTab brokersConfigTab = new BrokersConfigTab(); + protected TopicSettingsTab topicSettingsTab = new TopicSettingsTab(); + protected KsqlQueryForm ksqlQueryForm = new KsqlQueryForm(); + protected KsqlDbList ksqlDbList = new KsqlDbList(); } diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/BaseManualTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/BaseManualTest.java deleted file mode 100644 index bf9f0c75a..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/BaseManualTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.provectus.kafka.ui.manualSuite; - -import com.provectus.kafka.ui.settings.listeners.QaseResultListener; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import org.testng.SkipException; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Listeners; - -import java.lang.reflect.Method; - -import static com.provectus.kafka.ui.utilities.qaseUtils.QaseSetup.qaseIntegrationSetup; -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.NOT_AUTOMATED; -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.TO_BE_AUTOMATED; - -@Listeners(QaseResultListener.class) -public abstract class BaseManualTest { - - @BeforeSuite - public void beforeSuite() { - qaseIntegrationSetup(); - } - - @BeforeMethod - public void beforeMethod(Method method) { - if (method.getAnnotation(Automation.class).state().equals(NOT_AUTOMATED) - || method.getAnnotation(Automation.class).state().equals(TO_BE_AUTOMATED)) - throw new SkipException("Skip test exception"); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/backlog/SanityBacklog.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/backlog/SanityBacklog.java deleted file mode 100644 index f09673c8a..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/backlog/SanityBacklog.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.provectus.kafka.ui.manualSuite.backlog; - -import com.provectus.kafka.ui.manualSuite.BaseManualTest; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Suite; -import io.qase.api.annotation.QaseId; -import org.testng.annotations.Test; - -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.TO_BE_AUTOMATED; - -public class SanityBacklog extends BaseManualTest { - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 19) - @QaseId(285) - @Test - public void testCaseA() { - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/backlog/SmokeBacklog.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/backlog/SmokeBacklog.java deleted file mode 100644 index 84fa7476c..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/backlog/SmokeBacklog.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.provectus.kafka.ui.manualSuite.backlog; - -import com.provectus.kafka.ui.manualSuite.BaseManualTest; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Suite; -import io.qase.api.annotation.QaseId; -import org.testng.annotations.Test; - -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.TO_BE_AUTOMATED; - -public class SmokeBacklog extends BaseManualTest { - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 1) - @QaseId(330) - @Test - public void testCaseA() { - } - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 8) - @QaseId(276) - @Test - public void testCaseB() { - } - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 8) - @QaseId(277) - @Test - public void testCaseC() { - } - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 8) - @QaseId(278) - @Test - public void testCaseD() { - } - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 8) - @QaseId(284) - @Test - public void testCaseE() { - } - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 1) - @QaseId(331) - @Test - public void testCaseF() { - } - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 1) - @QaseId(332) - @Test - public void testCaseG() { - } - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 5) - @QaseId(335) - @Test - public void testCaseH() { - } - - @Automation(state = TO_BE_AUTOMATED) - @Suite(id = 5) - @QaseId(336) - @Test - public void testCaseI() { - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/DataMaskingTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/DataMaskingTest.java deleted file mode 100644 index 23b6e6539..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/DataMaskingTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.provectus.kafka.ui.manualSuite.suite; - -import com.provectus.kafka.ui.manualSuite.BaseManualTest; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import io.qase.api.annotation.QaseId; -import org.testng.annotations.Test; - -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.NOT_AUTOMATED; - -public class DataMaskingTest extends BaseManualTest { - - @Automation(state = NOT_AUTOMATED) - @QaseId(262) - @Test - public void testCaseA() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(264) - @Test - public void testCaseB() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(265) - @Test - public void testCaseC() { - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/RbacTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/RbacTest.java deleted file mode 100644 index aad85652f..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/RbacTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.provectus.kafka.ui.manualSuite.suite; - -import com.provectus.kafka.ui.manualSuite.BaseManualTest; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import io.qase.api.annotation.QaseId; -import org.testng.annotations.Test; - -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.NOT_AUTOMATED; - -public class RbacTest extends BaseManualTest { - - @Automation(state = NOT_AUTOMATED) - @QaseId(249) - @Test - public void testCaseA() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(251) - @Test - public void testCaseB() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(257) - @Test - public void testCaseC() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(258) - @Test - public void testCaseD() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(259) - @Test - public void testCaseE() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(260) - @Test - public void testCaseF() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(261) - @Test - public void testCaseG() { - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/TopicsTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/TopicsTest.java deleted file mode 100644 index dda8103ff..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/TopicsTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.provectus.kafka.ui.manualSuite.suite; - -import com.provectus.kafka.ui.manualSuite.BaseManualTest; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import io.qase.api.annotation.QaseId; -import org.testng.annotations.Test; - -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.NOT_AUTOMATED; - -public class TopicsTest extends BaseManualTest { - - @Automation(state = NOT_AUTOMATED) - @QaseId(17) - @Test - public void testCaseA() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(18) - @Test - public void testCaseB() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(21) - @Test() - public void testCaseC() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(22) - @Test - public void testCaseD() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(47) - @Test - public void testCaseE() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(48) - @Test - public void testCaseF() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(49) - @Test - public void testCaseG() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(50) - @Test - public void testCaseH() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(57) - @Test - public void testCaseI() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(58) - @Test - public void testCaseJ() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(269) - @Test - public void testCaseK() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(270) - @Test - public void testCaseL() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(271) - @Test - public void testCaseM() { - } - - @Automation(state = NOT_AUTOMATED) - @QaseId(272) - @Test - public void testCaseN() { - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/WizardTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/WizardTest.java deleted file mode 100644 index e7ae52bdb..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualSuite/suite/WizardTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.provectus.kafka.ui.manualSuite.suite; - -import com.provectus.kafka.ui.manualSuite.BaseManualTest; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import io.qase.api.annotation.QaseId; -import org.testng.annotations.Test; - -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.NOT_AUTOMATED; - -public class WizardTest extends BaseManualTest { - - @Automation(state = NOT_AUTOMATED) - @QaseId(333) - @Test - public void testCaseA() { - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/BaseManualTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/BaseManualTest.java new file mode 100644 index 000000000..827dc1ce4 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/BaseManualTest.java @@ -0,0 +1,30 @@ +package com.provectus.kafka.ui.manualsuite; + +import static com.provectus.kafka.ui.utilities.qase.QaseSetup.qaseIntegrationSetup; +import static com.provectus.kafka.ui.utilities.qase.enums.State.NOT_AUTOMATED; +import static com.provectus.kafka.ui.utilities.qase.enums.State.TO_BE_AUTOMATED; + +import com.provectus.kafka.ui.settings.listeners.QaseResultListener; +import com.provectus.kafka.ui.utilities.qase.annotations.Automation; +import java.lang.reflect.Method; +import org.testng.SkipException; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Listeners; + +@Listeners(QaseResultListener.class) +public abstract class BaseManualTest { + + @BeforeSuite + public void beforeSuite() { + qaseIntegrationSetup(); + } + + @BeforeMethod + public void beforeMethod(Method method) { + if (method.getAnnotation(Automation.class).state().equals(NOT_AUTOMATED) + || method.getAnnotation(Automation.class).state().equals(TO_BE_AUTOMATED)) { + throw new SkipException("Skip test exception"); + } + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SanityBacklog.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SanityBacklog.java new file mode 100644 index 000000000..4021c8ec9 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SanityBacklog.java @@ -0,0 +1,7 @@ +package com.provectus.kafka.ui.manualsuite.backlog; + +import com.provectus.kafka.ui.manualsuite.BaseManualTest; + +public class SanityBacklog extends BaseManualTest { + +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SmokeBacklog.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SmokeBacklog.java new file mode 100644 index 000000000..b89a1d0cf --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/backlog/SmokeBacklog.java @@ -0,0 +1,78 @@ +package com.provectus.kafka.ui.manualsuite.backlog; + +import static com.provectus.kafka.ui.qasesuite.BaseQaseTest.BROKERS_SUITE_ID; +import static com.provectus.kafka.ui.qasesuite.BaseQaseTest.KSQL_DB_SUITE_ID; +import static com.provectus.kafka.ui.qasesuite.BaseQaseTest.TOPICS_PROFILE_SUITE_ID; +import static com.provectus.kafka.ui.utilities.qase.enums.State.TO_BE_AUTOMATED; + +import com.provectus.kafka.ui.manualsuite.BaseManualTest; +import com.provectus.kafka.ui.utilities.qase.annotations.Automation; +import com.provectus.kafka.ui.utilities.qase.annotations.Suite; +import io.qase.api.annotation.QaseId; +import org.testng.annotations.Test; + +public class SmokeBacklog extends BaseManualTest { + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = BROKERS_SUITE_ID) + @QaseId(330) + @Test + public void testCaseA() { + } + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = KSQL_DB_SUITE_ID) + @QaseId(276) + @Test + public void testCaseB() { + } + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = KSQL_DB_SUITE_ID) + @QaseId(277) + @Test + public void testCaseC() { + } + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = KSQL_DB_SUITE_ID) + @QaseId(278) + @Test + public void testCaseD() { + } + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = KSQL_DB_SUITE_ID) + @QaseId(284) + @Test + public void testCaseE() { + } + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = BROKERS_SUITE_ID) + @QaseId(331) + @Test + public void testCaseF() { + } + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = BROKERS_SUITE_ID) + @QaseId(332) + @Test + public void testCaseG() { + } + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = TOPICS_PROFILE_SUITE_ID) + @QaseId(335) + @Test + public void testCaseH() { + } + + @Automation(state = TO_BE_AUTOMATED) + @Suite(id = TOPICS_PROFILE_SUITE_ID) + @QaseId(336) + @Test + public void testCaseI() { + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/DataMaskingTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/DataMaskingTest.java new file mode 100644 index 000000000..540511d0c --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/DataMaskingTest.java @@ -0,0 +1,29 @@ +package com.provectus.kafka.ui.manualsuite.suite; + +import static com.provectus.kafka.ui.utilities.qase.enums.State.NOT_AUTOMATED; + +import com.provectus.kafka.ui.manualsuite.BaseManualTest; +import com.provectus.kafka.ui.utilities.qase.annotations.Automation; +import io.qase.api.annotation.QaseId; +import org.testng.annotations.Test; + +public class DataMaskingTest extends BaseManualTest { + + @Automation(state = NOT_AUTOMATED) + @QaseId(262) + @Test + public void testCaseA() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(264) + @Test + public void testCaseB() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(265) + @Test + public void testCaseC() { + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/RbacTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/RbacTest.java new file mode 100644 index 000000000..7c7ac3153 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/RbacTest.java @@ -0,0 +1,53 @@ +package com.provectus.kafka.ui.manualsuite.suite; + +import static com.provectus.kafka.ui.utilities.qase.enums.State.NOT_AUTOMATED; + +import com.provectus.kafka.ui.manualsuite.BaseManualTest; +import com.provectus.kafka.ui.utilities.qase.annotations.Automation; +import io.qase.api.annotation.QaseId; +import org.testng.annotations.Test; + +public class RbacTest extends BaseManualTest { + + @Automation(state = NOT_AUTOMATED) + @QaseId(249) + @Test + public void testCaseA() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(251) + @Test + public void testCaseB() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(257) + @Test + public void testCaseC() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(258) + @Test + public void testCaseD() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(259) + @Test + public void testCaseE() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(260) + @Test + public void testCaseF() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(261) + @Test + public void testCaseG() { + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/TopicsTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/TopicsTest.java new file mode 100644 index 000000000..76f8506de --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/TopicsTest.java @@ -0,0 +1,95 @@ +package com.provectus.kafka.ui.manualsuite.suite; + +import static com.provectus.kafka.ui.utilities.qase.enums.State.NOT_AUTOMATED; + +import com.provectus.kafka.ui.manualsuite.BaseManualTest; +import com.provectus.kafka.ui.utilities.qase.annotations.Automation; +import io.qase.api.annotation.QaseId; +import org.testng.annotations.Test; + +public class TopicsTest extends BaseManualTest { + + @Automation(state = NOT_AUTOMATED) + @QaseId(17) + @Test + public void testCaseA() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(18) + @Test + public void testCaseB() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(21) + @Test() + public void testCaseC() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(22) + @Test + public void testCaseD() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(47) + @Test + public void testCaseE() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(48) + @Test + public void testCaseF() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(49) + @Test + public void testCaseG() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(50) + @Test + public void testCaseH() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(57) + @Test + public void testCaseI() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(58) + @Test + public void testCaseJ() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(269) + @Test + public void testCaseK() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(270) + @Test + public void testCaseL() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(271) + @Test + public void testCaseM() { + } + + @Automation(state = NOT_AUTOMATED) + @QaseId(272) + @Test + public void testCaseN() { + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/WizardTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/WizardTest.java new file mode 100644 index 000000000..9621104b1 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/manualsuite/suite/WizardTest.java @@ -0,0 +1,17 @@ +package com.provectus.kafka.ui.manualsuite.suite; + +import static com.provectus.kafka.ui.utilities.qase.enums.State.NOT_AUTOMATED; + +import com.provectus.kafka.ui.manualsuite.BaseManualTest; +import com.provectus.kafka.ui.utilities.qase.annotations.Automation; +import io.qase.api.annotation.QaseId; +import org.testng.annotations.Test; + +public class WizardTest extends BaseManualTest { + + @Automation(state = NOT_AUTOMATED) + @QaseId(333) + @Test + public void testCaseA() { + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/BaseQaseTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/BaseQaseTest.java deleted file mode 100644 index 7b4c34ac0..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/BaseQaseTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.provectus.kafka.ui.qaseSuite; - -import com.provectus.kafka.ui.settings.listeners.QaseCreateListener; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Listeners; - -import static com.provectus.kafka.ui.utilities.qaseUtils.QaseSetup.qaseIntegrationSetup; - -@Listeners(QaseCreateListener.class) -public abstract class BaseQaseTest { - - protected static final long BROKERS_SUITE_ID = 1; - protected static final long CONNECTORS_SUITE_ID = 10; - protected static final long KSQL_DB_SUITE_ID = 8; - protected static final long SANITY_SUITE_ID = 19; - protected static final long SCHEMAS_SUITE_ID = 11; - protected static final long TOPICS_SUITE_ID = 2; - - @BeforeSuite - public void beforeSuite() { - qaseIntegrationSetup(); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/Template.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/Template.java deleted file mode 100644 index ca987650d..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/Template.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.provectus.kafka.ui.qaseSuite; - -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Automation; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Status; -import com.provectus.kafka.ui.utilities.qaseUtils.annotations.Suite; -import io.qase.api.annotation.QaseTitle; -import io.qase.api.annotation.Step; - -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.State.NOT_AUTOMATED; -import static com.provectus.kafka.ui.utilities.qaseUtils.enums.Status.DRAFT; - -public class Template extends BaseQaseTest { - - /** - * this class is a kind of placeholder or example, use is as template to create new one - * copy Template into kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/ - * place it into regarding folder and rename according to test case summary from Qase.io - * uncomment @Test and set all annotations according to kafka-ui-e2e-checks/QASE.md - */ - - @Automation(state = NOT_AUTOMATED) - @QaseTitle("testCaseA title") - @Status(status = DRAFT) - @Suite(id = 0) -// @org.testng.annotations.Test - public void testCaseA() { - stepA(); - stepB(); - stepC(); - stepD(); - stepE(); - stepF(); - } - - @Step("stepA action") - private void stepA() { - } - - @Step("stepB action") - private void stepB() { - } - - @Step("stepC action") - private void stepC() { - } - - @Step("stepD action") - private void stepD() { - } - - @Step("stepE action") - private void stepE() { - } - - @Step("stepF action") - private void stepF() { - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qasesuite/BaseQaseTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qasesuite/BaseQaseTest.java new file mode 100644 index 000000000..1a195a363 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qasesuite/BaseQaseTest.java @@ -0,0 +1,25 @@ +package com.provectus.kafka.ui.qasesuite; + +import static com.provectus.kafka.ui.utilities.qase.QaseSetup.qaseIntegrationSetup; + +import com.provectus.kafka.ui.settings.listeners.QaseCreateListener; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Listeners; + +@Listeners(QaseCreateListener.class) +public abstract class BaseQaseTest { + + public static final long BROKERS_SUITE_ID = 1; + public static final long CONNECTORS_SUITE_ID = 10; + public static final long KSQL_DB_SUITE_ID = 8; + public static final long SANITY_SUITE_ID = 19; + public static final long SCHEMAS_SUITE_ID = 11; + public static final long TOPICS_SUITE_ID = 2; + public static final long TOPICS_CREATE_SUITE_ID = 4; + public static final long TOPICS_PROFILE_SUITE_ID = 5; + + @BeforeSuite + public void beforeSuite() { + qaseIntegrationSetup(); + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qasesuite/Template.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qasesuite/Template.java new file mode 100644 index 000000000..d5a47eccd --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qasesuite/Template.java @@ -0,0 +1,58 @@ +package com.provectus.kafka.ui.qasesuite; + +import static com.provectus.kafka.ui.utilities.qase.enums.State.NOT_AUTOMATED; +import static com.provectus.kafka.ui.utilities.qase.enums.Status.DRAFT; + +import com.provectus.kafka.ui.utilities.qase.annotations.Automation; +import com.provectus.kafka.ui.utilities.qase.annotations.Status; +import com.provectus.kafka.ui.utilities.qase.annotations.Suite; +import io.qase.api.annotation.QaseTitle; +import io.qase.api.annotation.Step; + +public class Template extends BaseQaseTest { + + /** + * this class is a kind of placeholder or example, use is as template to create new one + * copy Template into kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/qaseSuite/ + * place it into regarding folder and rename according to test case summary from Qase.io + * uncomment @Test and set all annotations according to kafka-ui-e2e-checks/QASE.md + */ + + @Automation(state = NOT_AUTOMATED) + @QaseTitle("testCaseA title") + @Status(status = DRAFT) + @Suite(id = 0) + // @org.testng.annotations.Test + public void testCaseA() { + stepA(); + stepB(); + stepC(); + stepD(); + stepE(); + stepF(); + } + + @Step("stepA action") + private void stepA() { + } + + @Step("stepB action") + private void stepB() { + } + + @Step("stepC action") + private void stepC() { + } + + @Step("stepD action") + private void stepD() { + } + + @Step("stepE action") + private void stepE() { + } + + @Step("stepF action") + private void stepF() { + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/sanitySuite/TestClass.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/sanitySuite/TestClass.java deleted file mode 100644 index 89402f3fc..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/sanitySuite/TestClass.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.provectus.kafka.ui.sanitySuite; - -public class TestClass { -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/sanitysuite/TopicsTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/sanitysuite/TopicsTest.java new file mode 100644 index 000000000..40a6d6780 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/sanitysuite/TopicsTest.java @@ -0,0 +1,66 @@ +package com.provectus.kafka.ui.sanitysuite; + +import static com.provectus.kafka.ui.pages.topics.enums.CleanupPolicyValue.COMPACT; +import static com.provectus.kafka.ui.pages.topics.enums.CleanupPolicyValue.DELETE; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import com.provectus.kafka.ui.BaseTest; +import com.provectus.kafka.ui.models.Topic; +import io.qase.api.annotation.QaseId; +import java.util.ArrayList; +import java.util.List; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + +public class TopicsTest extends BaseTest { + + private static final List TOPIC_LIST = new ArrayList<>(); + + @QaseId(285) + @Test() + public void verifyClearMessagesMenuStateAfterTopicUpdate() { + Topic topic = new Topic() + .setName("topic-" + randomAlphabetic(5)) + .setNumberOfPartitions(1) + .setCleanupPolicyValue(DELETE); + navigateToTopics(); + topicsList + .clickAddTopicBtn(); + topicCreateEditForm + .waitUntilScreenReady() + .setTopicName(topic.getName()) + .setNumberOfPartitions(topic.getNumberOfPartitions()) + .selectCleanupPolicy(topic.getCleanupPolicyValue()) + .clickSaveTopicBtn(); + topicDetails + .waitUntilScreenReady(); + TOPIC_LIST.add(topic); + topicDetails + .openDotMenu(); + Assert.assertTrue(topicDetails.isClearMessagesMenuEnabled(), "isClearMessagesMenuEnabled"); + topic.setCleanupPolicyValue(COMPACT); + editCleanUpPolicyAndOpenDotMenu(topic); + Assert.assertFalse(topicDetails.isClearMessagesMenuEnabled(), "isClearMessagesMenuEnabled"); + topic.setCleanupPolicyValue(DELETE); + editCleanUpPolicyAndOpenDotMenu(topic); + Assert.assertTrue(topicDetails.isClearMessagesMenuEnabled(), "isClearMessagesMenuEnabled"); + } + + private void editCleanUpPolicyAndOpenDotMenu(Topic topic) { + topicDetails + .clickEditSettingsMenu(); + topicCreateEditForm + .waitUntilScreenReady() + .selectCleanupPolicy(topic.getCleanupPolicyValue()) + .clickSaveTopicBtn(); + topicDetails + .waitUntilScreenReady() + .openDotMenu(); + } + + @AfterClass(alwaysRun = true) + public void afterClass() { + TOPIC_LIST.forEach(topic -> apiService.deleteTopic(topic.getName())); + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/SmokeTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/SmokeTest.java deleted file mode 100644 index c8439e70d..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/SmokeTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.provectus.kafka.ui.smokeSuite; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.WebDriverRunner; -import com.provectus.kafka.ui.BaseTest; -import com.provectus.kafka.ui.models.Connector; -import com.provectus.kafka.ui.models.Schema; -import com.provectus.kafka.ui.models.Topic; -import com.provectus.kafka.ui.pages.panels.enums.MenuItem; -import io.qameta.allure.Step; -import io.qase.api.annotation.QaseId; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.*; -import static com.provectus.kafka.ui.settings.BaseSource.BASE_HOST; -import static com.provectus.kafka.ui.utilities.FileUtils.getResourceAsString; -import static com.provectus.kafka.ui.variables.Url.*; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -public class SmokeTest extends BaseTest { - - private static final int BROKER_ID = 1; - private static final Schema TEST_SCHEMA = Schema.createSchemaAvro(); - private static final Topic TEST_TOPIC = new Topic() - .setName("new-topic-" + randomAlphabetic(5)) - .setNumberOfPartitions(1); - private static final Connector TEST_CONNECTOR = new Connector() - .setName("new-connector-" + randomAlphabetic(5)) - .setConfig(getResourceAsString("testData/connectors/config_for_create_connector_via_api.json")); - - @BeforeClass(alwaysRun = true) - public void beforeClass() { - apiService - .createTopic(TEST_TOPIC) - .createSchema(TEST_SCHEMA) - .createConnector(TEST_CONNECTOR); - } - - @QaseId(198) - @Test - public void checkBasePageElements() { - verifyElementsCondition( - Stream.concat(topPanel.getAllVisibleElements().stream(), naviSideBar.getAllMenuButtons().stream()) - .collect(Collectors.toList()), Condition.visible); - verifyElementsCondition( - Stream.concat(topPanel.getAllEnabledElements().stream(), naviSideBar.getAllMenuButtons().stream()) - .collect(Collectors.toList()), Condition.enabled); - } - - @QaseId(45) - @Test - public void checkUrlWhileNavigating() { - navigateToBrokers(); - verifyCurrentUrl(BROKERS_LIST_URL); - navigateToTopics(); - verifyCurrentUrl(TOPICS_LIST_URL); - navigateToConsumers(); - verifyCurrentUrl(CONSUMERS_LIST_URL); - navigateToSchemaRegistry(); - verifyCurrentUrl(SCHEMA_REGISTRY_LIST_URL); - navigateToConnectors(); - verifyCurrentUrl(KAFKA_CONNECT_LIST_URL); - navigateToKsqlDb(); - verifyCurrentUrl(KSQL_DB_LIST_URL); - } - - @QaseId(46) - @Test - public void checkPathWhileNavigating() { - navigateToBrokersAndOpenDetails(BROKER_ID); - verifyComponentsPath(BROKERS, String.format("Broker %d", BROKER_ID)); - navigateToTopicsAndOpenDetails(TEST_TOPIC.getName()); - verifyComponentsPath(TOPICS, TEST_TOPIC.getName()); - navigateToSchemaRegistryAndOpenDetails(TEST_SCHEMA.getName()); - verifyComponentsPath(SCHEMA_REGISTRY, TEST_SCHEMA.getName()); - navigateToConnectorsAndOpenDetails(TEST_CONNECTOR.getName()); - verifyComponentsPath(KAFKA_CONNECT, TEST_CONNECTOR.getName()); - } - - @Step - private void verifyCurrentUrl(String expectedUrl) { - String urlWithoutParameters = WebDriverRunner.getWebDriver().getCurrentUrl(); - if (urlWithoutParameters.contains("?")) - urlWithoutParameters = urlWithoutParameters.substring(0, urlWithoutParameters.indexOf("?")); - Assert.assertEquals(urlWithoutParameters, String.format(expectedUrl, BASE_HOST), "getCurrentUrl()"); - } - - @Step - private void verifyComponentsPath(MenuItem menuItem, String expectedPath) { - Assert.assertEquals(naviSideBar.getPagePath(menuItem), expectedPath, - String.format("getPagePath() for %s", menuItem.getPageTitle().toUpperCase())); - } - - @AfterClass(alwaysRun = true) - public void afterClass() { - apiService - .deleteTopic(TEST_TOPIC.getName()) - .deleteSchema(TEST_SCHEMA.getName()) - .deleteConnector(TEST_CONNECTOR.getName()); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/brokers/BrokersTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/brokers/BrokersTest.java deleted file mode 100644 index c9029e30a..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/brokers/BrokersTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.provectus.kafka.ui.smokeSuite.brokers; - -import com.codeborne.selenide.Condition; -import com.provectus.kafka.ui.BaseTest; -import io.qase.api.annotation.QaseId; -import org.testng.Assert; -import org.testng.annotations.Test; - -import static com.provectus.kafka.ui.pages.brokers.BrokersDetails.DetailsTab.CONFIGS; - -public class BrokersTest extends BaseTest { - - @QaseId(1) - @Test - public void checkBrokersOverview() { - navigateToBrokers(); - Assert.assertTrue(brokersList.getAllBrokers().size() > 0, "getAllBrokers()"); - verifyElementsCondition(brokersList.getAllVisibleElements(), Condition.visible); - verifyElementsCondition(brokersList.getAllEnabledElements(), Condition.enabled); - } - - @QaseId(85) - @Test - public void checkExistingBrokersInCluster() { - navigateToBrokers(); - Assert.assertTrue(brokersList.getAllBrokers().size() > 0, "getAllBrokers()"); - brokersList - .openBroker(1); - brokersDetails - .waitUntilScreenReady(); - verifyElementsCondition(brokersDetails.getAllVisibleElements(), Condition.visible); - verifyElementsCondition(brokersDetails.getAllEnabledElements(), Condition.enabled); - brokersDetails - .openDetailsTab(CONFIGS); - brokersConfigTab - .waitUntilScreenReady(); - verifyElementsCondition(brokersConfigTab.getColumnHeaders(), Condition.visible); - verifyElementsCondition(brokersConfigTab.getEditButtons(), Condition.enabled); - Assert.assertTrue(brokersConfigTab.isSearchByKeyVisible(), "isSearchByKeyVisible()"); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/connectors/ConnectorsTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/connectors/ConnectorsTest.java deleted file mode 100644 index bdce29e15..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/connectors/ConnectorsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.provectus.kafka.ui.smokeSuite.connectors; - -import com.provectus.kafka.ui.BaseTest; -import com.provectus.kafka.ui.models.Connector; -import com.provectus.kafka.ui.models.Topic; -import io.qase.api.annotation.QaseId; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.ArrayList; -import java.util.List; - -import static com.provectus.kafka.ui.pages.BasePage.AlertHeader.SUCCESS; -import static com.provectus.kafka.ui.utilities.FileUtils.getResourceAsString; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -public class ConnectorsTest extends BaseTest { - - private static final List TOPIC_LIST = new ArrayList<>(); - private static final List CONNECTOR_LIST = new ArrayList<>(); - private static final String MESSAGE_CONTENT = "testData/topics/message_content_create_topic.json"; - private static final String MESSAGE_KEY = " "; - private static final Topic TOPIC_FOR_CREATE = new Topic() - .setName("topic-for-create-connector-" + randomAlphabetic(5)) - .setMessageContent(MESSAGE_CONTENT).setMessageKey(MESSAGE_KEY); - private static final Topic TOPIC_FOR_DELETE = new Topic() - .setName("topic-for-delete-connector-" + randomAlphabetic(5)) - .setMessageContent(MESSAGE_CONTENT).setMessageKey(MESSAGE_KEY); - private static final Topic TOPIC_FOR_UPDATE = new Topic() - .setName("topic-for-update-connector-" + randomAlphabetic(5)) - .setMessageContent(MESSAGE_CONTENT).setMessageKey(MESSAGE_KEY); - private static final Connector CONNECTOR_FOR_DELETE = new Connector() - .setName("connector-for-delete-" + randomAlphabetic(5)) - .setConfig(getResourceAsString("testData/connectors/delete_connector_config.json")); - private static final Connector CONNECTOR_FOR_UPDATE = new Connector() - .setName("connector-for-update-and-delete-" + randomAlphabetic(5)) - .setConfig(getResourceAsString("testData/connectors/config_for_create_connector_via_api.json")); - - @BeforeClass(alwaysRun = true) - public void beforeClass() { - TOPIC_LIST.addAll(List.of(TOPIC_FOR_CREATE, TOPIC_FOR_DELETE, TOPIC_FOR_UPDATE)); - TOPIC_LIST.forEach(topic -> apiService - .createTopic(topic) - .sendMessage(topic) - ); - CONNECTOR_LIST.addAll(List.of(CONNECTOR_FOR_DELETE, CONNECTOR_FOR_UPDATE)); - CONNECTOR_LIST.forEach(connector -> apiService.createConnector(connector)); - } - - @QaseId(42) - @Test - public void createConnector() { - Connector connectorForCreate = new Connector() - .setName("connector-for-create-" + randomAlphabetic(5)) - .setConfig(getResourceAsString("testData/connectors/config_for_create_connector.json")); - navigateToConnectors(); - kafkaConnectList - .clickCreateConnectorBtn(); - connectorCreateForm - .waitUntilScreenReady() - .setConnectorDetails(connectorForCreate.getName(), connectorForCreate.getConfig()) - .clickSubmitButton(); - connectorDetails - .waitUntilScreenReady(); - navigateToConnectorsAndOpenDetails(connectorForCreate.getName()); - Assert.assertTrue(connectorDetails.isConnectorHeaderVisible(connectorForCreate.getName()), "isConnectorTitleVisible()"); - navigateToConnectors(); - Assert.assertTrue(kafkaConnectList.isConnectorVisible(CONNECTOR_FOR_DELETE.getName()), "isConnectorVisible()"); - CONNECTOR_LIST.add(connectorForCreate); - } - - @QaseId(196) - @Test - public void updateConnector() { - navigateToConnectorsAndOpenDetails(CONNECTOR_FOR_UPDATE.getName()); - connectorDetails - .openConfigTab() - .setConfig(CONNECTOR_FOR_UPDATE.getConfig()) - .clickSubmitButton(); - Assert.assertTrue(connectorDetails.isAlertWithMessageVisible(SUCCESS, "Config successfully updated."), "isAlertWithMessageVisible()"); - navigateToConnectors(); - Assert.assertTrue(kafkaConnectList.isConnectorVisible(CONNECTOR_FOR_UPDATE.getName()), "isConnectorVisible()"); - } - - @QaseId(195) - @Test - public void deleteConnector() { - navigateToConnectorsAndOpenDetails(CONNECTOR_FOR_DELETE.getName()); - connectorDetails - .openDotMenu() - .clickDeleteBtn() - .clickConfirmBtn(); - navigateToConnectors(); - Assert.assertFalse(kafkaConnectList.isConnectorVisible(CONNECTOR_FOR_DELETE.getName()), "isConnectorVisible()"); - CONNECTOR_LIST.remove(CONNECTOR_FOR_DELETE); - } - - @AfterClass(alwaysRun = true) - public void afterClass() { - CONNECTOR_LIST.forEach(connector -> - apiService.deleteConnector(connector.getName())); - TOPIC_LIST.forEach(topic -> apiService.deleteTopic(topic.getName())); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/ksqlDb/KsqlDbTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/ksqlDb/KsqlDbTest.java deleted file mode 100644 index 210e5549f..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/ksqlDb/KsqlDbTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.provectus.kafka.ui.smokeSuite.ksqlDb; - -import com.provectus.kafka.ui.BaseTest; -import com.provectus.kafka.ui.pages.ksqlDb.models.Stream; -import com.provectus.kafka.ui.pages.ksqlDb.models.Table; -import io.qase.api.annotation.QaseId; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.testng.asserts.SoftAssert; - -import java.util.ArrayList; -import java.util.List; - -import static com.provectus.kafka.ui.pages.ksqlDb.enums.KsqlQueryConfig.SHOW_TABLES; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -public class KsqlDbTest extends BaseTest { - - private static final Stream STREAM_FOR_CHECK_TABLES = new Stream() - .setName("STREAM_FOR_CHECK_TABLES_" + randomAlphabetic(4).toUpperCase()) - .setTopicName("TOPIC_FOR_STREAM_" + randomAlphabetic(4).toUpperCase()); - private static final Table FIRST_TABLE = new Table() - .setName("FIRST_TABLE" + randomAlphabetic(4).toUpperCase()) - .setStreamName(STREAM_FOR_CHECK_TABLES.getName()); - private static final Table SECOND_TABLE = new Table() - .setName("SECOND_TABLE" + randomAlphabetic(4).toUpperCase()) - .setStreamName(STREAM_FOR_CHECK_TABLES.getName()); - private static final List TOPIC_NAMES_LIST = new ArrayList<>(); - - @BeforeClass(alwaysRun = true) - public void beforeClass() { - apiService - .createStream(STREAM_FOR_CHECK_TABLES) - .createTables(FIRST_TABLE, SECOND_TABLE); - TOPIC_NAMES_LIST.addAll(List.of(STREAM_FOR_CHECK_TABLES.getTopicName(), - FIRST_TABLE.getName(), SECOND_TABLE.getName())); - } - - @QaseId(41) - @Test(priority = 1) - public void checkShowTablesRequestExecution() { - navigateToKsqlDb(); - ksqlDbList - .clickExecuteKsqlRequestBtn(); - ksqlQueryForm - .waitUntilScreenReady() - .setQuery(SHOW_TABLES.getQuery()) - .clickExecuteBtn(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(ksqlQueryForm.areResultsVisible(), "areResultsVisible()"); - softly.assertTrue(ksqlQueryForm.getTableByName(FIRST_TABLE.getName()).isVisible(), "getTableName()"); - softly.assertTrue(ksqlQueryForm.getTableByName(SECOND_TABLE.getName()).isVisible(), "getTableName()"); - softly.assertAll(); - } - - @QaseId(86) - @Test(priority = 2) - public void clearResultsForExecutedRequest() { - navigateToKsqlDb(); - ksqlDbList - .clickExecuteKsqlRequestBtn(); - ksqlQueryForm - .waitUntilScreenReady() - .setQuery(SHOW_TABLES.getQuery()) - .clickExecuteBtn(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(ksqlQueryForm.areResultsVisible(), "areResultsVisible()"); - softly.assertAll(); - ksqlQueryForm - .clickClearResultsBtn(); - softly.assertFalse(ksqlQueryForm.areResultsVisible(), "areResultsVisible()"); - softly.assertAll(); - } - - @AfterClass(alwaysRun = true) - public void afterClass() { - TOPIC_NAMES_LIST.forEach(topicName -> apiService.deleteTopic(topicName)); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/schemas/SchemasTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/schemas/SchemasTest.java deleted file mode 100644 index 9b2a1618c..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/schemas/SchemasTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.provectus.kafka.ui.smokeSuite.schemas; - -import com.codeborne.selenide.Condition; -import com.provectus.kafka.ui.BaseTest; -import com.provectus.kafka.ui.api.model.CompatibilityLevel; -import com.provectus.kafka.ui.models.Schema; -import io.qase.api.annotation.QaseId; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.testng.asserts.SoftAssert; - -import java.util.ArrayList; -import java.util.List; - -import static com.provectus.kafka.ui.utilities.FileUtils.fileToString; - -public class SchemasTest extends BaseTest { - - private static final List SCHEMA_LIST = new ArrayList<>(); - private static final Schema AVRO_API = Schema.createSchemaAvro(); - private static final Schema JSON_API = Schema.createSchemaJson(); - private static final Schema PROTOBUF_API = Schema.createSchemaProtobuf(); - - @BeforeClass(alwaysRun = true) - public void beforeClass() { - SCHEMA_LIST.addAll(List.of(AVRO_API, JSON_API, PROTOBUF_API)); - SCHEMA_LIST.forEach(schema -> apiService.createSchema(schema)); - } - - @QaseId(43) - @Test(priority = 1) - public void createSchemaAvro() { - Schema schemaAvro = Schema.createSchemaAvro(); - navigateToSchemaRegistry(); - schemaRegistryList - .clickCreateSchema(); - schemaCreateForm - .setSubjectName(schemaAvro.getName()) - .setSchemaField(fileToString(schemaAvro.getValuePath())) - .selectSchemaTypeFromDropdown(schemaAvro.getType()) - .clickSubmitButton(); - schemaDetails - .waitUntilScreenReady(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(schemaDetails.isSchemaHeaderVisible(schemaAvro.getName()), "isSchemaHeaderVisible()"); - softly.assertEquals(schemaDetails.getSchemaType(), schemaAvro.getType().getValue(), "getSchemaType()"); - softly.assertEquals(schemaDetails.getCompatibility(), CompatibilityLevel.CompatibilityEnum.BACKWARD.getValue(), - "getCompatibility()"); - softly.assertAll(); - navigateToSchemaRegistry(); - Assert.assertTrue(schemaRegistryList.isSchemaVisible(AVRO_API.getName()), "isSchemaVisible()"); - SCHEMA_LIST.add(schemaAvro); - } - - @QaseId(186) - @Test(priority = 2) - public void updateSchemaAvro() { - AVRO_API.setValuePath(System.getProperty("user.dir") + "/src/main/resources/testData/schemas/schema_avro_for_update.json"); - navigateToSchemaRegistryAndOpenDetails(AVRO_API.getName()); - schemaDetails - .openEditSchema(); - schemaCreateForm - .waitUntilScreenReady(); - verifyElementsCondition(schemaCreateForm.getAllDetailsPageElements(), Condition.visible); - SoftAssert softly = new SoftAssert(); - softly.assertFalse(schemaCreateForm.isSubmitBtnEnabled(), "isSubmitBtnEnabled()"); - softly.assertFalse(schemaCreateForm.isSchemaDropDownEnabled(), "isSchemaDropDownEnabled()"); - softly.assertAll(); - schemaCreateForm - .selectCompatibilityLevelFromDropdown(CompatibilityLevel.CompatibilityEnum.NONE) - .setNewSchemaValue(fileToString(AVRO_API.getValuePath())) - .clickSubmitButton(); - schemaDetails - .waitUntilScreenReady(); - Assert.assertEquals(schemaDetails.getCompatibility(), CompatibilityLevel.CompatibilityEnum.NONE.toString(), - "getCompatibility()"); - } - - @QaseId(44) - @Test(priority = 3) - public void compareVersionsOperation() { - navigateToSchemaRegistryAndOpenDetails(AVRO_API.getName()); - int latestVersion = schemaDetails - .waitUntilScreenReady() - .getLatestVersion(); - schemaDetails - .openCompareVersionMenu(); - int versionsNumberFromDdl = schemaCreateForm - .waitUntilScreenReady() - .openLeftVersionDdl() - .getVersionsNumberFromList(); - Assert.assertEquals(versionsNumberFromDdl, latestVersion, "Versions number is not matched"); - schemaCreateForm - .selectVersionFromDropDown(1); - Assert.assertEquals(schemaCreateForm.getMarkedLinesNumber(), 42, "getAllMarkedLines()"); - } - - @QaseId(187) - @Test(priority = 4) - public void deleteSchemaAvro() { - navigateToSchemaRegistryAndOpenDetails(AVRO_API.getName()); - schemaDetails - .removeSchema(); - schemaRegistryList - .waitUntilScreenReady(); - Assert.assertFalse(schemaRegistryList.isSchemaVisible(AVRO_API.getName()), "isSchemaVisible()"); - SCHEMA_LIST.remove(AVRO_API); - } - - @QaseId(89) - @Test(priority = 5) - public void createSchemaJson() { - Schema schemaJson = Schema.createSchemaJson(); - navigateToSchemaRegistry(); - schemaRegistryList - .clickCreateSchema(); - schemaCreateForm - .setSubjectName(schemaJson.getName()) - .setSchemaField(fileToString(schemaJson.getValuePath())) - .selectSchemaTypeFromDropdown(schemaJson.getType()) - .clickSubmitButton(); - schemaDetails - .waitUntilScreenReady(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(schemaDetails.isSchemaHeaderVisible(schemaJson.getName()), "isSchemaHeaderVisible()"); - softly.assertEquals(schemaDetails.getSchemaType(), schemaJson.getType().getValue(), "getSchemaType()"); - softly.assertEquals(schemaDetails.getCompatibility(), CompatibilityLevel.CompatibilityEnum.BACKWARD.getValue(), - "getCompatibility()"); - softly.assertAll(); - navigateToSchemaRegistry(); - Assert.assertTrue(schemaRegistryList.isSchemaVisible(JSON_API.getName()), "isSchemaVisible()"); - SCHEMA_LIST.add(schemaJson); - } - - @QaseId(189) - @Test(priority = 6) - public void deleteSchemaJson() { - navigateToSchemaRegistryAndOpenDetails(JSON_API.getName()); - schemaDetails - .removeSchema(); - schemaRegistryList - .waitUntilScreenReady(); - Assert.assertFalse(schemaRegistryList.isSchemaVisible(JSON_API.getName()), "isSchemaVisible()"); - SCHEMA_LIST.remove(JSON_API); - } - - @QaseId(91) - @Test(priority = 7) - public void createSchemaProtobuf() { - Schema schemaProtobuf = Schema.createSchemaProtobuf(); - navigateToSchemaRegistry(); - schemaRegistryList - .clickCreateSchema(); - schemaCreateForm - .setSubjectName(schemaProtobuf.getName()) - .setSchemaField(fileToString(schemaProtobuf.getValuePath())) - .selectSchemaTypeFromDropdown(schemaProtobuf.getType()) - .clickSubmitButton(); - schemaDetails - .waitUntilScreenReady(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(schemaDetails.isSchemaHeaderVisible(schemaProtobuf.getName()), "isSchemaHeaderVisible()"); - softly.assertEquals(schemaDetails.getSchemaType(), schemaProtobuf.getType().getValue(), "getSchemaType()"); - softly.assertEquals(schemaDetails.getCompatibility(), CompatibilityLevel.CompatibilityEnum.BACKWARD.getValue(), - "getCompatibility()"); - softly.assertAll(); - navigateToSchemaRegistry(); - Assert.assertTrue(schemaRegistryList.isSchemaVisible(PROTOBUF_API.getName()), "isSchemaVisible()"); - SCHEMA_LIST.add(schemaProtobuf); - } - - @QaseId(223) - @Test(priority = 8) - public void deleteSchemaProtobuf() { - navigateToSchemaRegistryAndOpenDetails(PROTOBUF_API.getName()); - schemaDetails - .removeSchema(); - schemaRegistryList - .waitUntilScreenReady(); - Assert.assertFalse(schemaRegistryList.isSchemaVisible(PROTOBUF_API.getName()), "isSchemaVisible()"); - SCHEMA_LIST.remove(PROTOBUF_API); - } - - @AfterClass(alwaysRun = true) - public void afterClass() { - SCHEMA_LIST.forEach(schema -> apiService.deleteSchema(schema.getName())); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/topics/MessagesTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/topics/MessagesTest.java deleted file mode 100644 index 00a0413e7..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/topics/MessagesTest.java +++ /dev/null @@ -1,283 +0,0 @@ -package com.provectus.kafka.ui.smokeSuite.topics; - -import com.provectus.kafka.ui.BaseTest; -import com.provectus.kafka.ui.models.Topic; -import com.provectus.kafka.ui.pages.topics.TopicDetails; -import io.qameta.allure.Issue; -import io.qameta.allure.Step; -import io.qase.api.annotation.QaseId; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; -import org.testng.asserts.SoftAssert; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.IntStream; - -import static com.provectus.kafka.ui.pages.BasePage.AlertHeader.SUCCESS; -import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.MESSAGES; -import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.OVERVIEW; -import static com.provectus.kafka.ui.utilities.TimeUtils.waitUntilNewMinuteStarted; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -public class MessagesTest extends BaseTest { - - private static final Topic TOPIC_FOR_MESSAGES = new Topic() - .setName("topic-with-clean-message-attribute-" + randomAlphabetic(5)) - .setMessageKey(randomAlphabetic(5)) - .setMessageContent(randomAlphabetic(10)); - private static final Topic TOPIC_TO_CLEAR_AND_PURGE_MESSAGES = new Topic() - .setName("topic-to-clear-and-purge-messages-" + randomAlphabetic(5)) - .setMessageKey(randomAlphabetic(5)) - .setMessageContent(randomAlphabetic(10)); - private static final Topic TOPIC_FOR_CHECK_FILTERS = new Topic() - .setName("topic-for-check-filters-" + randomAlphabetic(5)) - .setMessageKey(randomAlphabetic(5)) - .setMessageContent(randomAlphabetic(10)); - private static final Topic TOPIC_TO_RECREATE = new Topic() - .setName("topic-to-recreate-attribute-" + randomAlphabetic(5)) - .setMessageKey(randomAlphabetic(5)) - .setMessageContent(randomAlphabetic(10)); - private static final Topic TOPIC_FOR_CHECK_MESSAGES_COUNT = new Topic() - .setName("topic-for-check-messages-count" + randomAlphabetic(5)) - .setMessageKey(randomAlphabetic(5)) - .setMessageContent(randomAlphabetic(10)); - private static final List TOPIC_LIST = new ArrayList<>(); - - @BeforeClass(alwaysRun = true) - public void beforeClass() { - TOPIC_LIST.addAll(List.of(TOPIC_FOR_MESSAGES, TOPIC_FOR_CHECK_FILTERS, TOPIC_TO_CLEAR_AND_PURGE_MESSAGES, - TOPIC_TO_RECREATE, TOPIC_FOR_CHECK_MESSAGES_COUNT)); - TOPIC_LIST.forEach(topic -> apiService.createTopic(topic)); - IntStream.range(1, 3).forEach(i -> apiService.sendMessage(TOPIC_FOR_CHECK_FILTERS)); - waitUntilNewMinuteStarted(); - IntStream.range(1, 3).forEach(i -> apiService.sendMessage(TOPIC_FOR_CHECK_FILTERS)); - IntStream.range(1, 110).forEach(i -> apiService.sendMessage(TOPIC_FOR_CHECK_MESSAGES_COUNT)); - } - - @QaseId(222) - @Test(priority = 1) - public void produceMessage() { - navigateToTopicsAndOpenDetails(TOPIC_FOR_MESSAGES.getName()); - topicDetails - .openDetailsTab(MESSAGES); - produceMessage(TOPIC_FOR_MESSAGES); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(topicDetails.isKeyMessageVisible((TOPIC_FOR_MESSAGES.getMessageKey())), - "isKeyMessageVisible()"); - softly.assertTrue(topicDetails.isContentMessageVisible((TOPIC_FOR_MESSAGES.getMessageContent()).trim()), - "isContentMessageVisible()"); - softly.assertAll(); - } - - @QaseId(19) - @Test(priority = 2) - public void clearMessage() { - navigateToTopicsAndOpenDetails(TOPIC_FOR_MESSAGES.getName()); - topicDetails - .openDetailsTab(OVERVIEW); - int messageAmount = topicDetails.getMessageCountAmount(); - produceMessage(TOPIC_FOR_MESSAGES); - Assert.assertEquals(topicDetails.getMessageCountAmount(), messageAmount + 1, "getMessageCountAmount()"); - topicDetails - .openDotMenu() - .clickClearMessagesMenu() - .clickConfirmBtnMdl() - .waitUntilScreenReady(); - Assert.assertEquals(topicDetails.getMessageCountAmount(), 0, "getMessageCountAmount()"); - } - - @QaseId(239) - @Test(priority = 3) - public void checkClearTopicMessage() { - navigateToTopicsAndOpenDetails(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()); - topicDetails - .openDetailsTab(OVERVIEW); - produceMessage(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES); - navigateToTopics(); - Assert.assertEquals(topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(), 1, - "getNumberOfMessages()"); - topicsList - .openDotMenuByTopicName(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()) - .clickClearMessagesBtn() - .clickConfirmBtnMdl(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(topicsList.isAlertWithMessageVisible(SUCCESS, - String.format("%s messages have been successfully cleared!", TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName())), - "isAlertWithMessageVisible()"); - softly.assertEquals(topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(), 0, - "getNumberOfMessages()"); - softly.assertAll(); - } - - @QaseId(10) - @Test(priority = 4) - public void checkPurgeMessagePossibility() { - navigateToTopics(); - int messageAmount = topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(); - topicsList - .openTopic(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()); - topicDetails - .openDetailsTab(OVERVIEW); - produceMessage(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES); - navigateToTopics(); - Assert.assertEquals(topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(), - messageAmount + 1, "getNumberOfMessages()"); - topicsList - .getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()) - .selectItem(true) - .clickPurgeMessagesOfSelectedTopicsBtn(); - Assert.assertTrue(topicsList.isConfirmationMdlVisible(), "isConfirmationMdlVisible()"); - topicsList - .clickCancelBtnMdl() - .clickPurgeMessagesOfSelectedTopicsBtn() - .clickConfirmBtnMdl(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(topicsList.isAlertWithMessageVisible(SUCCESS, - String.format("%s messages have been successfully cleared!", TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName())), - "isAlertWithMessageVisible()"); - softly.assertEquals(topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(), 0, - "getNumberOfMessages()"); - softly.assertAll(); - } - - @Ignore - @Issue("https://github.com/provectus/kafka-ui/issues/2394") - @QaseId(15) - @Test(priority = 6) - public void checkMessageFilteringByOffset() { - navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); - topicDetails - .openDetailsTab(MESSAGES); - TopicDetails.MessageGridItem secondMessage = topicDetails.getMessageByOffset(1); - topicDetails - .selectSeekTypeDdlMessagesTab("Offset") - .setSeekTypeValueFldMessagesTab(String.valueOf(secondMessage.getOffset())) - .clickSubmitFiltersBtnMessagesTab(); - SoftAssert softly = new SoftAssert(); - topicDetails.getAllMessages().forEach(message -> - softly.assertTrue(message.getOffset() == secondMessage.getOffset() - || message.getOffset() > secondMessage.getOffset(), - String.format("Expected offset is: %s, but found: %s", secondMessage.getOffset(), message.getOffset()))); - softly.assertAll(); - } - - @Ignore - @Issue("https://github.com/provectus/kafka-ui/issues/3215") - @Issue("https://github.com/provectus/kafka-ui/issues/2345") - @QaseId(16) - @Test(priority = 7) - public void checkMessageFilteringByTimestamp() { - navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); - topicDetails - .openDetailsTab(MESSAGES); - LocalDateTime firstTimestamp = topicDetails.getMessageByOffset(0).getTimestamp(); - List nextMessages = topicDetails.getAllMessages().stream() - .filter(message -> message.getTimestamp().getMinute() != firstTimestamp.getMinute()) - .toList(); - LocalDateTime nextTimestamp = Objects.requireNonNull(nextMessages.stream() - .findFirst().orElseThrow()).getTimestamp(); - topicDetails - .selectSeekTypeDdlMessagesTab("Timestamp") - .openCalendarSeekType() - .selectDateAndTimeByCalendar(nextTimestamp) - .clickSubmitFiltersBtnMessagesTab(); - SoftAssert softly = new SoftAssert(); - topicDetails.getAllMessages().forEach(message -> - softly.assertTrue(message.getTimestamp().isEqual(nextTimestamp) - || message.getTimestamp().isAfter(nextTimestamp), - String.format("Expected timestamp is: %s, but found: %s", nextTimestamp, message.getTimestamp()))); - softly.assertAll(); - } - - @Ignore - @Issue("https://github.com/provectus/kafka-ui/issues/2778") - @QaseId(246) - @Test(priority = 8) - public void checkClearTopicMessageFromOverviewTab() { - navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); - topicDetails - .openDetailsTab(OVERVIEW) - .openDotMenu() - .clickClearMessagesMenu() - .clickConfirmBtnMdl(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, - String.format("%s messages have been successfully cleared!", TOPIC_FOR_CHECK_FILTERS.getName())), - "isAlertWithMessageVisible()"); - softly.assertEquals(topicDetails.getMessageCountAmount(), 0, - "getMessageCountAmount()= " + topicDetails.getMessageCountAmount()); - softly.assertAll(); - } - - @QaseId(240) - @Test(priority = 9) - public void checkRecreateTopic() { - navigateToTopicsAndOpenDetails(TOPIC_TO_RECREATE.getName()); - topicDetails - .openDetailsTab(OVERVIEW); - produceMessage(TOPIC_TO_RECREATE); - navigateToTopics(); - Assert.assertEquals(topicsList.getTopicItem(TOPIC_TO_RECREATE.getName()).getNumberOfMessages(), 1, - "getNumberOfMessages()"); - topicsList - .openDotMenuByTopicName(TOPIC_TO_RECREATE.getName()) - .clickRecreateTopicBtn() - .clickConfirmBtnMdl(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, - String.format("Topic %s successfully recreated!", TOPIC_TO_RECREATE.getName())), - "isAlertWithMessageVisible()"); - softly.assertEquals(topicsList.getTopicItem(TOPIC_TO_RECREATE.getName()).getNumberOfMessages(), 0, - "getNumberOfMessages()"); - softly.assertAll(); - } - - @Ignore - @Issue("https://github.com/provectus/kafka-ui/issues/3129") - @QaseId(267) - @Test(priority = 10) - public void CheckMessagesCountPerPageWithinTopic() { - navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_MESSAGES_COUNT.getName()); - topicDetails - .openDetailsTab(MESSAGES); - int messagesPerPage = topicDetails.getAllMessages().size(); - SoftAssert softly = new SoftAssert(); - softly.assertEquals(messagesPerPage, 100, "getAllMessages()"); - softly.assertFalse(topicDetails.isBackButtonEnabled(), "isBackButtonEnabled()"); - softly.assertTrue(topicDetails.isNextButtonEnabled(), "isNextButtonEnabled()"); - softly.assertAll(); - int lastOffsetOnPage = topicDetails.getAllMessages() - .get(messagesPerPage - 1).getOffset(); - topicDetails - .clickNextButton(); - softly.assertEquals(topicDetails.getAllMessages().stream().findFirst().orElseThrow().getOffset(), - lastOffsetOnPage + 1, "findFirst().getOffset()"); - softly.assertTrue(topicDetails.isBackButtonEnabled(), "isBackButtonEnabled()"); - softly.assertFalse(topicDetails.isNextButtonEnabled(), "isNextButtonEnabled()"); - softly.assertAll(); - } - - @Step - protected void produceMessage(Topic topic) { - topicDetails - .clickProduceMessageBtn(); - produceMessagePanel - .waitUntilScreenReady() - .setKeyField(topic.getMessageKey()) - .setContentFiled(topic.getMessageContent()) - .submitProduceMessage(); - topicDetails - .waitUntilScreenReady(); - } - - @AfterClass(alwaysRun = true) - public void afterClass() { - TOPIC_LIST.forEach(topic -> apiService.deleteTopic(topic.getName())); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/topics/TopicsTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/topics/TopicsTest.java deleted file mode 100644 index 0ce4d6c71..000000000 --- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokeSuite/topics/TopicsTest.java +++ /dev/null @@ -1,496 +0,0 @@ -package com.provectus.kafka.ui.smokeSuite.topics; - -import com.codeborne.selenide.Condition; -import com.provectus.kafka.ui.BaseTest; -import com.provectus.kafka.ui.models.Topic; -import io.qameta.allure.Issue; -import io.qase.api.annotation.QaseId; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; -import org.testng.asserts.SoftAssert; - -import java.util.ArrayList; -import java.util.List; - -import static com.provectus.kafka.ui.pages.BasePage.AlertHeader.SUCCESS; -import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.*; -import static com.provectus.kafka.ui.pages.topics.enums.CleanupPolicyValue.COMPACT; -import static com.provectus.kafka.ui.pages.topics.enums.CleanupPolicyValue.DELETE; -import static com.provectus.kafka.ui.pages.topics.enums.CustomParameterType.COMPRESSION_TYPE; -import static com.provectus.kafka.ui.pages.topics.enums.MaxSizeOnDisk.*; -import static com.provectus.kafka.ui.pages.topics.enums.TimeToRetain.BTN_2_DAYS; -import static com.provectus.kafka.ui.pages.topics.enums.TimeToRetain.BTN_7_DAYS; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang3.RandomUtils.nextInt; - -public class TopicsTest extends BaseTest { - - private static final Topic TOPIC_TO_CREATE = new Topic() - .setName("new-topic-" + randomAlphabetic(5)) - .setNumberOfPartitions(1) - .setCustomParameterType(COMPRESSION_TYPE) - .setCustomParameterValue("producer") - .setCleanupPolicyValue(DELETE); - private static final Topic TOPIC_TO_UPDATE_AND_DELETE = new Topic() - .setName("topic-to-update-and-delete-" + randomAlphabetic(5)) - .setNumberOfPartitions(1) - .setCleanupPolicyValue(DELETE) - .setTimeToRetain(BTN_7_DAYS) - .setMaxSizeOnDisk(NOT_SET) - .setMaxMessageBytes("1048588") - .setMessageKey(randomAlphabetic(5)) - .setMessageContent(randomAlphabetic(10)); - private static final Topic TOPIC_TO_CHECK_SETTINGS = new Topic() - .setName("new-topic-" + randomAlphabetic(5)) - .setNumberOfPartitions(1) - .setMaxMessageBytes("1000012") - .setMaxSizeOnDisk(NOT_SET); - private static final Topic TOPIC_FOR_CHECK_FILTERS = new Topic() - .setName("topic-for-check-filters-" + randomAlphabetic(5)); - private static final Topic TOPIC_FOR_DELETE = new Topic() - .setName("topic-to-delete-" + randomAlphabetic(5)); - private static final List TOPIC_LIST = new ArrayList<>(); - - @BeforeClass(alwaysRun = true) - public void beforeClass() { - TOPIC_LIST.addAll(List.of(TOPIC_TO_UPDATE_AND_DELETE, TOPIC_FOR_DELETE, TOPIC_FOR_CHECK_FILTERS)); - TOPIC_LIST.forEach(topic -> apiService.createTopic(topic)); - } - - @QaseId(199) - @Test(priority = 1) - public void createTopic() { - navigateToTopics(); - topicsList - .clickAddTopicBtn(); - topicCreateEditForm - .waitUntilScreenReady() - .setTopicName(TOPIC_TO_CREATE.getName()) - .setNumberOfPartitions(TOPIC_TO_CREATE.getNumberOfPartitions()) - .selectCleanupPolicy(TOPIC_TO_CREATE.getCleanupPolicyValue()) - .clickCreateTopicBtn(); - navigateToTopicsAndOpenDetails(TOPIC_TO_CREATE.getName()); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(topicDetails.isTopicHeaderVisible(TOPIC_TO_CREATE.getName()), "isTopicHeaderVisible()"); - softly.assertEquals(topicDetails.getCleanUpPolicy(), TOPIC_TO_CREATE.getCleanupPolicyValue().toString(), "getCleanUpPolicy()"); - softly.assertEquals(topicDetails.getPartitions(), TOPIC_TO_CREATE.getNumberOfPartitions(), "getPartitions()"); - softly.assertAll(); - navigateToTopics(); - Assert.assertTrue(topicsList.isTopicVisible(TOPIC_TO_CREATE.getName()), "isTopicVisible()"); - TOPIC_LIST.add(TOPIC_TO_CREATE); - } - - @QaseId(7) - @Test(priority = 2) - void checkAvailableOperations() { - navigateToTopics(); - topicsList - .getTopicItem(TOPIC_TO_UPDATE_AND_DELETE.getName()) - .selectItem(true); - verifyElementsCondition(topicsList.getActionButtons(), Condition.enabled); - topicsList - .getTopicItem(TOPIC_FOR_CHECK_FILTERS.getName()) - .selectItem(true); - Assert.assertFalse(topicsList.isCopySelectedTopicBtnEnabled(), "isCopySelectedTopicBtnEnabled()"); - } - - @Ignore - @Issue("https://github.com/provectus/kafka-ui/issues/3071") - @QaseId(268) - @Test(priority = 3) - public void checkCustomParametersWithinEditExistingTopic() { - navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE_AND_DELETE.getName()); - topicDetails - .openDotMenu() - .clickEditSettingsMenu(); - SoftAssert softly = new SoftAssert(); - topicCreateEditForm - .waitUntilScreenReady() - .clickAddCustomParameterTypeButton() - .openCustomParameterTypeDdl() - .getAllDdlOptions() - .forEach(option -> - softly.assertTrue(!option.is(Condition.attribute("disabled")), - option.getText() + " is enabled:")); - softly.assertAll(); - } - - @QaseId(197) - @Test(priority = 4) - public void updateTopic() { - navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE_AND_DELETE.getName()); - topicDetails - .openDotMenu() - .clickEditSettingsMenu(); - topicCreateEditForm - .waitUntilScreenReady(); - SoftAssert softly = new SoftAssert(); - softly.assertEquals(topicCreateEditForm.getCleanupPolicy(), - TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue().getVisibleText(), "getCleanupPolicy()"); - softly.assertEquals(topicCreateEditForm.getTimeToRetain(), - TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain().getValue(), "getTimeToRetain()"); - softly.assertEquals(topicCreateEditForm.getMaxSizeOnDisk(), - TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk().getVisibleText(), "getMaxSizeOnDisk()"); - softly.assertEquals(topicCreateEditForm.getMaxMessageBytes(), - TOPIC_TO_UPDATE_AND_DELETE.getMaxMessageBytes(), "getMaxMessageBytes()"); - softly.assertAll(); - TOPIC_TO_UPDATE_AND_DELETE - .setCleanupPolicyValue(COMPACT) - .setTimeToRetain(BTN_2_DAYS) - .setMaxSizeOnDisk(SIZE_50_GB).setMaxMessageBytes("1048589"); - topicCreateEditForm - .selectCleanupPolicy((TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue())) - .setTimeToRetainDataByButtons(TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain()) - .setMaxSizeOnDiskInGB(TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk()) - .setMaxMessageBytes(TOPIC_TO_UPDATE_AND_DELETE.getMaxMessageBytes()) - .clickCreateTopicBtn(); - softly.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, "Topic successfully updated."), - "isAlertWithMessageVisible()"); - softly.assertTrue(topicDetails.isTopicHeaderVisible(TOPIC_TO_UPDATE_AND_DELETE.getName()), - "isTopicHeaderVisible()"); - softly.assertAll(); - topicDetails - .waitUntilScreenReady(); - navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE_AND_DELETE.getName()); - topicDetails - .openDotMenu() - .clickEditSettingsMenu(); - softly.assertFalse(topicCreateEditForm.isNameFieldEnabled(), "isNameFieldEnabled()"); - softly.assertEquals(topicCreateEditForm.getCleanupPolicy(), - TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue().getVisibleText(), "getCleanupPolicy()"); - softly.assertEquals(topicCreateEditForm.getTimeToRetain(), - TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain().getValue(), "getTimeToRetain()"); - softly.assertEquals(topicCreateEditForm.getMaxSizeOnDisk(), - TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk().getVisibleText(), "getMaxSizeOnDisk()"); - softly.assertEquals(topicCreateEditForm.getMaxMessageBytes(), - TOPIC_TO_UPDATE_AND_DELETE.getMaxMessageBytes(), "getMaxMessageBytes()"); - softly.assertAll(); - } - - @QaseId(242) - @Test(priority = 5) - public void removeTopicFromTopicList() { - navigateToTopics(); - topicsList - .openDotMenuByTopicName(TOPIC_TO_UPDATE_AND_DELETE.getName()) - .clickRemoveTopicBtn() - .clickConfirmBtnMdl(); - Assert.assertTrue(topicsList.isAlertWithMessageVisible(SUCCESS, - String.format("Topic %s successfully deleted!", TOPIC_TO_UPDATE_AND_DELETE.getName())), - "isAlertWithMessageVisible()"); - TOPIC_LIST.remove(TOPIC_TO_UPDATE_AND_DELETE); - } - - @QaseId(207) - @Test(priority = 6) - public void deleteTopic() { - navigateToTopicsAndOpenDetails(TOPIC_FOR_DELETE.getName()); - topicDetails - .openDotMenu() - .clickDeleteTopicMenu() - .clickConfirmBtnMdl(); - navigateToTopics(); - Assert.assertFalse(topicsList.isTopicVisible(TOPIC_FOR_DELETE.getName()), "isTopicVisible"); - TOPIC_LIST.remove(TOPIC_FOR_DELETE); - } - - @QaseId(20) - @Test(priority = 7) - public void redirectToConsumerFromTopic() { - String topicName = "source-activities"; - String consumerGroupId = "connect-sink_postgres_activities"; - navigateToTopicsAndOpenDetails(topicName); - topicDetails - .openDetailsTab(CONSUMERS) - .openConsumerGroup(consumerGroupId); - consumersDetails - .waitUntilScreenReady(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(consumersDetails.isRedirectedConsumerTitleVisible(consumerGroupId), - "isRedirectedConsumerTitleVisible()"); - softly.assertTrue(consumersDetails.isTopicInConsumersDetailsVisible(topicName), - "isTopicInConsumersDetailsVisible()"); - softly.assertAll(); - } - - @QaseId(4) - @Test(priority = 8) - public void checkTopicCreatePossibility() { - navigateToTopics(); - topicsList - .clickAddTopicBtn(); - topicCreateEditForm - .waitUntilScreenReady(); - Assert.assertFalse(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); - topicCreateEditForm - .setTopicName("testName"); - Assert.assertFalse(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); - topicCreateEditForm - .setTopicName(null) - .setNumberOfPartitions(nextInt(1, 10)); - Assert.assertFalse(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); - topicCreateEditForm - .setTopicName("testName"); - Assert.assertTrue(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); - } - - @QaseId(266) - @Test(priority = 9) - public void checkTimeToRetainDataCustomValueWithEditingTopic() { - Topic topicToRetainData = new Topic() - .setName("topic-to-retain-data-" + randomAlphabetic(5)) - .setTimeToRetainData("86400000"); - navigateToTopics(); - topicsList - .clickAddTopicBtn(); - topicCreateEditForm - .waitUntilScreenReady() - .setTopicName(topicToRetainData.getName()) - .setNumberOfPartitions(1) - .setTimeToRetainDataInMs("604800000"); - Assert.assertEquals(topicCreateEditForm.getTimeToRetain(), "604800000", "getTimeToRetain()"); - topicCreateEditForm - .setTimeToRetainDataInMs(topicToRetainData.getTimeToRetainData()) - .clickCreateTopicBtn(); - topicDetails - .waitUntilScreenReady() - .openDotMenu() - .clickEditSettingsMenu(); - Assert.assertEquals(topicCreateEditForm.getTimeToRetain(), topicToRetainData.getTimeToRetainData(), - "getTimeToRetain()"); - topicDetails - .openDetailsTab(SETTINGS); - Assert.assertEquals(topicDetails.getSettingsGridValueByKey("retention.ms"), topicToRetainData.getTimeToRetainData(), - "getSettingsGridValueByKey()"); - TOPIC_LIST.add(topicToRetainData); - } - - @QaseId(6) - @Test(priority = 10) - public void checkCustomParametersWithinCreateNewTopic() { - navigateToTopics(); - topicsList - .clickAddTopicBtn(); - topicCreateEditForm - .waitUntilScreenReady() - .setTopicName(TOPIC_TO_CREATE.getName()) - .clickAddCustomParameterTypeButton() - .setCustomParameterType(TOPIC_TO_CREATE.getCustomParameterType()); - Assert.assertTrue(topicCreateEditForm.isDeleteCustomParameterButtonEnabled(), - "isDeleteCustomParameterButtonEnabled()"); - topicCreateEditForm - .clearCustomParameterValue(); - Assert.assertTrue(topicCreateEditForm.isValidationMessageCustomParameterValueVisible(), - "isValidationMessageCustomParameterValueVisible()"); - } - - @QaseId(2) - @Test(priority = 11) - public void checkTopicListElements() { - navigateToTopics(); - verifyElementsCondition(topicsList.getAllVisibleElements(), Condition.visible); - verifyElementsCondition(topicsList.getAllEnabledElements(), Condition.enabled); - } - - @QaseId(12) - @Test(priority = 12) - public void addNewFilterWithinTopic() { - String filterName = randomAlphabetic(5); - navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); - topicDetails - .openDetailsTab(MESSAGES) - .clickMessagesAddFiltersBtn() - .waitUntilAddFiltersMdlVisible(); - verifyElementsCondition(topicDetails.getAllAddFilterModalVisibleElements(), Condition.visible); - verifyElementsCondition(topicDetails.getAllAddFilterModalEnabledElements(), Condition.enabled); - verifyElementsCondition(topicDetails.getAllAddFilterModalDisabledElements(), Condition.disabled); - Assert.assertFalse(topicDetails.isSaveThisFilterCheckBoxSelected(), "isSaveThisFilterCheckBoxSelected()"); - topicDetails - .setFilterCodeFieldAddFilterMdl(filterName); - Assert.assertTrue(topicDetails.isAddFilterBtnAddFilterMdlEnabled(), "isAddFilterBtnAddFilterMdlEnabled()"); - topicDetails.clickAddFilterBtnAndCloseMdl(true); - Assert.assertTrue(topicDetails.isActiveFilterVisible(filterName), "isActiveFilterVisible()"); - } - - @QaseId(13) - @Test(priority = 13) - public void checkFilterSavingWithinSavedFilters() { - String displayName = randomAlphabetic(5); - navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); - topicDetails - .openDetailsTab(MESSAGES) - .clickMessagesAddFiltersBtn() - .waitUntilAddFiltersMdlVisible() - .setFilterCodeFieldAddFilterMdl(randomAlphabetic(4)) - .selectSaveThisFilterCheckboxMdl(true) - .setDisplayNameFldAddFilterMdl(displayName); - Assert.assertTrue(topicDetails.isAddFilterBtnAddFilterMdlEnabled(), - "isAddFilterBtnAddFilterMdlEnabled()"); - topicDetails - .clickAddFilterBtnAndCloseMdl(false) - .openSavedFiltersListMdl(); - Assert.assertTrue(topicDetails.isFilterVisibleAtSavedFiltersMdl(displayName), - "isFilterVisibleAtSavedFiltersMdl()"); - } - - @QaseId(14) - @Test(priority = 14) - public void checkApplyingSavedFilterWithinTopicMessages() { - String displayName = randomAlphabetic(5); - navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); - topicDetails - .openDetailsTab(MESSAGES) - .clickMessagesAddFiltersBtn() - .waitUntilAddFiltersMdlVisible() - .setFilterCodeFieldAddFilterMdl(randomAlphabetic(4)) - .selectSaveThisFilterCheckboxMdl(true) - .setDisplayNameFldAddFilterMdl(displayName) - .clickAddFilterBtnAndCloseMdl(false) - .openSavedFiltersListMdl() - .selectFilterAtSavedFiltersMdl(displayName) - .clickSelectFilterBtnAtSavedFiltersMdl(); - Assert.assertTrue(topicDetails.isActiveFilterVisible(displayName), "isActiveFilterVisible()"); - } - - @QaseId(11) - @Test(priority = 15) - public void checkShowInternalTopicsButton() { - navigateToTopics(); - topicsList - .setShowInternalRadioButton(true); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(topicsList.getInternalTopics().size() > 0, "getInternalTopics()"); - softly.assertTrue(topicsList.getNonInternalTopics().size() > 0, "getNonInternalTopics()"); - softly.assertAll(); - topicsList - .setShowInternalRadioButton(false); - softly.assertEquals(topicsList.getInternalTopics().size(), 0, "getInternalTopics()"); - softly.assertTrue(topicsList.getNonInternalTopics().size() > 0, "getNonInternalTopics()"); - softly.assertAll(); - } - - @QaseId(334) - @Test(priority = 16) - public void checkInternalTopicsNaming() { - navigateToTopics(); - SoftAssert softly = new SoftAssert(); - topicsList - .setShowInternalRadioButton(true) - .getInternalTopics() - .forEach(topic -> softly.assertTrue(topic.getName().startsWith("_"), - String.format("'%s' starts with '_'", topic.getName()))); - softly.assertAll(); - } - - @QaseId(56) - @Test(priority = 17) - public void checkRetentionBytesAccordingToMaxSizeOnDisk() { - navigateToTopics(); - topicsList - .clickAddTopicBtn(); - topicCreateEditForm - .waitUntilScreenReady() - .setTopicName(TOPIC_TO_CHECK_SETTINGS.getName()) - .setNumberOfPartitions(TOPIC_TO_CHECK_SETTINGS.getNumberOfPartitions()) - .setMaxMessageBytes(TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes()) - .clickCreateTopicBtn(); - topicDetails - .waitUntilScreenReady(); - TOPIC_LIST.add(TOPIC_TO_CHECK_SETTINGS); - topicDetails - .openDetailsTab(SETTINGS); - topicSettingsTab - .waitUntilScreenReady(); - SoftAssert softly = new SoftAssert(); - softly.assertEquals(topicSettingsTab.getValueByKey("retention.bytes"), - TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk().getOptionValue(), "getValueOfKey(retention.bytes)"); - softly.assertEquals(topicSettingsTab.getValueByKey("max.message.bytes"), - TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes(), "getValueOfKey(max.message.bytes)"); - softly.assertAll(); - TOPIC_TO_CHECK_SETTINGS - .setMaxSizeOnDisk(SIZE_1_GB) - .setMaxMessageBytes("1000056"); - topicDetails - .openDotMenu() - .clickEditSettingsMenu(); - topicCreateEditForm - .waitUntilScreenReady() - .setMaxSizeOnDiskInGB(TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk()) - .setMaxMessageBytes(TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes()) - .clickCreateTopicBtn(); - topicDetails - .waitUntilScreenReady() - .openDetailsTab(SETTINGS); - topicSettingsTab - .waitUntilScreenReady(); - softly.assertEquals(topicSettingsTab.getValueByKey("retention.bytes"), - TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk().getOptionValue(), "getValueOfKey(retention.bytes)"); - softly.assertEquals(topicSettingsTab.getValueByKey("max.message.bytes"), - TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes(), "getValueOfKey(max.message.bytes)"); - softly.assertAll(); - } - - @QaseId(247) - @Test(priority = 18) - public void recreateTopicFromTopicProfile() { - Topic topicToRecreate = new Topic() - .setName("topic-to-recreate-" + randomAlphabetic(5)) - .setNumberOfPartitions(1); - navigateToTopics(); - topicsList - .clickAddTopicBtn(); - topicCreateEditForm - .waitUntilScreenReady() - .setTopicName(topicToRecreate.getName()) - .setNumberOfPartitions(topicToRecreate.getNumberOfPartitions()) - .clickCreateTopicBtn(); - topicDetails - .waitUntilScreenReady(); - TOPIC_LIST.add(topicToRecreate); - topicDetails - .openDotMenu() - .clickRecreateTopicMenu(); - Assert.assertTrue(topicDetails.isConfirmationMdlVisible(), "isConfirmationMdlVisible()"); - topicDetails - .clickConfirmBtnMdl(); - Assert.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, - String.format("Topic %s successfully recreated!", topicToRecreate.getName())), - "isAlertWithMessageVisible()"); - } - - @QaseId(8) - @Test(priority = 19) - public void checkCopyTopicPossibility() { - Topic topicToCopy = new Topic() - .setName("topic-to-copy-" + randomAlphabetic(5)) - .setNumberOfPartitions(1); - navigateToTopics(); - topicsList - .getAnyNonInternalTopic() - .selectItem(true) - .clickCopySelectedTopicBtn(); - topicCreateEditForm - .waitUntilScreenReady(); - Assert.assertFalse(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); - topicCreateEditForm - .setTopicName(topicToCopy.getName()) - .setNumberOfPartitions(topicToCopy.getNumberOfPartitions()) - .clickCreateTopicBtn(); - topicDetails - .waitUntilScreenReady(); - TOPIC_LIST.add(topicToCopy); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, "Topic successfully created."), - "isAlertWithMessageVisible()"); - softly.assertTrue(topicDetails.isTopicHeaderVisible(topicToCopy.getName()), "isTopicHeaderVisible()"); - softly.assertAll(); - } - - @AfterClass(alwaysRun = true) - public void afterClass() { - TOPIC_LIST.forEach(topic -> apiService.deleteTopic(topic.getName())); - } -} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/SmokeTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/SmokeTest.java new file mode 100644 index 000000000..5193ecb25 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/SmokeTest.java @@ -0,0 +1,115 @@ +package com.provectus.kafka.ui.smokesuite; + +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.BROKERS; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.KAFKA_CONNECT; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.SCHEMA_REGISTRY; +import static com.provectus.kafka.ui.pages.panels.enums.MenuItem.TOPICS; +import static com.provectus.kafka.ui.settings.BaseSource.BASE_HOST; +import static com.provectus.kafka.ui.utilities.FileUtils.getResourceAsString; +import static com.provectus.kafka.ui.variables.Url.BROKERS_LIST_URL; +import static com.provectus.kafka.ui.variables.Url.CONSUMERS_LIST_URL; +import static com.provectus.kafka.ui.variables.Url.KAFKA_CONNECT_LIST_URL; +import static com.provectus.kafka.ui.variables.Url.KSQL_DB_LIST_URL; +import static com.provectus.kafka.ui.variables.Url.SCHEMA_REGISTRY_LIST_URL; +import static com.provectus.kafka.ui.variables.Url.TOPICS_LIST_URL; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.WebDriverRunner; +import com.provectus.kafka.ui.BaseTest; +import com.provectus.kafka.ui.models.Connector; +import com.provectus.kafka.ui.models.Schema; +import com.provectus.kafka.ui.models.Topic; +import com.provectus.kafka.ui.pages.panels.enums.MenuItem; +import io.qameta.allure.Step; +import io.qase.api.annotation.QaseId; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SmokeTest extends BaseTest { + + private static final int BROKER_ID = 1; + private static final Schema TEST_SCHEMA = Schema.createSchemaAvro(); + private static final Topic TEST_TOPIC = new Topic() + .setName("new-topic-" + randomAlphabetic(5)) + .setNumberOfPartitions(1); + private static final Connector TEST_CONNECTOR = new Connector() + .setName("new-connector-" + randomAlphabetic(5)) + .setConfig(getResourceAsString("testData/connectors/config_for_create_connector_via_api.json")); + + @BeforeClass(alwaysRun = true) + public void beforeClass() { + apiService + .createTopic(TEST_TOPIC) + .createSchema(TEST_SCHEMA) + .createConnector(TEST_CONNECTOR); + } + + @QaseId(198) + @Test + public void checkBasePageElements() { + verifyElementsCondition( + Stream.concat(topPanel.getAllVisibleElements().stream(), naviSideBar.getAllMenuButtons().stream()) + .collect(Collectors.toList()), Condition.visible); + verifyElementsCondition( + Stream.concat(topPanel.getAllEnabledElements().stream(), naviSideBar.getAllMenuButtons().stream()) + .collect(Collectors.toList()), Condition.enabled); + } + + @QaseId(45) + @Test + public void checkUrlWhileNavigating() { + navigateToBrokers(); + verifyCurrentUrl(BROKERS_LIST_URL); + navigateToTopics(); + verifyCurrentUrl(TOPICS_LIST_URL); + navigateToConsumers(); + verifyCurrentUrl(CONSUMERS_LIST_URL); + navigateToSchemaRegistry(); + verifyCurrentUrl(SCHEMA_REGISTRY_LIST_URL); + navigateToConnectors(); + verifyCurrentUrl(KAFKA_CONNECT_LIST_URL); + navigateToKsqlDb(); + verifyCurrentUrl(KSQL_DB_LIST_URL); + } + + @QaseId(46) + @Test + public void checkPathWhileNavigating() { + navigateToBrokersAndOpenDetails(BROKER_ID); + verifyComponentsPath(BROKERS, String.format("Broker %d", BROKER_ID)); + navigateToTopicsAndOpenDetails(TEST_TOPIC.getName()); + verifyComponentsPath(TOPICS, TEST_TOPIC.getName()); + navigateToSchemaRegistryAndOpenDetails(TEST_SCHEMA.getName()); + verifyComponentsPath(SCHEMA_REGISTRY, TEST_SCHEMA.getName()); + navigateToConnectorsAndOpenDetails(TEST_CONNECTOR.getName()); + verifyComponentsPath(KAFKA_CONNECT, TEST_CONNECTOR.getName()); + } + + @Step + private void verifyCurrentUrl(String expectedUrl) { + String urlWithoutParameters = WebDriverRunner.getWebDriver().getCurrentUrl(); + if (urlWithoutParameters.contains("?")) { + urlWithoutParameters = urlWithoutParameters.substring(0, urlWithoutParameters.indexOf("?")); + } + Assert.assertEquals(urlWithoutParameters, String.format(expectedUrl, BASE_HOST), "getCurrentUrl()"); + } + + @Step + private void verifyComponentsPath(MenuItem menuItem, String expectedPath) { + Assert.assertEquals(naviSideBar.getPagePath(menuItem), expectedPath, + String.format("getPagePath() for %s", menuItem.getPageTitle().toUpperCase())); + } + + @AfterClass(alwaysRun = true) + public void afterClass() { + apiService + .deleteTopic(TEST_TOPIC.getName()) + .deleteSchema(TEST_SCHEMA.getName()) + .deleteConnector(TEST_CONNECTOR.getName()); + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/brokers/BrokersTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/brokers/BrokersTest.java new file mode 100644 index 000000000..8fd1ffde1 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/brokers/BrokersTest.java @@ -0,0 +1,41 @@ +package com.provectus.kafka.ui.smokesuite.brokers; + +import static com.provectus.kafka.ui.pages.brokers.BrokersDetails.DetailsTab.CONFIGS; + +import com.codeborne.selenide.Condition; +import com.provectus.kafka.ui.BaseTest; +import io.qase.api.annotation.QaseId; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class BrokersTest extends BaseTest { + + @QaseId(1) + @Test + public void checkBrokersOverview() { + navigateToBrokers(); + Assert.assertTrue(brokersList.getAllBrokers().size() > 0, "getAllBrokers()"); + verifyElementsCondition(brokersList.getAllVisibleElements(), Condition.visible); + verifyElementsCondition(brokersList.getAllEnabledElements(), Condition.enabled); + } + + @QaseId(85) + @Test + public void checkExistingBrokersInCluster() { + navigateToBrokers(); + Assert.assertTrue(brokersList.getAllBrokers().size() > 0, "getAllBrokers()"); + brokersList + .openBroker(1); + brokersDetails + .waitUntilScreenReady(); + verifyElementsCondition(brokersDetails.getAllVisibleElements(), Condition.visible); + verifyElementsCondition(brokersDetails.getAllEnabledElements(), Condition.enabled); + brokersDetails + .openDetailsTab(CONFIGS); + brokersConfigTab + .waitUntilScreenReady(); + verifyElementsCondition(brokersConfigTab.getColumnHeaders(), Condition.visible); + verifyElementsCondition(brokersConfigTab.getEditButtons(), Condition.enabled); + Assert.assertTrue(brokersConfigTab.isSearchByKeyVisible(), "isSearchByKeyVisible()"); + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/connectors/ConnectorsTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/connectors/ConnectorsTest.java new file mode 100644 index 000000000..72fe769e3 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/connectors/ConnectorsTest.java @@ -0,0 +1,107 @@ +package com.provectus.kafka.ui.smokesuite.connectors; + +import static com.provectus.kafka.ui.pages.BasePage.AlertHeader.SUCCESS; +import static com.provectus.kafka.ui.utilities.FileUtils.getResourceAsString; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import com.provectus.kafka.ui.BaseTest; +import com.provectus.kafka.ui.models.Connector; +import com.provectus.kafka.ui.models.Topic; +import io.qase.api.annotation.QaseId; +import java.util.ArrayList; +import java.util.List; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class ConnectorsTest extends BaseTest { + + private static final List TOPIC_LIST = new ArrayList<>(); + private static final List CONNECTOR_LIST = new ArrayList<>(); + private static final String MESSAGE_CONTENT = "testData/topics/message_content_create_topic.json"; + private static final String MESSAGE_KEY = " "; + private static final Topic TOPIC_FOR_CREATE = new Topic() + .setName("topic-for-create-connector-" + randomAlphabetic(5)) + .setMessageContent(MESSAGE_CONTENT).setMessageKey(MESSAGE_KEY); + private static final Topic TOPIC_FOR_DELETE = new Topic() + .setName("topic-for-delete-connector-" + randomAlphabetic(5)) + .setMessageContent(MESSAGE_CONTENT).setMessageKey(MESSAGE_KEY); + private static final Topic TOPIC_FOR_UPDATE = new Topic() + .setName("topic-for-update-connector-" + randomAlphabetic(5)) + .setMessageContent(MESSAGE_CONTENT).setMessageKey(MESSAGE_KEY); + private static final Connector CONNECTOR_FOR_DELETE = new Connector() + .setName("connector-for-delete-" + randomAlphabetic(5)) + .setConfig(getResourceAsString("testData/connectors/delete_connector_config.json")); + private static final Connector CONNECTOR_FOR_UPDATE = new Connector() + .setName("connector-for-update-and-delete-" + randomAlphabetic(5)) + .setConfig(getResourceAsString("testData/connectors/config_for_create_connector_via_api.json")); + + @BeforeClass(alwaysRun = true) + public void beforeClass() { + TOPIC_LIST.addAll(List.of(TOPIC_FOR_CREATE, TOPIC_FOR_DELETE, TOPIC_FOR_UPDATE)); + TOPIC_LIST.forEach(topic -> apiService + .createTopic(topic) + .sendMessage(topic) + ); + CONNECTOR_LIST.addAll(List.of(CONNECTOR_FOR_DELETE, CONNECTOR_FOR_UPDATE)); + CONNECTOR_LIST.forEach(connector -> apiService.createConnector(connector)); + } + + @QaseId(42) + @Test + public void createConnector() { + Connector connectorForCreate = new Connector() + .setName("connector-for-create-" + randomAlphabetic(5)) + .setConfig(getResourceAsString("testData/connectors/config_for_create_connector.json")); + navigateToConnectors(); + kafkaConnectList + .clickCreateConnectorBtn(); + connectorCreateForm + .waitUntilScreenReady() + .setConnectorDetails(connectorForCreate.getName(), connectorForCreate.getConfig()) + .clickSubmitButton(); + connectorDetails + .waitUntilScreenReady(); + navigateToConnectorsAndOpenDetails(connectorForCreate.getName()); + Assert.assertTrue(connectorDetails.isConnectorHeaderVisible(connectorForCreate.getName()), + "isConnectorTitleVisible()"); + navigateToConnectors(); + Assert.assertTrue(kafkaConnectList.isConnectorVisible(CONNECTOR_FOR_DELETE.getName()), "isConnectorVisible()"); + CONNECTOR_LIST.add(connectorForCreate); + } + + @QaseId(196) + @Test + public void updateConnector() { + navigateToConnectorsAndOpenDetails(CONNECTOR_FOR_UPDATE.getName()); + connectorDetails + .openConfigTab() + .setConfig(CONNECTOR_FOR_UPDATE.getConfig()) + .clickSubmitButton(); + Assert.assertTrue(connectorDetails.isAlertWithMessageVisible(SUCCESS, "Config successfully updated."), + "isAlertWithMessageVisible()"); + navigateToConnectors(); + Assert.assertTrue(kafkaConnectList.isConnectorVisible(CONNECTOR_FOR_UPDATE.getName()), "isConnectorVisible()"); + } + + @QaseId(195) + @Test + public void deleteConnector() { + navigateToConnectorsAndOpenDetails(CONNECTOR_FOR_DELETE.getName()); + connectorDetails + .openDotMenu() + .clickDeleteBtn() + .clickConfirmBtn(); + navigateToConnectors(); + Assert.assertFalse(kafkaConnectList.isConnectorVisible(CONNECTOR_FOR_DELETE.getName()), "isConnectorVisible()"); + CONNECTOR_LIST.remove(CONNECTOR_FOR_DELETE); + } + + @AfterClass(alwaysRun = true) + public void afterClass() { + CONNECTOR_LIST.forEach(connector -> + apiService.deleteConnector(connector.getName())); + TOPIC_LIST.forEach(topic -> apiService.deleteTopic(topic.getName())); + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/ksqldb/KsqlDbTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/ksqldb/KsqlDbTest.java new file mode 100644 index 000000000..d8bda606d --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/ksqldb/KsqlDbTest.java @@ -0,0 +1,79 @@ +package com.provectus.kafka.ui.smokesuite.ksqldb; + +import static com.provectus.kafka.ui.pages.ksqldb.enums.KsqlQueryConfig.SHOW_TABLES; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import com.provectus.kafka.ui.BaseTest; +import com.provectus.kafka.ui.pages.ksqldb.models.Stream; +import com.provectus.kafka.ui.pages.ksqldb.models.Table; +import io.qase.api.annotation.QaseId; +import java.util.ArrayList; +import java.util.List; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.testng.asserts.SoftAssert; + +public class KsqlDbTest extends BaseTest { + + private static final Stream STREAM_FOR_CHECK_TABLES = new Stream() + .setName("STREAM_FOR_CHECK_TABLES_" + randomAlphabetic(4).toUpperCase()) + .setTopicName("TOPIC_FOR_STREAM_" + randomAlphabetic(4).toUpperCase()); + private static final Table FIRST_TABLE = new Table() + .setName("FIRST_TABLE" + randomAlphabetic(4).toUpperCase()) + .setStreamName(STREAM_FOR_CHECK_TABLES.getName()); + private static final Table SECOND_TABLE = new Table() + .setName("SECOND_TABLE" + randomAlphabetic(4).toUpperCase()) + .setStreamName(STREAM_FOR_CHECK_TABLES.getName()); + private static final List TOPIC_NAMES_LIST = new ArrayList<>(); + + @BeforeClass(alwaysRun = true) + public void beforeClass() { + apiService + .createStream(STREAM_FOR_CHECK_TABLES) + .createTables(FIRST_TABLE, SECOND_TABLE); + TOPIC_NAMES_LIST.addAll(List.of(STREAM_FOR_CHECK_TABLES.getTopicName(), + FIRST_TABLE.getName(), SECOND_TABLE.getName())); + } + + @QaseId(41) + @Test(priority = 1) + public void checkShowTablesRequestExecution() { + navigateToKsqlDb(); + ksqlDbList + .clickExecuteKsqlRequestBtn(); + ksqlQueryForm + .waitUntilScreenReady() + .setQuery(SHOW_TABLES.getQuery()) + .clickExecuteBtn(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(ksqlQueryForm.areResultsVisible(), "areResultsVisible()"); + softly.assertTrue(ksqlQueryForm.getTableByName(FIRST_TABLE.getName()).isVisible(), "getTableName()"); + softly.assertTrue(ksqlQueryForm.getTableByName(SECOND_TABLE.getName()).isVisible(), "getTableName()"); + softly.assertAll(); + } + + @QaseId(86) + @Test(priority = 2) + public void clearResultsForExecutedRequest() { + navigateToKsqlDb(); + ksqlDbList + .clickExecuteKsqlRequestBtn(); + ksqlQueryForm + .waitUntilScreenReady() + .setQuery(SHOW_TABLES.getQuery()) + .clickExecuteBtn(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(ksqlQueryForm.areResultsVisible(), "areResultsVisible()"); + softly.assertAll(); + ksqlQueryForm + .clickClearResultsBtn(); + softly.assertFalse(ksqlQueryForm.areResultsVisible(), "areResultsVisible()"); + softly.assertAll(); + } + + @AfterClass(alwaysRun = true) + public void afterClass() { + TOPIC_NAMES_LIST.forEach(topicName -> apiService.deleteTopic(topicName)); + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/schemas/SchemasTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/schemas/SchemasTest.java new file mode 100644 index 000000000..0fc77e1f4 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/schemas/SchemasTest.java @@ -0,0 +1,190 @@ +package com.provectus.kafka.ui.smokesuite.schemas; + +import static com.provectus.kafka.ui.utilities.FileUtils.fileToString; + +import com.codeborne.selenide.Condition; +import com.provectus.kafka.ui.BaseTest; +import com.provectus.kafka.ui.api.model.CompatibilityLevel; +import com.provectus.kafka.ui.models.Schema; +import io.qase.api.annotation.QaseId; +import java.util.ArrayList; +import java.util.List; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.testng.asserts.SoftAssert; + +public class SchemasTest extends BaseTest { + + private static final List SCHEMA_LIST = new ArrayList<>(); + private static final Schema AVRO_API = Schema.createSchemaAvro(); + private static final Schema JSON_API = Schema.createSchemaJson(); + private static final Schema PROTOBUF_API = Schema.createSchemaProtobuf(); + + @BeforeClass(alwaysRun = true) + public void beforeClass() { + SCHEMA_LIST.addAll(List.of(AVRO_API, JSON_API, PROTOBUF_API)); + SCHEMA_LIST.forEach(schema -> apiService.createSchema(schema)); + } + + @QaseId(43) + @Test(priority = 1) + public void createSchemaAvro() { + Schema schemaAvro = Schema.createSchemaAvro(); + navigateToSchemaRegistry(); + schemaRegistryList + .clickCreateSchema(); + schemaCreateForm + .setSubjectName(schemaAvro.getName()) + .setSchemaField(fileToString(schemaAvro.getValuePath())) + .selectSchemaTypeFromDropdown(schemaAvro.getType()) + .clickSubmitButton(); + schemaDetails + .waitUntilScreenReady(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(schemaDetails.isSchemaHeaderVisible(schemaAvro.getName()), "isSchemaHeaderVisible()"); + softly.assertEquals(schemaDetails.getSchemaType(), schemaAvro.getType().getValue(), "getSchemaType()"); + softly.assertEquals(schemaDetails.getCompatibility(), CompatibilityLevel.CompatibilityEnum.BACKWARD.getValue(), + "getCompatibility()"); + softly.assertAll(); + navigateToSchemaRegistry(); + Assert.assertTrue(schemaRegistryList.isSchemaVisible(AVRO_API.getName()), "isSchemaVisible()"); + SCHEMA_LIST.add(schemaAvro); + } + + @QaseId(186) + @Test(priority = 2) + public void updateSchemaAvro() { + AVRO_API.setValuePath( + System.getProperty("user.dir") + "/src/main/resources/testData/schemas/schema_avro_for_update.json"); + navigateToSchemaRegistryAndOpenDetails(AVRO_API.getName()); + schemaDetails + .openEditSchema(); + schemaCreateForm + .waitUntilScreenReady(); + verifyElementsCondition(schemaCreateForm.getAllDetailsPageElements(), Condition.visible); + SoftAssert softly = new SoftAssert(); + softly.assertFalse(schemaCreateForm.isSubmitBtnEnabled(), "isSubmitBtnEnabled()"); + softly.assertFalse(schemaCreateForm.isSchemaDropDownEnabled(), "isSchemaDropDownEnabled()"); + softly.assertAll(); + schemaCreateForm + .selectCompatibilityLevelFromDropdown(CompatibilityLevel.CompatibilityEnum.NONE) + .setNewSchemaValue(fileToString(AVRO_API.getValuePath())) + .clickSubmitButton(); + schemaDetails + .waitUntilScreenReady(); + Assert.assertEquals(schemaDetails.getCompatibility(), CompatibilityLevel.CompatibilityEnum.NONE.toString(), + "getCompatibility()"); + } + + @QaseId(44) + @Test(priority = 3) + public void compareVersionsOperation() { + navigateToSchemaRegistryAndOpenDetails(AVRO_API.getName()); + int latestVersion = schemaDetails + .waitUntilScreenReady() + .getLatestVersion(); + schemaDetails + .openCompareVersionMenu(); + int versionsNumberFromDdl = schemaCreateForm + .waitUntilScreenReady() + .openLeftVersionDdl() + .getVersionsNumberFromList(); + Assert.assertEquals(versionsNumberFromDdl, latestVersion, "Versions number is not matched"); + schemaCreateForm + .selectVersionFromDropDown(1); + Assert.assertEquals(schemaCreateForm.getMarkedLinesNumber(), 42, "getAllMarkedLines()"); + } + + @QaseId(187) + @Test(priority = 4) + public void deleteSchemaAvro() { + navigateToSchemaRegistryAndOpenDetails(AVRO_API.getName()); + schemaDetails + .removeSchema(); + schemaRegistryList + .waitUntilScreenReady(); + Assert.assertFalse(schemaRegistryList.isSchemaVisible(AVRO_API.getName()), "isSchemaVisible()"); + SCHEMA_LIST.remove(AVRO_API); + } + + @QaseId(89) + @Test(priority = 5) + public void createSchemaJson() { + Schema schemaJson = Schema.createSchemaJson(); + navigateToSchemaRegistry(); + schemaRegistryList + .clickCreateSchema(); + schemaCreateForm + .setSubjectName(schemaJson.getName()) + .setSchemaField(fileToString(schemaJson.getValuePath())) + .selectSchemaTypeFromDropdown(schemaJson.getType()) + .clickSubmitButton(); + schemaDetails + .waitUntilScreenReady(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(schemaDetails.isSchemaHeaderVisible(schemaJson.getName()), "isSchemaHeaderVisible()"); + softly.assertEquals(schemaDetails.getSchemaType(), schemaJson.getType().getValue(), "getSchemaType()"); + softly.assertEquals(schemaDetails.getCompatibility(), CompatibilityLevel.CompatibilityEnum.BACKWARD.getValue(), + "getCompatibility()"); + softly.assertAll(); + navigateToSchemaRegistry(); + Assert.assertTrue(schemaRegistryList.isSchemaVisible(JSON_API.getName()), "isSchemaVisible()"); + SCHEMA_LIST.add(schemaJson); + } + + @QaseId(189) + @Test(priority = 6) + public void deleteSchemaJson() { + navigateToSchemaRegistryAndOpenDetails(JSON_API.getName()); + schemaDetails + .removeSchema(); + schemaRegistryList + .waitUntilScreenReady(); + Assert.assertFalse(schemaRegistryList.isSchemaVisible(JSON_API.getName()), "isSchemaVisible()"); + SCHEMA_LIST.remove(JSON_API); + } + + @QaseId(91) + @Test(priority = 7) + public void createSchemaProtobuf() { + Schema schemaProtobuf = Schema.createSchemaProtobuf(); + navigateToSchemaRegistry(); + schemaRegistryList + .clickCreateSchema(); + schemaCreateForm + .setSubjectName(schemaProtobuf.getName()) + .setSchemaField(fileToString(schemaProtobuf.getValuePath())) + .selectSchemaTypeFromDropdown(schemaProtobuf.getType()) + .clickSubmitButton(); + schemaDetails + .waitUntilScreenReady(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(schemaDetails.isSchemaHeaderVisible(schemaProtobuf.getName()), "isSchemaHeaderVisible()"); + softly.assertEquals(schemaDetails.getSchemaType(), schemaProtobuf.getType().getValue(), "getSchemaType()"); + softly.assertEquals(schemaDetails.getCompatibility(), CompatibilityLevel.CompatibilityEnum.BACKWARD.getValue(), + "getCompatibility()"); + softly.assertAll(); + navigateToSchemaRegistry(); + Assert.assertTrue(schemaRegistryList.isSchemaVisible(PROTOBUF_API.getName()), "isSchemaVisible()"); + SCHEMA_LIST.add(schemaProtobuf); + } + + @QaseId(223) + @Test(priority = 8) + public void deleteSchemaProtobuf() { + navigateToSchemaRegistryAndOpenDetails(PROTOBUF_API.getName()); + schemaDetails + .removeSchema(); + schemaRegistryList + .waitUntilScreenReady(); + Assert.assertFalse(schemaRegistryList.isSchemaVisible(PROTOBUF_API.getName()), "isSchemaVisible()"); + SCHEMA_LIST.remove(PROTOBUF_API); + } + + @AfterClass(alwaysRun = true) + public void afterClass() { + SCHEMA_LIST.forEach(schema -> apiService.deleteSchema(schema.getName())); + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/MessagesTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/MessagesTest.java new file mode 100644 index 000000000..240483869 --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/MessagesTest.java @@ -0,0 +1,279 @@ +package com.provectus.kafka.ui.smokesuite.topics; + +import static com.provectus.kafka.ui.pages.BasePage.AlertHeader.SUCCESS; +import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.MESSAGES; +import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.OVERVIEW; +import static com.provectus.kafka.ui.utilities.TimeUtils.waitUntilNewMinuteStarted; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import com.provectus.kafka.ui.BaseTest; +import com.provectus.kafka.ui.models.Topic; +import com.provectus.kafka.ui.pages.topics.TopicDetails; +import io.qameta.allure.Issue; +import io.qameta.allure.Step; +import io.qase.api.annotation.QaseId; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.IntStream; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Ignore; +import org.testng.annotations.Test; +import org.testng.asserts.SoftAssert; + +public class MessagesTest extends BaseTest { + + private static final Topic TOPIC_FOR_MESSAGES = new Topic() + .setName("topic-with-clean-message-attribute-" + randomAlphabetic(5)) + .setMessageKey(randomAlphabetic(5)) + .setMessageContent(randomAlphabetic(10)); + private static final Topic TOPIC_TO_CLEAR_AND_PURGE_MESSAGES = new Topic() + .setName("topic-to-clear-and-purge-messages-" + randomAlphabetic(5)) + .setMessageKey(randomAlphabetic(5)) + .setMessageContent(randomAlphabetic(10)); + private static final Topic TOPIC_FOR_CHECK_FILTERS = new Topic() + .setName("topic-for-check-filters-" + randomAlphabetic(5)) + .setMessageKey(randomAlphabetic(5)) + .setMessageContent(randomAlphabetic(10)); + private static final Topic TOPIC_TO_RECREATE = new Topic() + .setName("topic-to-recreate-attribute-" + randomAlphabetic(5)) + .setMessageKey(randomAlphabetic(5)) + .setMessageContent(randomAlphabetic(10)); + private static final Topic TOPIC_FOR_CHECK_MESSAGES_COUNT = new Topic() + .setName("topic-for-check-messages-count" + randomAlphabetic(5)) + .setMessageKey(randomAlphabetic(5)) + .setMessageContent(randomAlphabetic(10)); + private static final List TOPIC_LIST = new ArrayList<>(); + + @BeforeClass(alwaysRun = true) + public void beforeClass() { + TOPIC_LIST.addAll(List.of(TOPIC_FOR_MESSAGES, TOPIC_FOR_CHECK_FILTERS, TOPIC_TO_CLEAR_AND_PURGE_MESSAGES, + TOPIC_TO_RECREATE, TOPIC_FOR_CHECK_MESSAGES_COUNT)); + TOPIC_LIST.forEach(topic -> apiService.createTopic(topic)); + IntStream.range(1, 3).forEach(i -> apiService.sendMessage(TOPIC_FOR_CHECK_FILTERS)); + waitUntilNewMinuteStarted(); + IntStream.range(1, 3).forEach(i -> apiService.sendMessage(TOPIC_FOR_CHECK_FILTERS)); + IntStream.range(1, 110).forEach(i -> apiService.sendMessage(TOPIC_FOR_CHECK_MESSAGES_COUNT)); + } + + @QaseId(222) + @Test(priority = 1) + public void produceMessageCheck() { + navigateToTopicsAndOpenDetails(TOPIC_FOR_MESSAGES.getName()); + topicDetails + .openDetailsTab(MESSAGES); + produceMessage(TOPIC_FOR_MESSAGES); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(topicDetails.isKeyMessageVisible((TOPIC_FOR_MESSAGES.getMessageKey())), + "isKeyMessageVisible()"); + softly.assertTrue(topicDetails.isContentMessageVisible((TOPIC_FOR_MESSAGES.getMessageContent()).trim()), + "isContentMessageVisible()"); + softly.assertAll(); + } + + @QaseId(19) + @Test(priority = 2) + public void clearMessageCheck() { + navigateToTopicsAndOpenDetails(TOPIC_FOR_MESSAGES.getName()); + topicDetails + .openDetailsTab(OVERVIEW); + int messageAmount = topicDetails.getMessageCountAmount(); + produceMessage(TOPIC_FOR_MESSAGES); + Assert.assertEquals(topicDetails.getMessageCountAmount(), messageAmount + 1, "getMessageCountAmount()"); + topicDetails + .openDotMenu() + .clickClearMessagesMenu() + .clickConfirmBtnMdl() + .waitUntilScreenReady(); + Assert.assertEquals(topicDetails.getMessageCountAmount(), 0, "getMessageCountAmount()"); + } + + @QaseId(239) + @Test(priority = 3) + public void checkClearTopicMessage() { + navigateToTopicsAndOpenDetails(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()); + topicDetails + .openDetailsTab(OVERVIEW); + produceMessage(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES); + navigateToTopics(); + Assert.assertEquals(topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(), 1, + "getNumberOfMessages()"); + topicsList + .openDotMenuByTopicName(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()) + .clickClearMessagesBtn() + .clickConfirmBtnMdl(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(topicsList.isAlertWithMessageVisible(SUCCESS, + String.format("%s messages have been successfully cleared!", TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName())), + "isAlertWithMessageVisible()"); + softly.assertEquals(topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(), 0, + "getNumberOfMessages()"); + softly.assertAll(); + } + + @QaseId(10) + @Test(priority = 4) + public void checkPurgeMessagePossibility() { + navigateToTopics(); + int messageAmount = topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(); + topicsList + .openTopic(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()); + topicDetails + .openDetailsTab(OVERVIEW); + produceMessage(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES); + navigateToTopics(); + Assert.assertEquals(topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(), + messageAmount + 1, "getNumberOfMessages()"); + topicsList + .getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()) + .selectItem(true) + .clickPurgeMessagesOfSelectedTopicsBtn(); + Assert.assertTrue(topicsList.isConfirmationMdlVisible(), "isConfirmationMdlVisible()"); + topicsList + .clickCancelBtnMdl() + .clickPurgeMessagesOfSelectedTopicsBtn() + .clickConfirmBtnMdl(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(topicsList.isAlertWithMessageVisible(SUCCESS, + String.format("%s messages have been successfully cleared!", TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName())), + "isAlertWithMessageVisible()"); + softly.assertEquals(topicsList.getTopicItem(TOPIC_TO_CLEAR_AND_PURGE_MESSAGES.getName()).getNumberOfMessages(), 0, + "getNumberOfMessages()"); + softly.assertAll(); + } + + @Ignore + @Issue("https://github.com/provectus/kafka-ui/issues/2394") + @QaseId(15) + @Test(priority = 6) + public void checkMessageFilteringByOffset() { + navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); + topicDetails + .openDetailsTab(MESSAGES); + TopicDetails.MessageGridItem secondMessage = topicDetails.getMessageByOffset(1); + topicDetails + .selectSeekTypeDdlMessagesTab("Offset") + .setSeekTypeValueFldMessagesTab(String.valueOf(secondMessage.getOffset())) + .clickSubmitFiltersBtnMessagesTab(); + SoftAssert softly = new SoftAssert(); + topicDetails.getAllMessages().forEach(message -> + softly.assertTrue(message.getOffset() == secondMessage.getOffset() + || message.getOffset() > secondMessage.getOffset(), + String.format("Expected offset is: %s, but found: %s", secondMessage.getOffset(), message.getOffset()))); + softly.assertAll(); + } + + @Ignore + @Issue("https://github.com/provectus/kafka-ui/issues/3215") + @Issue("https://github.com/provectus/kafka-ui/issues/2345") + @QaseId(16) + @Test(priority = 7) + public void checkMessageFilteringByTimestamp() { + navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); + topicDetails + .openDetailsTab(MESSAGES); + LocalDateTime firstTimestamp = topicDetails.getMessageByOffset(0).getTimestamp(); + List nextMessages = topicDetails.getAllMessages().stream() + .filter(message -> message.getTimestamp().getMinute() != firstTimestamp.getMinute()) + .toList(); + LocalDateTime nextTimestamp = nextMessages.stream() + .findFirst().orElseThrow().getTimestamp(); + topicDetails + .selectSeekTypeDdlMessagesTab("Timestamp") + .openCalendarSeekType() + .selectDateAndTimeByCalendar(nextTimestamp) + .clickSubmitFiltersBtnMessagesTab(); + SoftAssert softly = new SoftAssert(); + topicDetails.getAllMessages().forEach(message -> + softly.assertTrue(message.getTimestamp().isEqual(nextTimestamp) + || message.getTimestamp().isAfter(nextTimestamp), + String.format("Expected that %s is not before %s.", message.getTimestamp(), nextTimestamp))); + softly.assertAll(); + } + + @QaseId(246) + @Test(priority = 8) + public void checkClearTopicMessageFromOverviewTab() { + navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); + topicDetails + .openDetailsTab(OVERVIEW) + .openDotMenu() + .clickClearMessagesMenu() + .clickConfirmBtnMdl(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, + String.format("%s messages have been successfully cleared!", TOPIC_FOR_CHECK_FILTERS.getName())), + "isAlertWithMessageVisible()"); + softly.assertEquals(topicDetails.getMessageCountAmount(), 0, + "getMessageCountAmount()= " + topicDetails.getMessageCountAmount()); + softly.assertAll(); + } + + @QaseId(240) + @Test(priority = 9) + public void checkRecreateTopic() { + navigateToTopicsAndOpenDetails(TOPIC_TO_RECREATE.getName()); + topicDetails + .openDetailsTab(OVERVIEW); + produceMessage(TOPIC_TO_RECREATE); + navigateToTopics(); + Assert.assertEquals(topicsList.getTopicItem(TOPIC_TO_RECREATE.getName()).getNumberOfMessages(), 1, + "getNumberOfMessages()"); + topicsList + .openDotMenuByTopicName(TOPIC_TO_RECREATE.getName()) + .clickRecreateTopicBtn() + .clickConfirmBtnMdl(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, + String.format("Topic %s successfully recreated!", TOPIC_TO_RECREATE.getName())), + "isAlertWithMessageVisible()"); + softly.assertEquals(topicsList.getTopicItem(TOPIC_TO_RECREATE.getName()).getNumberOfMessages(), 0, + "getNumberOfMessages()"); + softly.assertAll(); + } + + @Ignore + @Issue("https://github.com/provectus/kafka-ui/issues/3129") + @QaseId(267) + @Test(priority = 10) + public void checkMessagesCountPerPageWithinTopic() { + navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_MESSAGES_COUNT.getName()); + topicDetails + .openDetailsTab(MESSAGES); + int messagesPerPage = topicDetails.getAllMessages().size(); + SoftAssert softly = new SoftAssert(); + softly.assertEquals(messagesPerPage, 100, "getAllMessages()"); + softly.assertFalse(topicDetails.isBackButtonEnabled(), "isBackButtonEnabled()"); + softly.assertTrue(topicDetails.isNextButtonEnabled(), "isNextButtonEnabled()"); + softly.assertAll(); + int lastOffsetOnPage = topicDetails.getAllMessages() + .get(messagesPerPage - 1).getOffset(); + topicDetails + .clickNextButton(); + softly.assertEquals(topicDetails.getAllMessages().stream().findFirst().orElseThrow().getOffset(), + lastOffsetOnPage + 1, "findFirst().getOffset()"); + softly.assertTrue(topicDetails.isBackButtonEnabled(), "isBackButtonEnabled()"); + softly.assertFalse(topicDetails.isNextButtonEnabled(), "isNextButtonEnabled()"); + softly.assertAll(); + } + + @Step + private void produceMessage(Topic topic) { + topicDetails + .clickProduceMessageBtn(); + produceMessagePanel + .waitUntilScreenReady() + .setKeyField(topic.getMessageKey()) + .setContentFiled(topic.getMessageContent()) + .submitProduceMessage(); + topicDetails + .waitUntilScreenReady(); + } + + @AfterClass(alwaysRun = true) + public void afterClass() { + TOPIC_LIST.forEach(topic -> apiService.deleteTopic(topic.getName())); + } +} diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/TopicsTest.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/TopicsTest.java new file mode 100644 index 000000000..319c5f74f --- /dev/null +++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/smokesuite/topics/TopicsTest.java @@ -0,0 +1,500 @@ +package com.provectus.kafka.ui.smokesuite.topics; + +import static com.provectus.kafka.ui.pages.BasePage.AlertHeader.SUCCESS; +import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.CONSUMERS; +import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.MESSAGES; +import static com.provectus.kafka.ui.pages.topics.TopicDetails.TopicMenu.SETTINGS; +import static com.provectus.kafka.ui.pages.topics.enums.CleanupPolicyValue.COMPACT; +import static com.provectus.kafka.ui.pages.topics.enums.CleanupPolicyValue.DELETE; +import static com.provectus.kafka.ui.pages.topics.enums.CustomParameterType.COMPRESSION_TYPE; +import static com.provectus.kafka.ui.pages.topics.enums.MaxSizeOnDisk.NOT_SET; +import static com.provectus.kafka.ui.pages.topics.enums.MaxSizeOnDisk.SIZE_1_GB; +import static com.provectus.kafka.ui.pages.topics.enums.MaxSizeOnDisk.SIZE_50_GB; +import static com.provectus.kafka.ui.pages.topics.enums.TimeToRetain.BTN_2_DAYS; +import static com.provectus.kafka.ui.pages.topics.enums.TimeToRetain.BTN_7_DAYS; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomUtils.nextInt; + +import com.codeborne.selenide.Condition; +import com.provectus.kafka.ui.BaseTest; +import com.provectus.kafka.ui.models.Topic; +import io.qameta.allure.Issue; +import io.qase.api.annotation.QaseId; +import java.util.ArrayList; +import java.util.List; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Ignore; +import org.testng.annotations.Test; +import org.testng.asserts.SoftAssert; + +public class TopicsTest extends BaseTest { + + private static final Topic TOPIC_TO_CREATE = new Topic() + .setName("new-topic-" + randomAlphabetic(5)) + .setNumberOfPartitions(1) + .setCustomParameterType(COMPRESSION_TYPE) + .setCustomParameterValue("producer") + .setCleanupPolicyValue(DELETE); + private static final Topic TOPIC_TO_UPDATE_AND_DELETE = new Topic() + .setName("topic-to-update-and-delete-" + randomAlphabetic(5)) + .setNumberOfPartitions(1) + .setCleanupPolicyValue(DELETE) + .setTimeToRetain(BTN_7_DAYS) + .setMaxSizeOnDisk(NOT_SET) + .setMaxMessageBytes("1048588") + .setMessageKey(randomAlphabetic(5)) + .setMessageContent(randomAlphabetic(10)); + private static final Topic TOPIC_TO_CHECK_SETTINGS = new Topic() + .setName("new-topic-" + randomAlphabetic(5)) + .setNumberOfPartitions(1) + .setMaxMessageBytes("1000012") + .setMaxSizeOnDisk(NOT_SET); + private static final Topic TOPIC_FOR_CHECK_FILTERS = new Topic() + .setName("topic-for-check-filters-" + randomAlphabetic(5)); + private static final Topic TOPIC_FOR_DELETE = new Topic() + .setName("topic-to-delete-" + randomAlphabetic(5)); + private static final List TOPIC_LIST = new ArrayList<>(); + + @BeforeClass(alwaysRun = true) + public void beforeClass() { + TOPIC_LIST.addAll(List.of(TOPIC_TO_UPDATE_AND_DELETE, TOPIC_FOR_DELETE, TOPIC_FOR_CHECK_FILTERS)); + TOPIC_LIST.forEach(topic -> apiService.createTopic(topic)); + } + + @QaseId(199) + @Test(priority = 1) + public void createTopic() { + navigateToTopics(); + topicsList + .clickAddTopicBtn(); + topicCreateEditForm + .waitUntilScreenReady() + .setTopicName(TOPIC_TO_CREATE.getName()) + .setNumberOfPartitions(TOPIC_TO_CREATE.getNumberOfPartitions()) + .selectCleanupPolicy(TOPIC_TO_CREATE.getCleanupPolicyValue()) + .clickSaveTopicBtn(); + navigateToTopicsAndOpenDetails(TOPIC_TO_CREATE.getName()); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(topicDetails.isTopicHeaderVisible(TOPIC_TO_CREATE.getName()), "isTopicHeaderVisible()"); + softly.assertEquals(topicDetails.getCleanUpPolicy(), TOPIC_TO_CREATE.getCleanupPolicyValue().toString(), + "getCleanUpPolicy()"); + softly.assertEquals(topicDetails.getPartitions(), TOPIC_TO_CREATE.getNumberOfPartitions(), "getPartitions()"); + softly.assertAll(); + navigateToTopics(); + Assert.assertTrue(topicsList.isTopicVisible(TOPIC_TO_CREATE.getName()), "isTopicVisible()"); + TOPIC_LIST.add(TOPIC_TO_CREATE); + } + + @QaseId(7) + @Test(priority = 2) + void checkAvailableOperations() { + navigateToTopics(); + topicsList + .getTopicItem(TOPIC_TO_UPDATE_AND_DELETE.getName()) + .selectItem(true); + verifyElementsCondition(topicsList.getActionButtons(), Condition.enabled); + topicsList + .getTopicItem(TOPIC_FOR_CHECK_FILTERS.getName()) + .selectItem(true); + Assert.assertFalse(topicsList.isCopySelectedTopicBtnEnabled(), "isCopySelectedTopicBtnEnabled()"); + } + + @Ignore + @Issue("https://github.com/provectus/kafka-ui/issues/3071") + @QaseId(268) + @Test(priority = 3) + public void checkCustomParametersWithinEditExistingTopic() { + navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE_AND_DELETE.getName()); + topicDetails + .openDotMenu() + .clickEditSettingsMenu(); + SoftAssert softly = new SoftAssert(); + topicCreateEditForm + .waitUntilScreenReady() + .clickAddCustomParameterTypeButton() + .openCustomParameterTypeDdl() + .getAllDdlOptions() + .forEach(option -> + softly.assertTrue(!option.is(Condition.attribute("disabled")), + option.getText() + " is enabled:")); + softly.assertAll(); + } + + @QaseId(197) + @Test(priority = 4) + public void updateTopic() { + navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE_AND_DELETE.getName()); + topicDetails + .openDotMenu() + .clickEditSettingsMenu(); + topicCreateEditForm + .waitUntilScreenReady(); + SoftAssert softly = new SoftAssert(); + softly.assertEquals(topicCreateEditForm.getCleanupPolicy(), + TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue().getVisibleText(), "getCleanupPolicy()"); + softly.assertEquals(topicCreateEditForm.getTimeToRetain(), + TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain().getValue(), "getTimeToRetain()"); + softly.assertEquals(topicCreateEditForm.getMaxSizeOnDisk(), + TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk().getVisibleText(), "getMaxSizeOnDisk()"); + softly.assertEquals(topicCreateEditForm.getMaxMessageBytes(), + TOPIC_TO_UPDATE_AND_DELETE.getMaxMessageBytes(), "getMaxMessageBytes()"); + softly.assertAll(); + TOPIC_TO_UPDATE_AND_DELETE + .setCleanupPolicyValue(COMPACT) + .setTimeToRetain(BTN_2_DAYS) + .setMaxSizeOnDisk(SIZE_50_GB).setMaxMessageBytes("1048589"); + topicCreateEditForm + .selectCleanupPolicy((TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue())) + .setTimeToRetainDataByButtons(TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain()) + .setMaxSizeOnDiskInGB(TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk()) + .setMaxMessageBytes(TOPIC_TO_UPDATE_AND_DELETE.getMaxMessageBytes()) + .clickSaveTopicBtn(); + softly.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, "Topic successfully updated."), + "isAlertWithMessageVisible()"); + softly.assertTrue(topicDetails.isTopicHeaderVisible(TOPIC_TO_UPDATE_AND_DELETE.getName()), + "isTopicHeaderVisible()"); + softly.assertAll(); + topicDetails + .waitUntilScreenReady(); + navigateToTopicsAndOpenDetails(TOPIC_TO_UPDATE_AND_DELETE.getName()); + topicDetails + .openDotMenu() + .clickEditSettingsMenu(); + softly.assertFalse(topicCreateEditForm.isNameFieldEnabled(), "isNameFieldEnabled()"); + softly.assertEquals(topicCreateEditForm.getCleanupPolicy(), + TOPIC_TO_UPDATE_AND_DELETE.getCleanupPolicyValue().getVisibleText(), "getCleanupPolicy()"); + softly.assertEquals(topicCreateEditForm.getTimeToRetain(), + TOPIC_TO_UPDATE_AND_DELETE.getTimeToRetain().getValue(), "getTimeToRetain()"); + softly.assertEquals(topicCreateEditForm.getMaxSizeOnDisk(), + TOPIC_TO_UPDATE_AND_DELETE.getMaxSizeOnDisk().getVisibleText(), "getMaxSizeOnDisk()"); + softly.assertEquals(topicCreateEditForm.getMaxMessageBytes(), + TOPIC_TO_UPDATE_AND_DELETE.getMaxMessageBytes(), "getMaxMessageBytes()"); + softly.assertAll(); + } + + @QaseId(242) + @Test(priority = 5) + public void removeTopicFromTopicList() { + navigateToTopics(); + topicsList + .openDotMenuByTopicName(TOPIC_TO_UPDATE_AND_DELETE.getName()) + .clickRemoveTopicBtn() + .clickConfirmBtnMdl(); + Assert.assertTrue(topicsList.isAlertWithMessageVisible(SUCCESS, + String.format("Topic %s successfully deleted!", TOPIC_TO_UPDATE_AND_DELETE.getName())), + "isAlertWithMessageVisible()"); + TOPIC_LIST.remove(TOPIC_TO_UPDATE_AND_DELETE); + } + + @QaseId(207) + @Test(priority = 6) + public void deleteTopic() { + navigateToTopicsAndOpenDetails(TOPIC_FOR_DELETE.getName()); + topicDetails + .openDotMenu() + .clickDeleteTopicMenu() + .clickConfirmBtnMdl(); + navigateToTopics(); + Assert.assertFalse(topicsList.isTopicVisible(TOPIC_FOR_DELETE.getName()), "isTopicVisible"); + TOPIC_LIST.remove(TOPIC_FOR_DELETE); + } + + @QaseId(20) + @Test(priority = 7) + public void redirectToConsumerFromTopic() { + String topicName = "source-activities"; + String consumerGroupId = "connect-sink_postgres_activities"; + navigateToTopicsAndOpenDetails(topicName); + topicDetails + .openDetailsTab(CONSUMERS) + .openConsumerGroup(consumerGroupId); + consumersDetails + .waitUntilScreenReady(); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(consumersDetails.isRedirectedConsumerTitleVisible(consumerGroupId), + "isRedirectedConsumerTitleVisible()"); + softly.assertTrue(consumersDetails.isTopicInConsumersDetailsVisible(topicName), + "isTopicInConsumersDetailsVisible()"); + softly.assertAll(); + } + + @QaseId(4) + @Test(priority = 8) + public void checkTopicCreatePossibility() { + navigateToTopics(); + topicsList + .clickAddTopicBtn(); + topicCreateEditForm + .waitUntilScreenReady(); + Assert.assertFalse(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); + topicCreateEditForm + .setTopicName("testName"); + Assert.assertFalse(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); + topicCreateEditForm + .setTopicName(null) + .setNumberOfPartitions(nextInt(1, 10)); + Assert.assertFalse(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); + topicCreateEditForm + .setTopicName("testName"); + Assert.assertTrue(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); + } + + @QaseId(266) + @Test(priority = 9) + public void checkTimeToRetainDataCustomValueWithEditingTopic() { + Topic topicToRetainData = new Topic() + .setName("topic-to-retain-data-" + randomAlphabetic(5)) + .setTimeToRetainData("86400000"); + navigateToTopics(); + topicsList + .clickAddTopicBtn(); + topicCreateEditForm + .waitUntilScreenReady() + .setTopicName(topicToRetainData.getName()) + .setNumberOfPartitions(1) + .setTimeToRetainDataInMs("604800000"); + Assert.assertEquals(topicCreateEditForm.getTimeToRetain(), "604800000", "getTimeToRetain()"); + topicCreateEditForm + .setTimeToRetainDataInMs(topicToRetainData.getTimeToRetainData()) + .clickSaveTopicBtn(); + topicDetails + .waitUntilScreenReady() + .openDotMenu() + .clickEditSettingsMenu(); + Assert.assertEquals(topicCreateEditForm.getTimeToRetain(), topicToRetainData.getTimeToRetainData(), + "getTimeToRetain()"); + topicDetails + .openDetailsTab(SETTINGS); + Assert.assertEquals(topicDetails.getSettingsGridValueByKey("retention.ms"), topicToRetainData.getTimeToRetainData(), + "getSettingsGridValueByKey()"); + TOPIC_LIST.add(topicToRetainData); + } + + @QaseId(6) + @Test(priority = 10) + public void checkCustomParametersWithinCreateNewTopic() { + navigateToTopics(); + topicsList + .clickAddTopicBtn(); + topicCreateEditForm + .waitUntilScreenReady() + .setTopicName(TOPIC_TO_CREATE.getName()) + .clickAddCustomParameterTypeButton() + .setCustomParameterType(TOPIC_TO_CREATE.getCustomParameterType()); + Assert.assertTrue(topicCreateEditForm.isDeleteCustomParameterButtonEnabled(), + "isDeleteCustomParameterButtonEnabled()"); + topicCreateEditForm + .clearCustomParameterValue(); + Assert.assertTrue(topicCreateEditForm.isValidationMessageCustomParameterValueVisible(), + "isValidationMessageCustomParameterValueVisible()"); + } + + @QaseId(2) + @Test(priority = 11) + public void checkTopicListElements() { + navigateToTopics(); + verifyElementsCondition(topicsList.getAllVisibleElements(), Condition.visible); + verifyElementsCondition(topicsList.getAllEnabledElements(), Condition.enabled); + } + + @QaseId(12) + @Test(priority = 12) + public void addNewFilterWithinTopic() { + String filterName = randomAlphabetic(5); + navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); + topicDetails + .openDetailsTab(MESSAGES) + .clickMessagesAddFiltersBtn() + .waitUntilAddFiltersMdlVisible(); + verifyElementsCondition(topicDetails.getAllAddFilterModalVisibleElements(), Condition.visible); + verifyElementsCondition(topicDetails.getAllAddFilterModalEnabledElements(), Condition.enabled); + verifyElementsCondition(topicDetails.getAllAddFilterModalDisabledElements(), Condition.disabled); + Assert.assertFalse(topicDetails.isSaveThisFilterCheckBoxSelected(), "isSaveThisFilterCheckBoxSelected()"); + topicDetails + .setFilterCodeFieldAddFilterMdl(filterName); + Assert.assertTrue(topicDetails.isAddFilterBtnAddFilterMdlEnabled(), "isAddFilterBtnAddFilterMdlEnabled()"); + topicDetails.clickAddFilterBtnAndCloseMdl(true); + Assert.assertTrue(topicDetails.isActiveFilterVisible(filterName), "isActiveFilterVisible()"); + } + + @QaseId(13) + @Test(priority = 13) + public void checkFilterSavingWithinSavedFilters() { + String displayName = randomAlphabetic(5); + navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); + topicDetails + .openDetailsTab(MESSAGES) + .clickMessagesAddFiltersBtn() + .waitUntilAddFiltersMdlVisible() + .setFilterCodeFieldAddFilterMdl(randomAlphabetic(4)) + .selectSaveThisFilterCheckboxMdl(true) + .setDisplayNameFldAddFilterMdl(displayName); + Assert.assertTrue(topicDetails.isAddFilterBtnAddFilterMdlEnabled(), + "isAddFilterBtnAddFilterMdlEnabled()"); + topicDetails + .clickAddFilterBtnAndCloseMdl(false) + .openSavedFiltersListMdl(); + Assert.assertTrue(topicDetails.isFilterVisibleAtSavedFiltersMdl(displayName), + "isFilterVisibleAtSavedFiltersMdl()"); + } + + @QaseId(14) + @Test(priority = 14) + public void checkApplyingSavedFilterWithinTopicMessages() { + String displayName = randomAlphabetic(5); + navigateToTopicsAndOpenDetails(TOPIC_FOR_CHECK_FILTERS.getName()); + topicDetails + .openDetailsTab(MESSAGES) + .clickMessagesAddFiltersBtn() + .waitUntilAddFiltersMdlVisible() + .setFilterCodeFieldAddFilterMdl(randomAlphabetic(4)) + .selectSaveThisFilterCheckboxMdl(true) + .setDisplayNameFldAddFilterMdl(displayName) + .clickAddFilterBtnAndCloseMdl(false) + .openSavedFiltersListMdl() + .selectFilterAtSavedFiltersMdl(displayName) + .clickSelectFilterBtnAtSavedFiltersMdl(); + Assert.assertTrue(topicDetails.isActiveFilterVisible(displayName), "isActiveFilterVisible()"); + } + + @QaseId(11) + @Test(priority = 15) + public void checkShowInternalTopicsButton() { + navigateToTopics(); + topicsList + .setShowInternalRadioButton(true); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(topicsList.getInternalTopics().size() > 0, "getInternalTopics()"); + softly.assertTrue(topicsList.getNonInternalTopics().size() > 0, "getNonInternalTopics()"); + softly.assertAll(); + topicsList + .setShowInternalRadioButton(false); + softly.assertEquals(topicsList.getInternalTopics().size(), 0, "getInternalTopics()"); + softly.assertTrue(topicsList.getNonInternalTopics().size() > 0, "getNonInternalTopics()"); + softly.assertAll(); + } + + @QaseId(334) + @Test(priority = 16) + public void checkInternalTopicsNaming() { + navigateToTopics(); + SoftAssert softly = new SoftAssert(); + topicsList + .setShowInternalRadioButton(true) + .getInternalTopics() + .forEach(topic -> softly.assertTrue(topic.getName().startsWith("_"), + String.format("'%s' starts with '_'", topic.getName()))); + softly.assertAll(); + } + + @QaseId(56) + @Test(priority = 17) + public void checkRetentionBytesAccordingToMaxSizeOnDisk() { + navigateToTopics(); + topicsList + .clickAddTopicBtn(); + topicCreateEditForm + .waitUntilScreenReady() + .setTopicName(TOPIC_TO_CHECK_SETTINGS.getName()) + .setNumberOfPartitions(TOPIC_TO_CHECK_SETTINGS.getNumberOfPartitions()) + .setMaxMessageBytes(TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes()) + .clickSaveTopicBtn(); + topicDetails + .waitUntilScreenReady(); + TOPIC_LIST.add(TOPIC_TO_CHECK_SETTINGS); + topicDetails + .openDetailsTab(SETTINGS); + topicSettingsTab + .waitUntilScreenReady(); + SoftAssert softly = new SoftAssert(); + softly.assertEquals(topicSettingsTab.getValueByKey("retention.bytes"), + TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk().getOptionValue(), "getValueOfKey(retention.bytes)"); + softly.assertEquals(topicSettingsTab.getValueByKey("max.message.bytes"), + TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes(), "getValueOfKey(max.message.bytes)"); + softly.assertAll(); + TOPIC_TO_CHECK_SETTINGS + .setMaxSizeOnDisk(SIZE_1_GB) + .setMaxMessageBytes("1000056"); + topicDetails + .openDotMenu() + .clickEditSettingsMenu(); + topicCreateEditForm + .waitUntilScreenReady() + .setMaxSizeOnDiskInGB(TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk()) + .setMaxMessageBytes(TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes()) + .clickSaveTopicBtn(); + topicDetails + .waitUntilScreenReady() + .openDetailsTab(SETTINGS); + topicSettingsTab + .waitUntilScreenReady(); + softly.assertEquals(topicSettingsTab.getValueByKey("retention.bytes"), + TOPIC_TO_CHECK_SETTINGS.getMaxSizeOnDisk().getOptionValue(), "getValueOfKey(retention.bytes)"); + softly.assertEquals(topicSettingsTab.getValueByKey("max.message.bytes"), + TOPIC_TO_CHECK_SETTINGS.getMaxMessageBytes(), "getValueOfKey(max.message.bytes)"); + softly.assertAll(); + } + + @QaseId(247) + @Test(priority = 18) + public void recreateTopicFromTopicProfile() { + Topic topicToRecreate = new Topic() + .setName("topic-to-recreate-" + randomAlphabetic(5)) + .setNumberOfPartitions(1); + navigateToTopics(); + topicsList + .clickAddTopicBtn(); + topicCreateEditForm + .waitUntilScreenReady() + .setTopicName(topicToRecreate.getName()) + .setNumberOfPartitions(topicToRecreate.getNumberOfPartitions()) + .clickSaveTopicBtn(); + topicDetails + .waitUntilScreenReady(); + TOPIC_LIST.add(topicToRecreate); + topicDetails + .openDotMenu() + .clickRecreateTopicMenu(); + Assert.assertTrue(topicDetails.isConfirmationMdlVisible(), "isConfirmationMdlVisible()"); + topicDetails + .clickConfirmBtnMdl(); + Assert.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, + String.format("Topic %s successfully recreated!", topicToRecreate.getName())), + "isAlertWithMessageVisible()"); + } + + @QaseId(8) + @Test(priority = 19) + public void checkCopyTopicPossibility() { + Topic topicToCopy = new Topic() + .setName("topic-to-copy-" + randomAlphabetic(5)) + .setNumberOfPartitions(1); + navigateToTopics(); + topicsList + .getAnyNonInternalTopic() + .selectItem(true) + .clickCopySelectedTopicBtn(); + topicCreateEditForm + .waitUntilScreenReady(); + Assert.assertFalse(topicCreateEditForm.isCreateTopicButtonEnabled(), "isCreateTopicButtonEnabled()"); + topicCreateEditForm + .setTopicName(topicToCopy.getName()) + .setNumberOfPartitions(topicToCopy.getNumberOfPartitions()) + .clickSaveTopicBtn(); + topicDetails + .waitUntilScreenReady(); + TOPIC_LIST.add(topicToCopy); + SoftAssert softly = new SoftAssert(); + softly.assertTrue(topicDetails.isAlertWithMessageVisible(SUCCESS, "Topic successfully created."), + "isAlertWithMessageVisible()"); + softly.assertTrue(topicDetails.isTopicHeaderVisible(topicToCopy.getName()), "isTopicHeaderVisible()"); + softly.assertAll(); + } + + @AfterClass(alwaysRun = true) + public void afterClass() { + TOPIC_LIST.forEach(topic -> apiService.deleteTopic(topic.getName())); + } +} diff --git a/kafka-ui-e2e-checks/src/test/resources/manual.xml b/kafka-ui-e2e-checks/src/test/resources/manual.xml index 89dbd7e17..f9ea5e5b0 100644 --- a/kafka-ui-e2e-checks/src/test/resources/manual.xml +++ b/kafka-ui-e2e-checks/src/test/resources/manual.xml @@ -2,7 +2,7 @@ - + diff --git a/kafka-ui-e2e-checks/src/test/resources/qase.xml b/kafka-ui-e2e-checks/src/test/resources/qase.xml index 8dd1dd152..df3193171 100644 --- a/kafka-ui-e2e-checks/src/test/resources/qase.xml +++ b/kafka-ui-e2e-checks/src/test/resources/qase.xml @@ -2,7 +2,7 @@ - + diff --git a/kafka-ui-e2e-checks/src/test/resources/regression.xml b/kafka-ui-e2e-checks/src/test/resources/regression.xml index 6cc4c5bd4..fe102bae3 100644 --- a/kafka-ui-e2e-checks/src/test/resources/regression.xml +++ b/kafka-ui-e2e-checks/src/test/resources/regression.xml @@ -2,9 +2,9 @@ - - - + + + diff --git a/kafka-ui-e2e-checks/src/test/resources/sanity.xml b/kafka-ui-e2e-checks/src/test/resources/sanity.xml index 01aa279c0..c6b9b0602 100644 --- a/kafka-ui-e2e-checks/src/test/resources/sanity.xml +++ b/kafka-ui-e2e-checks/src/test/resources/sanity.xml @@ -2,7 +2,7 @@ - + diff --git a/kafka-ui-e2e-checks/src/test/resources/smoke.xml b/kafka-ui-e2e-checks/src/test/resources/smoke.xml index b370468e4..ab2929ff3 100644 --- a/kafka-ui-e2e-checks/src/test/resources/smoke.xml +++ b/kafka-ui-e2e-checks/src/test/resources/smoke.xml @@ -2,7 +2,7 @@ - +