test_organization_integration_configuration_tabs.py 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. from selenium.webdriver.common.by import By
  2. from sentry.models import Integration
  3. from sentry.testutils import AcceptanceTestCase
  4. from sentry.testutils.silo import region_silo_test
  5. @region_silo_test
  6. class OrganizationIntegrationConfigurationTabs(AcceptanceTestCase):
  7. def setUp(self):
  8. super().setUp()
  9. self.login_as(self.user)
  10. self.provider = "github"
  11. self.integration = Integration.objects.create(
  12. provider=self.provider,
  13. external_id="some_github",
  14. name="Github",
  15. metadata={
  16. "access_token": "some_access_token",
  17. "expires_at": "2021-04-16T01:08:42",
  18. "icon": "https://avatars.githubusercontent.com/u/10491134?v=4",
  19. "domain_name": "github.com/getsentry",
  20. "account_type": "User",
  21. },
  22. )
  23. self.integration.add_organization(self.organization, self.user)
  24. self.create_repo(
  25. name="getsentry/sentry",
  26. provider="integrations:github",
  27. integration_id=self.integration.id,
  28. project=self.project,
  29. url="https://github.com/getsentry/sentry",
  30. )
  31. def load_page(self, slug, configuration_tab=False):
  32. url = f"/settings/{self.organization.slug}/integrations/{slug}/"
  33. if configuration_tab:
  34. url += "?tab=configurations"
  35. self.browser.get(url)
  36. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  37. def test_external_user_mappings(self):
  38. # create `auth_user` records to differentiate `user_id` and `organization_member_id`
  39. self.create_sentry_app()
  40. self.user2 = self.create_user("user2@example.com")
  41. self.user3 = self.create_user("user3@example.com")
  42. self.team = self.create_team(
  43. organization=self.organization, slug="tiger-team", members=[self.user]
  44. )
  45. self.team2 = self.create_team(
  46. organization=self.organization, slug="tiger-team2", members=[self.user2]
  47. )
  48. self.team3 = self.create_team(
  49. organization=self.organization, slug="tiger-team3", members=[self.user3]
  50. )
  51. self.project = self.create_project(
  52. organization=self.organization, teams=[self.team, self.team2, self.team3], slug="bengal"
  53. )
  54. with self.feature(
  55. {
  56. "organizations:integrations-codeowners": True,
  57. "organizations:integrations-stacktrace-link": True,
  58. }
  59. ):
  60. self.browser.get(
  61. f"/settings/{self.organization.slug}/integrations/{self.provider}/{self.integration.id}/"
  62. )
  63. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  64. self.browser.click(".nav-tabs li:nth-child(3) a")
  65. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  66. # Empty state
  67. self.browser.snapshot("integrations - empty external user mappings")
  68. # Create mapping
  69. self.browser.click('[data-test-id="add-mapping-button"]')
  70. self.browser.wait_until("[role='dialog']")
  71. # Add Mapping Modal
  72. externalName = self.browser.find_element(by=By.NAME, value="externalName")
  73. externalName.send_keys("@user2")
  74. self.browser.click("#userId:first-child div")
  75. self.browser.click('[id="react-select-2-option-1"]')
  76. self.browser.snapshot("integrations - save new external user mapping")
  77. # List View
  78. self.browser.click('[aria-label="Save Changes"]')
  79. self.browser.wait_until_not('[aria-label="Save Changes"]')
  80. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  81. self.browser.snapshot("integrations - one external user mapping")
  82. def test_external_team_mappings(self):
  83. with self.feature(
  84. {
  85. "organizations:integrations-codeowners": True,
  86. "organizations:integrations-stacktrace-link": True,
  87. }
  88. ):
  89. self.browser.get(
  90. f"/settings/{self.organization.slug}/integrations/{self.provider}/{self.integration.id}/"
  91. )
  92. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  93. self.browser.click(".nav-tabs li:nth-child(4) a")
  94. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  95. # Empty state
  96. self.browser.snapshot("integrations - empty external team mappings")
  97. # Create mapping
  98. self.browser.click('[data-test-id="add-mapping-button"]')
  99. self.browser.wait_until("[role='dialog']")
  100. # Add Mapping Modal
  101. externalName = self.browser.find_element(by=By.NAME, value="externalName")
  102. externalName.send_keys("@getsentry/ecosystem")
  103. self.browser.click("#teamId:first-child div")
  104. self.browser.click('[id="react-select-2-option-0"]')
  105. self.browser.snapshot("integrations - save new external team mapping")
  106. # List View
  107. self.browser.click('[aria-label="Save Changes"]')
  108. self.browser.wait_until_not('[aria-label="Save Changes"]')
  109. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  110. self.browser.snapshot("integrations - one external team mapping")
  111. def test_settings_tab(self):
  112. provider = "custom_scm"
  113. integration = Integration.objects.create(
  114. provider=provider,
  115. external_id="123456789",
  116. name="Some Org",
  117. metadata={
  118. "domain_name": "https://github.com/some-org/",
  119. },
  120. )
  121. integration.add_organization(self.organization, self.user)
  122. with self.feature(
  123. {
  124. "organizations:integrations-codeowners": True,
  125. "organizations:integrations-stacktrace-link": True,
  126. "organizations:integrations-custom-scm": True,
  127. }
  128. ):
  129. self.browser.get(
  130. f"/settings/{self.organization.slug}/integrations/{provider}/{integration.id}/"
  131. )
  132. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  133. self.browser.click(".nav-tabs li:nth-child(1) a")
  134. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  135. name = self.browser.find_element(by=By.NAME, value="name")
  136. name.clear()
  137. name.send_keys("New Name")
  138. self.browser.click('[aria-label="Save Settings"]')
  139. self.browser.wait_until('[data-test-id="toast-success"]')
  140. self.browser.snapshot("integrations - custom scm settings")