test_dashboard.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. from __future__ import absolute_import
  2. from django.utils import timezone
  3. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  4. from sentry.models import (
  5. GroupAssignee,
  6. Release,
  7. Environment,
  8. Deploy,
  9. ReleaseProjectEnvironment,
  10. OrganizationOnboardingTask,
  11. OnboardingTask,
  12. OnboardingTaskStatus,
  13. )
  14. from sentry.utils.samples import load_data
  15. from datetime import datetime
  16. class DashboardTest(AcceptanceTestCase, SnubaTestCase):
  17. def setUp(self):
  18. super(DashboardTest, self).setUp()
  19. release = Release.objects.create(organization_id=self.organization.id, version="1")
  20. environment = Environment.objects.create(
  21. organization_id=self.organization.id, name="production"
  22. )
  23. deploy = Deploy.objects.create(
  24. environment_id=environment.id,
  25. organization_id=self.organization.id,
  26. release=release,
  27. date_finished="2018-05-23",
  28. )
  29. ReleaseProjectEnvironment.objects.create(
  30. project_id=self.project.id,
  31. release_id=release.id,
  32. environment_id=environment.id,
  33. last_deploy_id=deploy.id,
  34. )
  35. self.login_as(self.user)
  36. self.path = u"/organizations/{}/projects/".format(self.organization.slug)
  37. def create_sample_event(self):
  38. self.init_snuba()
  39. event_data = load_data("python")
  40. event_data["event_id"] = "d964fdbd649a4cf8bfc35d18082b6b0e"
  41. event_data["timestamp"] = 1452683305
  42. event = self.store_event(
  43. project_id=self.project.id, data=event_data, assert_no_errors=False
  44. )
  45. event.group.update(
  46. first_seen=datetime(2018, 1, 12, 3, 8, 25, tzinfo=timezone.utc),
  47. last_seen=datetime(2018, 1, 13, 3, 8, 25, tzinfo=timezone.utc),
  48. )
  49. GroupAssignee.objects.create(user=self.user, group=event.group, project=self.project)
  50. OrganizationOnboardingTask.objects.create_or_update(
  51. organization_id=self.project.organization_id,
  52. task=OnboardingTask.FIRST_EVENT,
  53. status=OnboardingTaskStatus.COMPLETE,
  54. )
  55. self.project.update(first_event=timezone.now())
  56. def test_project_with_no_first_event(self):
  57. self.project.update(first_event=None)
  58. self.browser.get(self.path)
  59. self.browser.wait_until_not(".loading-indicator")
  60. self.browser.wait_until_test_id("resources")
  61. self.browser.wait_until("[data-test-id] figure", timeout=10000)
  62. self.browser.snapshot("org dash no first event")
  63. def test_one_issue(self):
  64. self.create_sample_event()
  65. self.browser.get(self.path)
  66. self.browser.wait_until_not(".loading-indicator")
  67. self.browser.wait_until("[data-test-id] figure", timeout=100000)
  68. self.browser.snapshot("org dash one issue")
  69. def test_rename_team_and_navigate_back(self):
  70. self.create_sample_event()
  71. self.browser.get(self.path)
  72. self.browser.wait_until_not(".loading-indicator")
  73. self.browser.click('[data-test-id="badge-display-name"]')
  74. self.browser.wait_until_not(".loading-indicator")
  75. self.browser.click(".nav-tabs li:nth-child(3) a")
  76. self.browser.wait_until('input[name="slug"]')
  77. self.browser.element('input[name="slug"]').send_keys("-new-slug")
  78. self.browser.click('[aria-label="Save"]')
  79. self.browser.wait_until_not('[aria-label="Save"]')
  80. self.browser.wait_until('[data-test-id="toast-success"]')
  81. # Go to projects
  82. self.browser.click('[href="/organizations/{}/projects/"]'.format(self.organization.slug))
  83. self.browser.wait_until_not(".loading-indicator")
  84. assert self.browser.element('[data-test-id="badge-display-name"]').text == "#foo-new-slug"
  85. class EmptyDashboardTest(AcceptanceTestCase):
  86. def setUp(self):
  87. super(EmptyDashboardTest, self).setUp()
  88. self.login_as(self.user)
  89. self.path = u"/organizations/{}/projects/".format(self.organization.slug)
  90. def test_new_dashboard_empty(self):
  91. self.browser.get(self.path)
  92. self.browser.wait_until_not(".loading-indicator")
  93. self.browser.snapshot("new dashboard empty")