test_project_alert_settings.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. from sentry.models import Rule
  2. from sentry.testutils import AcceptanceTestCase
  3. from sentry.testutils.silo import region_silo_test
  4. @region_silo_test
  5. class ProjectAlertSettingsTest(AcceptanceTestCase):
  6. def setUp(self):
  7. super().setUp()
  8. self.user = self.create_user("foo@example.com")
  9. self.org = self.create_organization(name="Rowdy Tiger", owner=None)
  10. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  11. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  12. self.create_member(user=self.user, organization=self.org, role="owner", teams=[self.team])
  13. action_data = [
  14. {
  15. "id": "sentry.rules.actions.notify_event.NotifyEventAction",
  16. "name": "Send a notification (for all legacy integrations)",
  17. },
  18. {
  19. "id": "sentry.rules.actions.notify_event_service.NotifyEventServiceAction",
  20. "service": "mail",
  21. "name": "Send a notification via mail",
  22. },
  23. ]
  24. condition_data = [
  25. {
  26. "id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition",
  27. "name": "A new issue is created",
  28. },
  29. {
  30. "id": "sentry.rules.conditions.every_event.EveryEventCondition",
  31. "name": "The event occurs",
  32. },
  33. ]
  34. Rule.objects.filter(project=self.project).delete()
  35. Rule.objects.create(
  36. project=self.project, data={"conditions": condition_data, "actions": action_data}
  37. )
  38. self.login_as(self.user)
  39. self.path1 = f"/settings/{self.org.slug}/projects/{self.project.slug}/alerts/"
  40. def test_settings_load(self):
  41. self.browser.get(self.path1)
  42. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  43. self.browser.snapshot("project alert settings")
  44. self.browser.wait_until(".ref-plugin-enable-webhooks")
  45. self.browser.click(".ref-plugin-enable-webhooks")
  46. self.browser.wait_until(".ref-plugin-config-webhooks")
  47. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  48. # flakey Toast animation being snapshotted in CI
  49. # click it to clear it before snapshotting
  50. self.browser.click_when_visible('[data-test-id="toast-success"]')
  51. self.browser.wait_until_not('[data-test-id="toast-success"]')
  52. self.browser.snapshot("project alert settings webhooks enabled")