test_incidents.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from __future__ import absolute_import
  2. from datetime import datetime, timedelta
  3. from django.utils import timezone
  4. import pytz
  5. from mock import patch
  6. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  7. from sentry.incidents.logic import create_incident
  8. from sentry.incidents.models import IncidentType
  9. FEATURE_NAME = 'organizations:incidents'
  10. event_time = (datetime.utcnow() - timedelta(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. self.browser.wait_until(details_url)
  38. self.browser.click(details_url)
  39. self.browser.wait_until_not('.loading-indicator')
  40. self.browser.wait_until_test_id('incident-title')
  41. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  42. self.browser.snapshot('incidents - details')
  43. @patch('django.utils.timezone.now')
  44. def test_open_create_incident_modal(self, mock_now):
  45. mock_now.return_value = datetime.utcnow().replace(tzinfo=pytz.utc)
  46. self.store_event(
  47. data={
  48. 'event_id': 'a' * 32,
  49. 'message': 'oh no',
  50. 'timestamp': event_time.isoformat()[:19],
  51. 'fingerprint': ['group-1']
  52. },
  53. project_id=self.project.id
  54. )
  55. with self.feature(FEATURE_NAME):
  56. self.browser.get(u'/organizations/{}/issues/'.format(self.organization.slug))
  57. self.browser.wait_until_not('.loading-indicator')
  58. self.browser.wait_until_test_id('group')
  59. self.browser.click('[data-test-id="group"]')
  60. self.browser.click('[data-test-id="action-link-create-new-incident"]')
  61. self.browser.wait_until_test_id('create-new-incident-form')
  62. # TODO: Figure out how to deal with mocked dates