Skip to content

Commit

Permalink
Merge pull request #621 from antip00/tests-fix
Browse files Browse the repository at this point in the history
Adding test for #615.
  • Loading branch information
Slach authored Sep 12, 2024
2 parents a521a07 + a78b693 commit f6ebddc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ def confirm_delete_button(self):
return driver.find_element(SelectBy.CSS_SELECTOR,
"[data-testid='data-testid Confirm Modal Danger Button']")

@property
def use_default_values_toggle(self):
driver: WebDriver = current().context.driver
return driver.find_element(SelectBy.CSS_SELECTOR,
"[for='useDefaultConfiguration']")


locators = Locators()
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def enter_url_into_url_field(self, url):
locators.url_field.send_keys(url)


@TestStep(When)
def get_url_textfield_text(self):
"""Get url from url textfield."""

return locators.url_field.get_attribute('value')


@TestStep(When)
def click_save_and_test_button(self):
"""Click submit button."""
Expand Down Expand Up @@ -151,6 +158,13 @@ def click_use_post_method_toggle(self):
locators.use_post_method_to_send_queries.click()


@TestStep(When)
def click_use_default_values_toggle(self):
"""Click `Use default values toggle`."""

locators.use_default_values_toggle.click()


@TestStep(When)
def click_add_cors_flag_to_request_toggle(self):
"""Click add CORS flag to request toggle."""
Expand Down
40 changes: 39 additions & 1 deletion tests/testflows/tests/automated/e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import steps.dashboards.view as dashboards
import steps.panel.sql_editor.view as sql_editor
import steps.connections.datasources.view as datasources
import steps.connections.datasources.new.view as datasources_new
import steps.connections.datasources.altinity_edit.view as datasources_altinity_edit

from requirements.requirements import *
Expand All @@ -24,7 +25,7 @@ def gh_api_check(self):
for attempt in retries(delay=5, timeout=50):
with attempt:
with delay():
with Then("I take screenshot of Repeated postgresql panel"):
with Then("I take screenshot of Pull request events for grafana/grafana panel"):
dashboard.take_screenshot_for_panel(panel_name="Pull request events for grafana/grafana", screenshot_name="gh-api_panel")

with delay():
Expand Down Expand Up @@ -129,6 +130,43 @@ def mixed_data_sources(self):
dashboard.saving_dashboard()


@TestScenario
def default_values_not_affect_url_textfield(self):
"""Check that default values not affect to url textfield in datasource setup."""

with When("I open create new datasource view"):
with delay():
datasources_new.open_add_new_datasource_endpoint()

with And("I click new altinity grafana plugin"):
with delay():
datasources_new.click_new_altinity_plugin_datasource()

with And("I enter url"):
with delay():
datasources_altinity_edit.enter_url_into_url_field(url="http://clickhouse:8123")

with And("I enter datasource name"):
with delay():
datasources_altinity_edit.enter_name_into_name_field(datasource_name="default_values_not_affect_url_textfield")

with And("I click save and test button"):
with delay():
datasources_altinity_edit.click_save_and_test_button()

with And("I click `Use default values toggle`"):
with delay():
datasources_altinity_edit.click_use_default_values_toggle()

with And("I click use post method toggle"):
with delay():
datasources_altinity_edit.click_use_post_method_toggle()

with Then("I check that url textfield is not change after clicking on the toggle"):
with delay():
assert datasources_altinity_edit.get_url_textfield_text() == "http://clickhouse:8123", error()


@TestFeature
@Name("e2e")
def feature(self):
Expand Down

0 comments on commit f6ebddc

Please sign in to comment.