test_organization_developer_settings.py 4.5 KB

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