test_dashboard.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.cases import AcceptanceTestCase, SnubaTestCase
  14. from sentry.testutils.silo import no_silo_test
  15. from sentry.utils.samples import load_data
  16. @no_silo_test(stable=True)
  17. class DashboardTest(AcceptanceTestCase, SnubaTestCase):
  18. def setUp(self):
  19. super().setUp()
  20. release = Release.objects.create(organization_id=self.organization.id, version="1")
  21. environment = Environment.objects.create(
  22. organization_id=self.organization.id, name="production"
  23. )
  24. deploy = Deploy.objects.create(
  25. environment_id=environment.id,
  26. organization_id=self.organization.id,
  27. release=release,
  28. date_finished="2018-05-23",
  29. )
  30. ReleaseProjectEnvironment.objects.create(
  31. project_id=self.project.id,
  32. release_id=release.id,
  33. environment_id=environment.id,
  34. last_deploy_id=deploy.id,
  35. )
  36. self.login_as(self.user)
  37. self.path = f"/organizations/{self.organization.slug}/projects/"
  38. def create_sample_event(self):
  39. self.init_snuba()
  40. event_data = load_data("python")
  41. event_data["event_id"] = "d964fdbd649a4cf8bfc35d18082b6b0e"
  42. event_data["timestamp"] = 1452683305
  43. event = self.store_event(
  44. project_id=self.project.id, data=event_data, assert_no_errors=False
  45. )
  46. event.group.update(
  47. first_seen=datetime(2018, 1, 12, 3, 8, 25, tzinfo=timezone.utc),
  48. last_seen=datetime(2018, 1, 13, 3, 8, 25, tzinfo=timezone.utc),
  49. )
  50. GroupAssignee.objects.create(user_id=self.user.id, group=event.group, project=self.project)
  51. OrganizationOnboardingTask.objects.create_or_update(
  52. organization_id=self.project.organization_id,
  53. task=OnboardingTask.FIRST_EVENT,
  54. status=OnboardingTaskStatus.COMPLETE,
  55. )
  56. self.project.update(first_event=timezone.now())
  57. def test_project_with_no_first_event(self):
  58. self.project.update(first_event=None)
  59. self.browser.get(self.path)
  60. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  61. self.browser.wait_until_test_id("resources")
  62. self.browser.wait_until(".echarts-for-react path", timeout=10000)
  63. def test_one_issue(self):
  64. self.create_sample_event()
  65. self.browser.get(self.path)
  66. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  67. self.browser.wait_until(".echarts-for-react path", timeout=100000)
  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"]')