test_project_alert_settings.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from sentry.models import Rule
  2. from sentry.testutils.cases import AcceptanceTestCase
  3. from sentry.testutils.silo import no_silo_test
  4. @no_silo_test(stable=True)
  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.wait_until(".ref-plugin-enable-webhooks")
  44. self.browser.click(".ref-plugin-enable-webhooks")
  45. self.browser.wait_until(".ref-plugin-config-webhooks")
  46. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  47. # flakey Toast animation being snapshotted in CI
  48. # click it to clear it before snapshotting
  49. self.browser.click_when_visible('[data-test-id="toast-success"]')
  50. self.browser.wait_until_not('[data-test-id="toast-success"]')