test_project_alert_settings.py 2.4 KB

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