test_organization_integration_configuration_tabs.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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
  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("organizations:integrations-codeowners"):
  55. self.browser.get(
  56. f"/settings/{self.organization.slug}/integrations/{self.provider}/{self.integration.id}/"
  57. )
  58. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  59. self.browser.click(".nav-tabs li:nth-child(3) a")
  60. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  61. # Empty state
  62. # Create mapping
  63. self.browser.click('[data-test-id="add-mapping-button"]')
  64. self.browser.wait_until("[role='dialog']")
  65. # Add Mapping Modal
  66. externalName = self.browser.find_element(by=By.NAME, value="externalName")
  67. externalName.send_keys("@user2")
  68. self.browser.click("#userId:first-child div")
  69. self.browser.click('[id="react-select-2-option-1"]')
  70. # List View
  71. self.browser.click('[aria-label="Save Changes"]')
  72. self.browser.wait_until_not('[aria-label="Save Changes"]')
  73. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  74. def test_external_team_mappings(self):
  75. with self.feature("organizations:integrations-codeowners"):
  76. self.browser.get(
  77. f"/settings/{self.organization.slug}/integrations/{self.provider}/{self.integration.id}/"
  78. )
  79. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  80. self.browser.click(".nav-tabs li:nth-child(4) a")
  81. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  82. # Empty state
  83. # Create mapping
  84. self.browser.click('[data-test-id="add-mapping-button"]')
  85. self.browser.wait_until("[role='dialog']")
  86. # Add Mapping Modal
  87. externalName = self.browser.find_element(by=By.NAME, value="externalName")
  88. externalName.send_keys("@getsentry/ecosystem")
  89. self.browser.click("#teamId:first-child div")
  90. self.browser.click('[id="react-select-2-option-0"]')
  91. # List View
  92. self.browser.click('[aria-label="Save Changes"]')
  93. self.browser.wait_until_not('[aria-label="Save Changes"]')
  94. self.browser.wait_until_not('[data-test-id="loading-indicator"]')