test_organization_integration_configuration_tabs.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. from selenium.webdriver.common.by import By
  2. from sentry.models.integrations.integration import Integration
  3. from sentry.testutils.cases import AcceptanceTestCase
  4. from sentry.testutils.silo import no_silo_test
  5. @no_silo_test(stable=True)
  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. # Create mapping
  68. self.browser.click('[data-test-id="add-mapping-button"]')
  69. self.browser.wait_until("[role='dialog']")
  70. # Add Mapping Modal
  71. externalName = self.browser.find_element(by=By.NAME, value="externalName")
  72. externalName.send_keys("@user2")
  73. self.browser.click("#userId:first-child div")
  74. self.browser.click('[id="react-select-2-option-1"]')
  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. 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. # Create mapping
  94. self.browser.click('[data-test-id="add-mapping-button"]')
  95. self.browser.wait_until("[role='dialog']")
  96. # Add Mapping Modal
  97. externalName = self.browser.find_element(by=By.NAME, value="externalName")
  98. externalName.send_keys("@getsentry/ecosystem")
  99. self.browser.click("#teamId:first-child div")
  100. self.browser.click('[id="react-select-2-option-0"]')
  101. # List View
  102. self.browser.click('[aria-label="Save Changes"]')
  103. self.browser.wait_until_not('[aria-label="Save Changes"]')
  104. self.browser.wait_until_not('[data-test-id="loading-indicator"]')