test_incidents.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from __future__ import absolute_import
  2. from django.utils import timezone
  3. import pytz
  4. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  5. from sentry.testutils.helpers.datetime import before_now
  6. FEATURE_NAME = ["organizations:incidents", "organizations:performance-view"]
  7. event_time = before_now(days=3).replace(tzinfo=pytz.utc)
  8. class OrganizationIncidentsListTest(AcceptanceTestCase, SnubaTestCase):
  9. def setUp(self):
  10. super(OrganizationIncidentsListTest, self).setUp()
  11. self.login_as(self.user)
  12. self.path = u"/organizations/{}/alerts/".format(self.organization.slug)
  13. def test_empty_incidents(self):
  14. with self.feature(FEATURE_NAME):
  15. self.browser.get(self.path)
  16. self.browser.wait_until_not(".loading-indicator")
  17. self.browser.snapshot("incidents - empty state")
  18. def test_incidents_list(self):
  19. alert_rule = self.create_alert_rule()
  20. incident = self.create_incident(
  21. self.organization,
  22. title="Incident #1",
  23. date_started=timezone.now(),
  24. date_detected=timezone.now(),
  25. projects=[self.project],
  26. alert_rule=alert_rule,
  27. )
  28. with self.feature(FEATURE_NAME):
  29. self.browser.get(self.path)
  30. self.browser.wait_until_not(".loading-indicator")
  31. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  32. self.browser.wait_until_test_id("incident-sparkline")
  33. self.browser.snapshot("incidents - list")
  34. details_url = u'[href="/organizations/{}/alerts/{}/'.format(
  35. self.organization.slug, incident.identifier
  36. )
  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.blur()
  43. self.browser.snapshot("incidents - details")