test_incidents.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from __future__ import absolute_import
  2. from django.utils import timezone
  3. import pytz
  4. from mock import patch
  5. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  6. from sentry.testutils.helpers.datetime import iso_format, before_now
  7. from sentry.incidents.logic import create_incident
  8. from sentry.incidents.models import IncidentType
  9. FEATURE_NAME = "organizations:incidents"
  10. event_time = before_now(days=3).replace(tzinfo=pytz.utc)
  11. class OrganizationIncidentsListTest(AcceptanceTestCase, SnubaTestCase):
  12. def setUp(self):
  13. super(OrganizationIncidentsListTest, self).setUp()
  14. self.login_as(self.user)
  15. self.path = u"/organizations/{}/incidents/".format(self.organization.slug)
  16. def test_empty_incidents(self):
  17. with self.feature(FEATURE_NAME):
  18. self.browser.get(self.path)
  19. self.browser.wait_until_not(".loading-indicator")
  20. self.browser.snapshot("incidents - empty state")
  21. def test_incidents_list(self):
  22. incident = create_incident(
  23. self.organization,
  24. type=IncidentType.CREATED,
  25. title="Incident #1",
  26. query="",
  27. date_started=timezone.now(),
  28. projects=[self.project],
  29. groups=[self.group],
  30. )
  31. with self.feature(FEATURE_NAME):
  32. self.browser.get(self.path)
  33. self.browser.wait_until_not(".loading-indicator")
  34. self.browser.snapshot("incidents - list")
  35. details_url = u'[href="/organizations/{}/incidents/{}/'.format(
  36. self.organization.slug, incident.identifier
  37. )
  38. self.browser.wait_until(details_url)
  39. self.browser.click(details_url)
  40. self.browser.wait_until_not(".loading-indicator")
  41. self.browser.wait_until_test_id("incident-title")
  42. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  43. self.browser.snapshot("incidents - details")
  44. @patch("django.utils.timezone.now")
  45. def test_open_create_incident_modal(self, mock_now):
  46. mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
  47. self.store_event(
  48. data={
  49. "event_id": "a" * 32,
  50. "message": "oh no",
  51. "timestamp": iso_format(event_time),
  52. "fingerprint": ["group-1"],
  53. },
  54. project_id=self.project.id,
  55. )
  56. with self.feature(FEATURE_NAME):
  57. self.browser.get(u"/organizations/{}/issues/".format(self.organization.slug))
  58. self.browser.wait_until_not(".loading-indicator")
  59. self.browser.wait_until_test_id("group")
  60. self.browser.click('[data-test-id="group"]')
  61. self.browser.click('[data-test-id="action-link-create-new-incident"]')
  62. self.browser.wait_until_test_id("create-new-incident-form")
  63. # TODO: Figure out how to deal with mocked dates