test_dashboard.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. from datetime import datetime
  2. from django.utils import timezone
  3. from sentry.models import (
  4. Deploy,
  5. Environment,
  6. GroupAssignee,
  7. OnboardingTask,
  8. OnboardingTaskStatus,
  9. OrganizationOnboardingTask,
  10. Release,
  11. ReleaseProjectEnvironment,
  12. )
  13. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  14. from sentry.utils.samples import load_data
  15. class DashboardTest(AcceptanceTestCase, SnubaTestCase):
  16. def setUp(self):
  17. super().setUp()
  18. release = Release.objects.create(organization_id=self.organization.id, version="1")
  19. environment = Environment.objects.create(
  20. organization_id=self.organization.id, name="production"
  21. )
  22. deploy = Deploy.objects.create(
  23. environment_id=environment.id,
  24. organization_id=self.organization.id,
  25. release=release,
  26. date_finished="2018-05-23",
  27. )
  28. ReleaseProjectEnvironment.objects.create(
  29. project_id=self.project.id,
  30. release_id=release.id,
  31. environment_id=environment.id,
  32. last_deploy_id=deploy.id,
  33. )
  34. self.login_as(self.user)
  35. self.path = f"/organizations/{self.organization.slug}/projects/"
  36. def create_sample_event(self):
  37. self.init_snuba()
  38. event_data = load_data("python")
  39. event_data["event_id"] = "d964fdbd649a4cf8bfc35d18082b6b0e"
  40. event_data["timestamp"] = 1452683305
  41. event = self.store_event(
  42. project_id=self.project.id, data=event_data, assert_no_errors=False
  43. )
  44. event.group.update(
  45. first_seen=datetime(2018, 1, 12, 3, 8, 25, tzinfo=timezone.utc),
  46. last_seen=datetime(2018, 1, 13, 3, 8, 25, tzinfo=timezone.utc),
  47. )
  48. GroupAssignee.objects.create(user=self.user, group=event.group, project=self.project)
  49. OrganizationOnboardingTask.objects.create_or_update(
  50. organization_id=self.project.organization_id,
  51. task=OnboardingTask.FIRST_EVENT,
  52. status=OnboardingTaskStatus.COMPLETE,
  53. )
  54. self.project.update(first_event=timezone.now())
  55. def test_project_with_no_first_event(self):
  56. self.project.update(first_event=None)
  57. self.browser.get(self.path)
  58. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  59. self.browser.wait_until_test_id("resources")
  60. self.browser.wait_until(".echarts-for-react path", timeout=10000)
  61. self.browser.snapshot("org dash no first event")
  62. def test_one_issue(self):
  63. self.create_sample_event()
  64. self.browser.get(self.path)
  65. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  66. self.browser.wait_until(".echarts-for-react path", timeout=100000)
  67. self.browser.snapshot("org dash one issue")
  68. class EmptyDashboardTest(AcceptanceTestCase):
  69. def setUp(self):
  70. super().setUp()
  71. self.login_as(self.user)
  72. self.path = f"/organizations/{self.organization.slug}/projects/"
  73. def test_new_dashboard_empty(self):
  74. self.browser.get(self.path)
  75. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  76. self.browser.snapshot("new dashboard empty")