test_organization_developer_settings.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. from sentry.testutils import AcceptanceTestCase
  2. class OrganizationDeveloperSettingsNewAcceptanceTest(AcceptanceTestCase):
  3. """
  4. As a developer, I can create an integration, install it, and uninstall it
  5. """
  6. def setUp(self):
  7. super().setUp()
  8. self.team = self.create_team(organization=self.organization, name="Tesla Motors")
  9. self.project = self.create_project(
  10. organization=self.organization, teams=[self.team], name="Model S"
  11. )
  12. self.login_as(self.user)
  13. self.org_developer_settings_path = f"/settings/{self.organization.slug}/developer-settings/"
  14. def load_page(self, url):
  15. self.browser.get(url)
  16. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  17. def test_create_new_public_integration(self):
  18. self.load_page(self.org_developer_settings_path)
  19. self.browser.click('[aria-label="New Public Integration"]')
  20. self.browser.element('input[name="name"]').send_keys("Tesla")
  21. self.browser.element('input[name="author"]').send_keys("Elon Musk")
  22. self.browser.element('input[name="webhookUrl"]').send_keys("https://example.com/webhook")
  23. self.browser.click('[aria-label="Save Changes"]')
  24. self.browser.wait_until(xpath="//span[contains(text(), 'Client ID')]", timeout=3)
  25. def test_create_new_internal_integration(self):
  26. self.load_page(self.org_developer_settings_path)
  27. self.browser.click('[aria-label="New Internal Integration"]')
  28. self.browser.element('input[name="name"]').send_keys("Tesla")
  29. self.browser.click('[aria-label="Save Changes"]')
  30. self.browser.wait_until(xpath="//button//span[contains(text(), 'New Token')]", timeout=3)
  31. class OrganizationDeveloperSettingsEditAcceptanceTest(AcceptanceTestCase):
  32. """
  33. As a developer, I can edit an existing integration
  34. """
  35. def setUp(self):
  36. super().setUp()
  37. self.user = self.create_user("foo@example.com")
  38. self.org = self.create_organization(name="Tesla", owner=self.user)
  39. self.team = self.create_team(organization=self.org, name="Tesla Motors")
  40. self.project = self.create_project(organization=self.org, teams=[self.team], name="Model S")
  41. self.sentry_app = self.create_sentry_app(
  42. name="Tesla App",
  43. organization=self.org,
  44. schema={"elements": [self.create_issue_link_schema()]},
  45. )
  46. self.login_as(self.user)
  47. self.org_developer_settings_path = (
  48. f"/settings/{self.org.slug}/developer-settings/{self.sentry_app.slug}"
  49. )
  50. def load_page(self, url):
  51. self.browser.get(url)
  52. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  53. def test_edit_integration_schema(self):
  54. self.load_page(self.org_developer_settings_path)
  55. textarea = self.browser.element('textarea[name="schema"]')
  56. textarea.clear()
  57. textarea.send_keys("{}")
  58. self.browser.click('[aria-label="Save Changes"]')
  59. self.browser.wait_until(".ref-success")
  60. link = self.browser.find_element_by_link_text("Tesla App")
  61. link.click()
  62. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  63. schema = self.browser.element('textarea[name="schema"]')
  64. assert schema.text == ""
  65. def test_remove_tokens_internal_app(self):
  66. internal_app = self.create_internal_integration(name="Internal App", organization=self.org)
  67. url = f"/settings/{self.org.slug}/developer-settings/{internal_app.slug}"
  68. self.load_page(url)
  69. self.browser.click('[data-test-id="token-delete"]')
  70. self.browser.wait_until(".ref-success")
  71. assert self.browser.find_element_by_xpath(
  72. "//div[contains(text(), 'No tokens created yet.')]"
  73. )
  74. def test_add_tokens_internal_app(self):
  75. internal_app = self.create_internal_integration(name="Internal App", organization=self.org)
  76. url = f"/settings/{self.org.slug}/developer-settings/{internal_app.slug}"
  77. self.load_page(url)
  78. self.browser.click('[data-test-id="token-add"]')
  79. self.browser.wait_until(".ref-success")
  80. assert len(self.browser.elements('[data-test-id="token-delete"]')) == 2