test_incidents.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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(name="Alert Rule #1")
  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. features = {feature: True for feature in FEATURE_NAME}
  28. with self.feature(features):
  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.snapshot("incidents - list")
  33. details_url = f'[href="/organizations/{self.organization.slug}/alerts/rules/details/{alert_rule.id}/?alert={incident.id}'
  34. self.browser.wait_until(details_url)
  35. self.browser.click(details_url)
  36. self.browser.wait_until_not(".loading-indicator")
  37. self.browser.wait_until_test_id("incident-rule-title")
  38. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  39. self.browser.blur()
  40. self.browser.snapshot("incidents - details")