test_organization_developer_settings.py 4.8 KB

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