dashboard_detail.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. from .base import BasePage
  2. EDIT_WIDGET_BUTTON = '[data-test-id="widget-edit"]'
  3. WIDGET_DRAG_HANDLE = ".widget-drag"
  4. WIDGET_RESIZE_HANDLE = ".react-resizable-handle"
  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. def visit_default_overview(self):
  17. self.browser.get(f"/organizations/{self.organization.slug}/dashboard/default-overview/")
  18. self.wait_until_loaded()
  19. self.browser.driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
  20. self.wait_until_loaded()
  21. def visit_create_dashboard(self):
  22. self.browser.get(f"/organizations/{self.organization.slug}/dashboards/new/")
  23. self.wait_until_loaded()
  24. def visit_dashboard_detail(self):
  25. self.browser.get(f"/organizations/{self.organization.slug}/dashboard/{self.dashboard.id}/")
  26. self.wait_until_loaded()
  27. def enter_edit_state(self):
  28. self.browser.wait_until_clickable('[data-test-id="dashboard-edit"]')
  29. button = self.browser.element('[data-test-id="dashboard-edit"]')
  30. button.click()
  31. self.wait_until_loaded()
  32. def click_dashboard_add_widget_button(self):
  33. self.browser.wait_until_clickable('[data-test-id="widget-add"]')
  34. button = self.browser.element('[data-test-id="widget-add"]')
  35. button.click()
  36. self.wait_until_loaded()
  37. def click_dashboard_header_add_widget_button(self):
  38. self.browser.wait_until_clickable('[data-test-id="add-widget-library"]')
  39. button = self.browser.element('[data-test-id="add-widget-library"]')
  40. button.click()
  41. self.wait_until_loaded()
  42. def click_cancel_button(self):
  43. self.browser.wait_until_clickable('[data-test-id="dashboard-cancel"]')
  44. button = self.browser.element('[data-test-id="dashboard-cancel"]')
  45. button.click()
  46. self.wait_until_loaded()
  47. def add_widget_through_dashboard(self, widget_title):
  48. self.click_dashboard_add_widget_button()
  49. title_input = self.browser.element(WIDGET_TITLE_FIELD)
  50. title_input.send_keys(widget_title)
  51. button = self.browser.element('[data-test-id="add-widget"]')
  52. button.click()
  53. self.wait_until_loaded()
  54. def save_dashboard(self):
  55. self.browser.wait_until_clickable('[data-test-id="dashboard-commit"]')
  56. button = self.browser.element('[data-test-id="dashboard-commit"]')
  57. button.click()
  58. self.wait_until_loaded()