|
@@ -6,6 +6,7 @@ from sentry.models import (
|
|
|
DashboardWidget,
|
|
|
DashboardWidgetDisplayTypes,
|
|
|
DashboardWidgetQuery,
|
|
|
+ DashboardWidgetTypes,
|
|
|
)
|
|
|
from sentry.testutils import OrganizationDashboardWidgetTestCase
|
|
|
|
|
@@ -18,6 +19,7 @@ class OrganizationDashboardDetailsTestCase(OrganizationDashboardWidgetTestCase):
|
|
|
order=0,
|
|
|
title="Widget 1",
|
|
|
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
|
|
|
+ widget_type=DashboardWidgetTypes.DISCOVER,
|
|
|
interval="1d",
|
|
|
)
|
|
|
self.widget_2 = DashboardWidget.objects.create(
|
|
@@ -25,6 +27,7 @@ class OrganizationDashboardDetailsTestCase(OrganizationDashboardWidgetTestCase):
|
|
|
order=1,
|
|
|
title="Widget 2",
|
|
|
display_type=DashboardWidgetDisplayTypes.TABLE,
|
|
|
+ widget_type=DashboardWidgetTypes.DISCOVER,
|
|
|
interval="1d",
|
|
|
)
|
|
|
self.widget_1_data_1 = DashboardWidgetQuery.objects.create(
|
|
@@ -166,12 +169,14 @@ class OrganizationDashboardDetailsPutTest(OrganizationDashboardDetailsTestCase):
|
|
|
order=2,
|
|
|
title="Widget 3",
|
|
|
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
|
|
|
+ widget_type=DashboardWidgetTypes.DISCOVER,
|
|
|
)
|
|
|
self.widget_4 = DashboardWidget.objects.create(
|
|
|
dashboard=self.dashboard,
|
|
|
order=3,
|
|
|
title="Widget 4",
|
|
|
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
|
|
|
+ widget_type=DashboardWidgetTypes.DISCOVER,
|
|
|
)
|
|
|
self.widget_ids = [self.widget_1.id, self.widget_2.id, self.widget_3.id, self.widget_4.id]
|
|
|
|
|
@@ -674,6 +679,7 @@ class OrganizationDashboardDetailsPutTest(OrganizationDashboardDetailsTestCase):
|
|
|
),
|
|
|
title="Widget 200",
|
|
|
display_type=DashboardWidgetDisplayTypes.LINE_CHART,
|
|
|
+ widget_type=DashboardWidgetTypes.DISCOVER,
|
|
|
)
|
|
|
response = self.do_request(
|
|
|
"put",
|
|
@@ -694,6 +700,101 @@ class OrganizationDashboardDetailsPutTest(OrganizationDashboardDetailsTestCase):
|
|
|
assert response.data == ["You cannot update widgets that are not part of this dashboard."]
|
|
|
self.assert_no_changes()
|
|
|
|
|
|
+ def test_add_issue_widget_valid_query(self):
|
|
|
+ data = {
|
|
|
+ "title": "First dashboard",
|
|
|
+ "widgets": [
|
|
|
+ {"id": str(self.widget_1.id)},
|
|
|
+ {
|
|
|
+ "title": "Issues",
|
|
|
+ "displayType": "table",
|
|
|
+ "widgetType": "issue",
|
|
|
+ "interval": "5m",
|
|
|
+ "queries": [{"name": "", "fields": ["count()"], "conditions": "is:unresolved"}],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ response = self.do_request("put", self.url(self.dashboard.id), data=data)
|
|
|
+ assert response.status_code == 200, response.data
|
|
|
+
|
|
|
+ def test_add_issue_widget_invalid_query(self):
|
|
|
+ data = {
|
|
|
+ "title": "First dashboard",
|
|
|
+ "widgets": [
|
|
|
+ {"id": str(self.widget_1.id)},
|
|
|
+ {
|
|
|
+ "title": "Issues",
|
|
|
+ "displayType": "table",
|
|
|
+ "widgetType": "issue",
|
|
|
+ "interval": "5m",
|
|
|
+ "queries": [{"name": "", "fields": ["count()"], "conditions": "is:())"}],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ response = self.do_request("put", self.url(self.dashboard.id), data=data)
|
|
|
+ assert response.status_code == 400, response.data
|
|
|
+ assert b"Parse error" in response.content
|
|
|
+
|
|
|
+ def test_add_discover_widget_invalid_issue_query(self):
|
|
|
+ data = {
|
|
|
+ "title": "First dashboard",
|
|
|
+ "widgets": [
|
|
|
+ {"id": str(self.widget_1.id)},
|
|
|
+ {
|
|
|
+ "title": "Issues",
|
|
|
+ "displayType": "table",
|
|
|
+ "widgetType": "discover",
|
|
|
+ "interval": "5m",
|
|
|
+ "queries": [{"name": "", "fields": ["count()"], "conditions": "is:unresolved"}],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ response = self.do_request("put", self.url(self.dashboard.id), data=data)
|
|
|
+ assert response.status_code == 400, response.data
|
|
|
+ assert b"Invalid conditions" in response.content
|
|
|
+
|
|
|
+ def test_add_multiple_discover_and_issue_widget(self):
|
|
|
+ data = {
|
|
|
+ "title": "First dashboard",
|
|
|
+ "widgets": [
|
|
|
+ {"id": str(self.widget_1.id)},
|
|
|
+ {
|
|
|
+ "title": "Unresolved Issues",
|
|
|
+ "displayType": "table",
|
|
|
+ "widgetType": "issue",
|
|
|
+ "interval": "5m",
|
|
|
+ "queries": [{"name": "", "fields": ["count()"], "conditions": "is:unresolved"}],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "Resolved Issues",
|
|
|
+ "displayType": "table",
|
|
|
+ "widgetType": "issue",
|
|
|
+ "interval": "5m",
|
|
|
+ "queries": [{"name": "", "fields": ["count()"], "conditions": "is:resolved"}],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "Transactions",
|
|
|
+ "displayType": "table",
|
|
|
+ "widgetType": "discover",
|
|
|
+ "interval": "5m",
|
|
|
+ "queries": [
|
|
|
+ {"name": "", "fields": ["count()"], "conditions": "event.type:transaction"}
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "Errors",
|
|
|
+ "displayType": "table",
|
|
|
+ "widgetType": "discover",
|
|
|
+ "interval": "5m",
|
|
|
+ "queries": [
|
|
|
+ {"name": "", "fields": ["count()"], "conditions": "event.type:error"}
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ response = self.do_request("put", self.url(self.dashboard.id), data=data)
|
|
|
+ assert response.status_code == 200, response.data
|
|
|
+
|
|
|
|
|
|
class OrganizationDashboardVisitTest(OrganizationDashboardDetailsTestCase):
|
|
|
def url(self, dashboard_id):
|