123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- from sentry.models import Dashboard, DashboardWidget, DashboardWidgetDisplayTypes
- from sentry.testutils import AcceptanceTestCase
- from sentry.testutils.helpers.datetime import before_now, iso_format
- FEATURE_NAMES = [
- "organizations:discover-basic",
- "organizations:discover-query",
- "organizations:dashboards-basic",
- ]
- EDIT_FEATURE = ["organizations:dashboards-edit"]
- class OrganizationDashboardsAcceptanceTest(AcceptanceTestCase):
- def setUp(self):
- super().setUp()
- min_ago = iso_format(before_now(minutes=1))
- self.default_path = f"/organizations/{self.organization.slug}/dashboard/default-overview/"
- self.store_event(
- data={"event_id": "a" * 32, "message": "oh no", "timestamp": min_ago},
- project_id=self.project.id,
- )
- self.login_as(self.user)
- def wait_until_loaded(self):
- self.browser.wait_until_not(".loading-indicator")
- self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
- def test_view_dashboard(self):
- with self.feature(FEATURE_NAMES):
- self.browser.get(self.default_path)
- self.wait_until_loaded()
- self.browser.snapshot("dashboards - default overview")
- def test_view_dashboard_with_manager(self):
- with self.feature(FEATURE_NAMES + EDIT_FEATURE):
- self.browser.get(self.default_path)
- self.wait_until_loaded()
- self.browser.snapshot("dashboards - default overview manager")
- def test_edit_dashboard(self):
- with self.feature(FEATURE_NAMES + EDIT_FEATURE):
- self.browser.get(self.default_path)
- self.wait_until_loaded()
- button = self.browser.element('[data-test-id="dashboard-edit"]')
- button.click()
- self.browser.snapshot("dashboards - edit state")
- def test_add_widget(self):
- with self.feature(FEATURE_NAMES + EDIT_FEATURE):
- self.browser.get(self.default_path)
- self.wait_until_loaded()
- # Go to edit mode.
- button = self.browser.element('[data-test-id="dashboard-edit"]')
- button.click()
- # Add a widget
- button = self.browser.element('[data-test-id="widget-add"]')
- button.click()
- self.browser.snapshot("dashboards - add widget")
- def test_edit_widget(self):
- with self.feature(FEATURE_NAMES + EDIT_FEATURE):
- self.browser.get(self.default_path)
- self.wait_until_loaded()
- # Go to edit mode.
- button = self.browser.element('[data-test-id="dashboard-edit"]')
- button.click()
- # Edit the first widget.
- button = self.browser.element('[data-test-id="widget-edit"]')
- button.click()
- self.browser.snapshot("dashboards - edit widget")
- class OrganizationDashboardsManageAcceptanceTest(AcceptanceTestCase):
- def setUp(self):
- super().setUp()
- self.team = self.create_team(organization=self.organization, name="Mariachi Band")
- self.project = self.create_project(
- organization=self.organization, teams=[self.team], name="Bengal"
- )
- self.dashboard = Dashboard.objects.create(
- title="Dashboard 1", created_by=self.user, organization=self.organization
- )
- self.widget_1 = DashboardWidget.objects.create(
- dashboard=self.dashboard,
- order=0,
- title="Widget 1",
- display_type=DashboardWidgetDisplayTypes.LINE_CHART,
- interval="1d",
- )
- self.widget_2 = DashboardWidget.objects.create(
- dashboard=self.dashboard,
- order=1,
- title="Widget 2",
- display_type=DashboardWidgetDisplayTypes.TABLE,
- interval="1d",
- )
- self.login_as(self.user)
- self.default_path = f"/organizations/{self.organization.slug}/dashboards/"
- def wait_until_loaded(self):
- self.browser.wait_until_not(".loading-indicator")
- self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
- def test_dashboard_manager(self):
- with self.feature(FEATURE_NAMES + EDIT_FEATURE):
- self.browser.get(self.default_path)
- self.wait_until_loaded()
- self.browser.snapshot("dashboards - manage overview")
|