test_incidents.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from django.utils import timezone as django_timezone
  2. from sentry.incidents.logic import update_incident_status
  3. from sentry.incidents.models import IncidentStatus, IncidentStatusMethod
  4. from sentry.testutils.cases import AcceptanceTestCase, SnubaTestCase
  5. from sentry.testutils.helpers.datetime import before_now
  6. from sentry.testutils.silo import no_silo_test
  7. FEATURE_NAME = ["organizations:incidents", "organizations:performance-view"]
  8. event_time = before_now(days=3)
  9. @no_silo_test
  10. class OrganizationIncidentsListTest(AcceptanceTestCase, SnubaTestCase):
  11. def setUp(self):
  12. super().setUp()
  13. self.login_as(self.user)
  14. self.path = f"/organizations/{self.organization.slug}/alerts/"
  15. def test_empty_incidents(self):
  16. with self.feature(FEATURE_NAME):
  17. self.browser.get(self.path)
  18. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  19. def test_incidents_list(self):
  20. alert_rule = self.create_alert_rule(name="Alert Rule #1")
  21. incident = self.create_incident(
  22. self.organization,
  23. title="Incident #1",
  24. date_started=django_timezone.now(),
  25. date_detected=django_timezone.now(),
  26. projects=[self.project],
  27. alert_rule=alert_rule,
  28. )
  29. update_incident_status(
  30. incident, IncidentStatus.CRITICAL, status_method=IncidentStatusMethod.RULE_TRIGGERED
  31. )
  32. features = {feature: True for feature in FEATURE_NAME}
  33. with self.feature(features):
  34. self.browser.get(self.path)
  35. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  36. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  37. details_url = f'[href="/organizations/{self.organization.slug}/alerts/rules/details/{alert_rule.id}/?alert={incident.id}'
  38. self.browser.wait_until(details_url)
  39. self.browser.click(details_url)
  40. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  41. self.browser.wait_until_test_id("incident-rule-title")
  42. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')