test_organization_integration_configuration_tabs.py 6.6 KB

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