test_dashboard.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. def test_rename_team_and_navigate_back(self):
  69. self.create_sample_event()
  70. self.browser.get(self.path)
  71. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  72. self.browser.click('[data-test-id="badge-display-name"]')
  73. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  74. self.browser.click(".nav-tabs li:nth-child(4) a")
  75. self.browser.wait_until('input[name="slug"]')
  76. self.browser.element('input[name="slug"]').send_keys("-new-slug")
  77. self.browser.click('[aria-label="Save"]')
  78. self.browser.wait_until_not('[aria-label="Save"]')
  79. self.browser.wait_until('[data-test-id="toast-success"]')
  80. # Go to projects
  81. self.browser.click(f'[href="/organizations/{self.organization.slug}/projects/"]')
  82. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  83. assert self.browser.element('[data-test-id="badge-display-name"]').text == "#foo-new-slug"
  84. class EmptyDashboardTest(AcceptanceTestCase):
  85. def setUp(self):
  86. super().setUp()
  87. self.login_as(self.user)
  88. self.path = f"/organizations/{self.organization.slug}/projects/"
  89. def test_new_dashboard_empty(self):
  90. self.browser.get(self.path)
  91. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  92. self.browser.snapshot("new dashboard empty")