test_project_servicehooks.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from sentry.models import ServiceHook
  2. from sentry.testutils import AcceptanceTestCase
  3. class ProjectServiceHooksTest(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. self.login_as(self.user)
  12. self.list_hooks_path = f"/settings/{self.org.slug}/projects/{self.project.slug}/hooks/"
  13. self.new_hook_path = f"/settings/{self.org.slug}/projects/{self.project.slug}/hooks/new/"
  14. def test_simple(self):
  15. with self.feature("projects:servicehooks"):
  16. self.browser.get(self.list_hooks_path)
  17. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  18. self.browser.snapshot("project settings - service hooks - empty list")
  19. # click "New"
  20. self.browser.click('[data-test-id="new-service-hook"]')
  21. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  22. assert self.browser.current_url == f"{self.browser.live_server_url}{self.new_hook_path}"
  23. self.browser.snapshot("project settings - service hooks - create")
  24. self.browser.element('input[name="url"]').send_keys("https://example.com/hook")
  25. # click "Save Changes"
  26. self.browser.click('form [data-test-id="form-submit"]')
  27. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  28. assert (
  29. self.browser.current_url == f"{self.browser.live_server_url}{self.list_hooks_path}"
  30. )
  31. self.browser.snapshot("project settings - service hooks - list with entries")
  32. hook = ServiceHook.objects.get(project_id=self.project.id)
  33. assert hook.url == "https://example.com/hook"
  34. assert not hook.events
  35. # hopefully click the first service hook
  36. self.browser.click('[data-test-id="project-service-hook"]')
  37. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  38. assert self.browser.current_url == "{}{}".format(
  39. self.browser.live_server_url,
  40. f"/settings/{self.org.slug}/projects/{self.project.slug}/hooks/{hook.guid}/",
  41. )
  42. self.browser.snapshot("project settings - service hooks - details")