dashboard_detail.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from .base import BasePage
  2. EDIT_WIDGET_BUTTON = '[data-test-id="widget-edit"]'
  3. WIDGET_DRAG_HANDLE = ".widget-drag"
  4. WIDGET_RESIZE_HANDLE = ".widget-resize"
  5. WIDGET_TITLE_FIELD = 'input[data-test-id="widget-title-input"]'
  6. class DashboardDetailPage(BasePage):
  7. def __init__(self, browser, client, **kwargs):
  8. super().__init__(browser)
  9. self.client = client
  10. self.organization = kwargs.get("organization", None)
  11. self.dashboard = kwargs.get("dashboard", None)
  12. def wait_until_loaded(self):
  13. self.browser.wait_until_not('[data-test-id="events-request-loading"]')
  14. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  15. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  16. self.browser.wait_until_not(".loading")
  17. def visit_default_overview(self):
  18. self.browser.get(f"/organizations/{self.organization.slug}/dashboard/default-overview/")
  19. self.wait_until_loaded()
  20. self.browser.driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
  21. self.wait_until_loaded()
  22. def visit_create_dashboard(self):
  23. self.browser.get(f"/organizations/{self.organization.slug}/dashboards/new/")
  24. self.wait_until_loaded()
  25. def visit_dashboard_detail(self):
  26. self.browser.get(f"/organizations/{self.organization.slug}/dashboard/{self.dashboard.id}/")
  27. self.wait_until_loaded()
  28. def enter_edit_state(self):
  29. button = self.browser.element('[data-test-id="dashboard-edit"]')
  30. self.browser.wait_until_clickable('[data-test-id="dashboard-edit"]')
  31. button.click()
  32. self.wait_until_loaded()
  33. def click_dashboard_add_widget_button(self):
  34. button = self.browser.element('[data-test-id="widget-add"]')
  35. # HACK: Use JavaScript to execute click to avoid click intercepted issues
  36. self.browser.driver.execute_script("arguments[0].click()", button)
  37. self.wait_until_loaded()
  38. def click_dashboard_header_add_widget_button(self):
  39. button = self.browser.element('[data-test-id="add-widget-library"]')
  40. self.browser.wait_until_clickable('[data-test-id="add-widget-library"]')
  41. button.click()
  42. self.wait_until_loaded()
  43. def click_cancel_button(self):
  44. button = self.browser.element('[data-test-id="dashboard-cancel"]')
  45. self.browser.wait_until_clickable('[data-test-id="dashboard-cancel"]')
  46. button.click()
  47. self.wait_until_loaded()
  48. def add_widget_through_dashboard(self, widget_title):
  49. self.click_dashboard_add_widget_button()
  50. title_input = self.browser.element(WIDGET_TITLE_FIELD)
  51. title_input.send_keys(widget_title)
  52. button = self.browser.element('[data-test-id="add-widget"]')
  53. button.click()
  54. self.wait_until_loaded()
  55. def save_dashboard(self):
  56. button = self.browser.element('[data-test-id="dashboard-commit"]')
  57. self.browser.wait_until_clickable('[data-test-id="dashboard-commit"]')
  58. button.click()
  59. self.wait_until_loaded()