test_organization_integration_configuration_tabs.py 6.5 KB

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