test_issue_details.py 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. from __future__ import absolute_import
  2. import json
  3. import pytz
  4. from datetime import datetime, timedelta
  5. from django.conf import settings
  6. from django.utils import timezone
  7. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  8. from sentry.utils.samples import load_data
  9. event_time = (datetime.utcnow() - timedelta(days=3)).replace(tzinfo=pytz.utc)
  10. now = datetime.utcnow().replace(tzinfo=pytz.utc)
  11. class IssueDetailsTest(AcceptanceTestCase, SnubaTestCase):
  12. def setUp(self):
  13. super(IssueDetailsTest, self).setUp()
  14. self.user = self.create_user("foo@example.com")
  15. self.org = self.create_organization(owner=self.user, name="Rowdy Tiger")
  16. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  17. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  18. self.login_as(self.user)
  19. self.dismiss_assistant()
  20. def create_sample_event(self, platform, default=None, sample_name=None, time=None):
  21. event_data = load_data(platform, default=default, sample_name=sample_name)
  22. event_data["event_id"] = "d964fdbd649a4cf8bfc35d18082b6b0e"
  23. # Only set these properties if we were given a time.
  24. # event processing will mark old time values as processing errors.
  25. if time:
  26. event_data["received"] = time.isoformat()
  27. # We need a fallback datetime for the event
  28. if time is None:
  29. time = now - timedelta(days=1)
  30. time = time.replace(hour=0, minute=0, second=0, microsecond=0)
  31. event_data["timestamp"] = time.isoformat()
  32. event = self.store_event(
  33. data=event_data, project_id=self.project.id, assert_no_errors=False
  34. )
  35. event.group.update(
  36. first_seen=datetime(2015, 8, 13, 3, 8, 25, tzinfo=timezone.utc), last_seen=time
  37. )
  38. return event
  39. def visit_issue(self, groupid):
  40. self.dismiss_assistant()
  41. self.browser.get(u"/organizations/{}/issues/{}/".format(self.org.slug, groupid))
  42. self.wait_until_loaded()
  43. def test_python_event(self):
  44. event = self.create_sample_event(platform="python", time=event_time)
  45. self.visit_issue(event.group.id)
  46. # Wait for tag bars to load
  47. self.browser.wait_until('[data-test-id="loaded-device-name"]')
  48. self.browser.snapshot("issue details python")
  49. def test_python_rawbody_event(self):
  50. event = self.create_sample_event(platform="python-rawbody")
  51. self.visit_issue(event.group.id)
  52. self.browser.move_to(".request pre span")
  53. self.browser.snapshot("issue details python raw body")
  54. def test_python_formdata_event(self):
  55. event = self.create_sample_event(platform="python-formdata")
  56. self.visit_issue(event.group.id)
  57. self.browser.snapshot("issue details python formdata")
  58. def test_cocoa_event(self):
  59. event = self.create_sample_event(platform="cocoa")
  60. self.visit_issue(event.group.id)
  61. self.browser.snapshot("issue details cocoa")
  62. def test_unity_event(self):
  63. event = self.create_sample_event(default="unity", platform="csharp")
  64. self.visit_issue(event.group.id)
  65. self.browser.snapshot("issue details unity")
  66. def test_aspnetcore_event(self):
  67. event = self.create_sample_event(default="aspnetcore", platform="csharp")
  68. self.visit_issue(event.group.id)
  69. self.browser.snapshot("issue details aspnetcore")
  70. def test_javascript_specific_event(self):
  71. event = self.create_sample_event(platform="javascript")
  72. self.dismiss_assistant()
  73. self.visit_issue(event.group.id)
  74. self.browser.snapshot("issue details javascript - event details")
  75. self.browser.find_element_by_xpath("//a//code[contains(text(), 'curl')]").click()
  76. self.browser.snapshot("issue details javascript - event details - curl command")
  77. def test_rust_event(self):
  78. # TODO: This should become its own "rust" platform type
  79. event = self.create_sample_event(platform="native", sample_name="Rust")
  80. self.visit_issue(event.group.id)
  81. self.wait_until_loaded()
  82. self.browser.snapshot("issue details rust")
  83. def test_cordova_event(self):
  84. event = self.create_sample_event(platform="cordova")
  85. self.visit_issue(event.group.id)
  86. self.browser.snapshot("issue details cordova")
  87. def test_stripped_event(self):
  88. event = self.create_sample_event(platform="pii")
  89. self.visit_issue(event.group.id)
  90. self.browser.snapshot("issue details pii stripped")
  91. def test_empty_exception(self):
  92. event = self.create_sample_event(platform="empty-exception")
  93. self.visit_issue(event.group.id)
  94. self.browser.snapshot("issue details empty exception")
  95. def test_empty_stacktrace(self):
  96. event = self.create_sample_event(platform="empty-stacktrace")
  97. self.visit_issue(event.group.id)
  98. self.browser.snapshot("issue details empty stacktrace")
  99. def test_invalid_interfaces(self):
  100. event = self.create_sample_event(platform="invalid-interfaces")
  101. self.visit_issue(event.group.id)
  102. self.browser.click(".errors-toggle")
  103. self.browser.wait_until(".entries > .errors ul")
  104. self.browser.snapshot("issue details invalid interfaces")
  105. def test_activity_page(self):
  106. event = self.create_sample_event(platform="python")
  107. self.browser.get(
  108. u"/organizations/{}/issues/{}/activity/".format(self.org.slug, event.group.id)
  109. )
  110. self.browser.wait_until_test_id("activity-item")
  111. self.browser.snapshot("issue activity python")
  112. def wait_until_loaded(self):
  113. self.browser.wait_until_not(".loading-indicator")
  114. self.browser.wait_until(".entries")
  115. self.browser.wait_until_test_id("linked-issues")
  116. self.browser.wait_until_test_id("loaded-device-name")
  117. def dismiss_assistant(self):
  118. # Forward session cookie to django client.
  119. self.client.cookies[settings.SESSION_COOKIE_NAME] = self.session.session_key
  120. res = self.client.put(
  121. "/api/0/assistant/",
  122. content_type="application/json",
  123. data=json.dumps({"guide_id": 1, "status": "viewed", "useful": True}),
  124. )
  125. assert res.status_code == 201
  126. res = self.client.put(
  127. "/api/0/assistant/",
  128. content_type="application/json",
  129. data=json.dumps({"guide_id": 3, "status": "viewed", "useful": True}),
  130. )
  131. assert res.status_code == 201