test_issue_details.py 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. from datetime import datetime, timedelta, timezone
  2. from unittest.mock import patch
  3. from fixtures.page_objects.issue_details import IssueDetailsPage
  4. from sentry.testutils.cases import AcceptanceTestCase, SnubaTestCase
  5. from sentry.testutils.silo import no_silo_test
  6. from sentry.utils.samples import load_data
  7. now = datetime.utcnow().replace(tzinfo=timezone.utc)
  8. @no_silo_test(stable=True)
  9. class IssueDetailsTest(AcceptanceTestCase, SnubaTestCase):
  10. def setUp(self):
  11. super().setUp()
  12. patcher = patch("django.utils.timezone.now", return_value=now)
  13. patcher.start()
  14. self.addCleanup(patcher.stop)
  15. self.user = self.create_user("foo@example.com")
  16. self.org = self.create_organization(owner=self.user, name="Rowdy Tiger")
  17. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  18. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  19. self.login_as(self.user)
  20. self.page = IssueDetailsPage(self.browser, self.client)
  21. self.dismiss_assistant()
  22. def create_sample_event(self, platform, default=None, sample_name=None, time=None, tags=None):
  23. event_data = load_data(platform, default=default, sample_name=sample_name)
  24. event_data["event_id"] = "d964fdbd649a4cf8bfc35d18082b6b0e"
  25. # Only set these properties if we were given a time.
  26. # event processing will mark old time values as processing errors.
  27. if time:
  28. event_data["received"] = time.isoformat()
  29. if tags:
  30. event_data["tags"] = tags
  31. # We need a fallback datetime for the event
  32. if time is None:
  33. time = now - timedelta(days=2)
  34. time = time.replace(hour=0, minute=0, second=0, microsecond=0)
  35. event_data["timestamp"] = time.isoformat()
  36. event = self.store_event(
  37. data=event_data, project_id=self.project.id, assert_no_errors=False
  38. )
  39. event.group.update(
  40. first_seen=datetime(2015, 8, 13, 3, 8, 25, tzinfo=timezone.utc), last_seen=time
  41. )
  42. return event
  43. def test_python_event(self):
  44. tags = [
  45. ["server_name", "web02.example.org"],
  46. ["environment", "staging"],
  47. ]
  48. self.create_sample_event(platform="python", tags=tags)
  49. event = self.create_sample_event(platform="python")
  50. self.page.visit_issue(self.org.slug, event.group.id)
  51. # Wait for tag bars to load
  52. self.browser.wait_until_test_id("loaded-device-name")
  53. def test_python_rawbody_event(self):
  54. event = self.create_sample_event(platform="python-rawbody")
  55. self.page.visit_issue(self.org.slug, event.group.id)
  56. self.browser.move_to('[data-test-id="rich-http-content-body-section-pre"]')
  57. def test_python_formdata_event(self):
  58. event = self.create_sample_event(platform="python-formdata")
  59. self.page.visit_issue(self.org.slug, event.group.id)
  60. def test_pii_tooltips(self):
  61. event = self.create_sample_event(platform="pii-tooltips")
  62. self.page.visit_issue(self.org.slug, event.group.id)
  63. def test_cocoa_event(self):
  64. event = self.create_sample_event(platform="cocoa")
  65. self.page.visit_issue(self.org.slug, event.group.id)
  66. def test_cocoa_event_frame_line_hover(self):
  67. event = self.create_sample_event(platform="cocoa")
  68. self.page.visit_issue(self.org.slug, event.group.id)
  69. self.browser.wait_until_not(".loading")
  70. self.browser.move_to(".traceback li:nth-child(2)")
  71. def test_unity_event(self):
  72. event = self.create_sample_event(default="unity", platform="csharp")
  73. self.page.visit_issue(self.org.slug, event.group.id)
  74. def test_android_event(self):
  75. event = self.create_sample_event(platform="android")
  76. self.page.visit_issue(self.org.slug, event.group.id)
  77. def test_android_ndk_event(self):
  78. event = self.create_sample_event(default="android-ndk", platform="android-ndk")
  79. self.page.visit_issue(self.org.slug, event.group.id)
  80. def test_aspnetcore_event(self):
  81. event = self.create_sample_event(default="aspnetcore", platform="csharp")
  82. self.page.visit_issue(self.org.slug, event.group.id)
  83. def test_javascript_specific_event(self):
  84. event = self.create_sample_event(platform="javascript")
  85. self.page.visit_issue(self.org.slug, event.group.id)
  86. self.browser.click('label[data-test-id="curl"]')
  87. def test_rust_event(self):
  88. # TODO: This should become its own "rust" platform type
  89. event = self.create_sample_event(platform="native", sample_name="Rust")
  90. self.page.visit_issue(self.org.slug, event.group.id)
  91. def test_cordova_event(self):
  92. event = self.create_sample_event(platform="cordova")
  93. self.page.visit_issue(self.org.slug, event.group.id)
  94. def test_stripped_event(self):
  95. event = self.create_sample_event(platform="pii")
  96. self.page.visit_issue(self.org.slug, event.group.id)
  97. def test_empty_exception(self):
  98. event = self.create_sample_event(platform="empty-exception")
  99. self.page.visit_issue(self.org.slug, event.group.id)
  100. def test_empty_stacktrace(self):
  101. event = self.create_sample_event(platform="empty-stacktrace")
  102. self.page.visit_issue(self.org.slug, event.group.id)
  103. def test_invalid_interfaces(self):
  104. event = self.create_sample_event(platform="invalid-interfaces")
  105. self.page.visit_issue(self.org.slug, event.group.id)
  106. self.browser.click('[data-test-id="event-error-alert"]')
  107. self.browser.wait_until_test_id("event-error-details")
  108. def test_activity_page(self):
  109. event = self.create_sample_event(platform="python")
  110. self.page.visit_issue(self.org.slug, event.group.id)
  111. self.page.go_to_subtab("activity")
  112. self.browser.wait_until_test_id("activity-item")
  113. def test_resolved(self):
  114. event = self.create_sample_event(platform="python")
  115. self.page.visit_issue(self.org.slug, event.group.id)
  116. self.page.resolve_issue()
  117. def test_ignored(self):
  118. event = self.create_sample_event(platform="python")
  119. self.page.visit_issue(self.org.slug, event.group.id)
  120. self.page.ignore_issue()
  121. def test_exception_and_no_threads_event(self):
  122. event = self.create_sample_event(platform="exceptions-and-no-threads")
  123. self.page.visit_issue(self.org.slug, event.group.id)
  124. def test_exception_with_stack_trace_and_crashed_thread_without_stack_trace_event(self):
  125. event = self.create_sample_event(
  126. platform="exception-with-stack-trace-and-crashed-thread-without-stack-trace"
  127. )
  128. self.page.visit_issue(self.org.slug, event.group.id)
  129. def test_exception_without_stack_trace_and_crashed_thread_with_stack_trace_event(self):
  130. event = self.create_sample_event(
  131. platform="exception-without-stack-trace-and-crashed-thread-with-stack-trace"
  132. )
  133. self.page.visit_issue(self.org.slug, event.group.id)
  134. def test_exception_with_stack_trace_and_crashed_thread_with_stack_trace_event(self):
  135. event = self.create_sample_event(
  136. platform="exception-with-stack-trace-and-crashed-thread-with-stack-trace"
  137. )
  138. self.page.visit_issue(self.org.slug, event.group.id)
  139. def test_python_invalid_json_error(self):
  140. event = self.create_sample_event(default="python-invalid-json-error", platform="native")
  141. self.page.visit_issue(self.org.slug, event.group.id)
  142. def test_exception_with_address_instruction(self):
  143. event = self.create_sample_event(
  144. default="exception-with-address-instruction", platform="cocoa"
  145. )
  146. self.page.visit_issue(self.org.slug, event.group.id)