test_organization_dashboards.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. from sentry.models import Dashboard, DashboardWidget, DashboardWidgetDisplayTypes
  2. from sentry.testutils import AcceptanceTestCase
  3. from sentry.testutils.helpers.datetime import before_now, iso_format
  4. FEATURE_NAMES = [
  5. "organizations:discover-basic",
  6. "organizations:discover-query",
  7. "organizations:dashboards-basic",
  8. ]
  9. EDIT_FEATURE = ["organizations:dashboards-edit"]
  10. class OrganizationDashboardsAcceptanceTest(AcceptanceTestCase):
  11. def setUp(self):
  12. super().setUp()
  13. min_ago = iso_format(before_now(minutes=1))
  14. self.default_path = f"/organizations/{self.organization.slug}/dashboard/default-overview/"
  15. self.store_event(
  16. data={"event_id": "a" * 32, "message": "oh no", "timestamp": min_ago},
  17. project_id=self.project.id,
  18. )
  19. self.login_as(self.user)
  20. def wait_until_loaded(self):
  21. self.browser.wait_until_not(".loading-indicator")
  22. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  23. def test_view_dashboard(self):
  24. with self.feature(FEATURE_NAMES):
  25. self.browser.get(self.default_path)
  26. self.wait_until_loaded()
  27. self.browser.snapshot("dashboards - default overview")
  28. def test_view_dashboard_with_manager(self):
  29. with self.feature(FEATURE_NAMES + EDIT_FEATURE):
  30. self.browser.get(self.default_path)
  31. self.wait_until_loaded()
  32. self.browser.snapshot("dashboards - default overview manager")
  33. def test_edit_dashboard(self):
  34. with self.feature(FEATURE_NAMES + EDIT_FEATURE):
  35. self.browser.get(self.default_path)
  36. self.wait_until_loaded()
  37. button = self.browser.element('[data-test-id="dashboard-edit"]')
  38. button.click()
  39. self.browser.snapshot("dashboards - edit state")
  40. def test_add_widget(self):
  41. with self.feature(FEATURE_NAMES + EDIT_FEATURE):
  42. self.browser.get(self.default_path)
  43. self.wait_until_loaded()
  44. # Go to edit mode.
  45. button = self.browser.element('[data-test-id="dashboard-edit"]')
  46. button.click()
  47. # Add a widget
  48. button = self.browser.element('[data-test-id="widget-add"]')
  49. button.click()
  50. self.browser.snapshot("dashboards - add widget")
  51. def test_edit_widget(self):
  52. with self.feature(FEATURE_NAMES + EDIT_FEATURE):
  53. self.browser.get(self.default_path)
  54. self.wait_until_loaded()
  55. # Go to edit mode.
  56. button = self.browser.element('[data-test-id="dashboard-edit"]')
  57. button.click()
  58. # Edit the first widget.
  59. button = self.browser.element('[data-test-id="widget-edit"]')
  60. button.click()
  61. self.browser.snapshot("dashboards - edit widget")
  62. class OrganizationDashboardsManageAcceptanceTest(AcceptanceTestCase):
  63. def setUp(self):
  64. super().setUp()
  65. self.team = self.create_team(organization=self.organization, name="Mariachi Band")
  66. self.project = self.create_project(
  67. organization=self.organization, teams=[self.team], name="Bengal"
  68. )
  69. self.dashboard = Dashboard.objects.create(
  70. title="Dashboard 1", created_by=self.user, organization=self.organization
  71. )
  72. self.widget_1 = DashboardWidget.objects.create(
  73. dashboard=self.dashboard,
  74. order=0,
  75. title="Widget 1",
  76. display_type=DashboardWidgetDisplayTypes.LINE_CHART,
  77. interval="1d",
  78. )
  79. self.widget_2 = DashboardWidget.objects.create(
  80. dashboard=self.dashboard,
  81. order=1,
  82. title="Widget 2",
  83. display_type=DashboardWidgetDisplayTypes.TABLE,
  84. interval="1d",
  85. )
  86. self.login_as(self.user)
  87. self.default_path = f"/organizations/{self.organization.slug}/dashboards/"
  88. def wait_until_loaded(self):
  89. self.browser.wait_until_not(".loading-indicator")
  90. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  91. def test_dashboard_manager(self):
  92. with self.feature(FEATURE_NAMES + EDIT_FEATURE):
  93. self.browser.get(self.default_path)
  94. self.wait_until_loaded()
  95. self.browser.snapshot("dashboards - manage overview")