test_incidents.py 1.9 KB

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