test_incidents.py 2.2 KB

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