test_organization_integration_configuration_tabs.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. from selenium.webdriver.common.by import By
  2. from sentry.testutils.cases import AcceptanceTestCase
  3. from sentry.testutils.silo import no_silo_test
  4. @no_silo_test
  5. class OrganizationIntegrationConfigurationTabs(AcceptanceTestCase):
  6. def setUp(self):
  7. super().setUp()
  8. self.login_as(self.user)
  9. self.provider = "github"
  10. self.integration = self.create_provider_integration(
  11. provider=self.provider,
  12. external_id="some_github",
  13. name="Github",
  14. metadata={
  15. "access_token": "some_access_token",
  16. "expires_at": "2021-04-16T01:08:42",
  17. "icon": "https://avatars.githubusercontent.com/u/10491134?v=4",
  18. "domain_name": "github.com/getsentry",
  19. "account_type": "User",
  20. },
  21. )
  22. self.integration.add_organization(self.organization, self.user)
  23. self.create_repo(
  24. name="getsentry/sentry",
  25. provider="integrations:github",
  26. integration_id=self.integration.id,
  27. project=self.project,
  28. url="https://github.com/getsentry/sentry",
  29. )
  30. def load_page(self, slug, configuration_tab=False):
  31. url = f"/settings/{self.organization.slug}/integrations/{slug}/"
  32. if configuration_tab:
  33. url += "?tab=configurations"
  34. self.browser.get(url)
  35. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  36. def test_external_user_mappings(self):
  37. # create `auth_user` records to differentiate `user_id` and `organization_member_id`
  38. self.create_sentry_app()
  39. self.user2 = self.create_user("user2@example.com")
  40. self.user3 = self.create_user("user3@example.com")
  41. self.team = self.create_team(
  42. organization=self.organization, slug="tiger-team", members=[self.user]
  43. )
  44. self.team2 = self.create_team(
  45. organization=self.organization, slug="tiger-team2", members=[self.user2]
  46. )
  47. self.team3 = self.create_team(
  48. organization=self.organization, slug="tiger-team3", members=[self.user3]
  49. )
  50. self.project = self.create_project(
  51. organization=self.organization, teams=[self.team, self.team2, self.team3], slug="bengal"
  52. )
  53. with self.feature("organizations:integrations-codeowners"):
  54. self.browser.get(
  55. f"/settings/{self.organization.slug}/integrations/{self.provider}/{self.integration.id}/"
  56. )
  57. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  58. self.browser.click(".nav-tabs li:nth-child(3) a")
  59. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  60. # Empty state
  61. # Create mapping
  62. self.browser.click('[data-test-id="add-mapping-button"]')
  63. self.browser.wait_until("[role='dialog']")
  64. # Add Mapping Modal
  65. externalName = self.browser.find_element(by=By.NAME, value="externalName")
  66. externalName.send_keys("@user2")
  67. self.browser.click("#userId:first-child div")
  68. self.browser.click('[id="react-select-2-option-1"]')
  69. # List View
  70. self.browser.click('[aria-label="Save Changes"]')
  71. self.browser.wait_until_not('[aria-label="Save Changes"]')
  72. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  73. def test_external_team_mappings(self):
  74. with self.feature("organizations:integrations-codeowners"):
  75. self.browser.get(
  76. f"/settings/{self.organization.slug}/integrations/{self.provider}/{self.integration.id}/"
  77. )
  78. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  79. self.browser.click(".nav-tabs li:nth-child(4) a")
  80. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  81. # Empty state
  82. # Create mapping
  83. self.browser.click('[data-test-id="add-mapping-button"]')
  84. self.browser.wait_until("[role='dialog']")
  85. # Add Mapping Modal
  86. externalName = self.browser.find_element(by=By.NAME, value="externalName")
  87. externalName.send_keys("@getsentry/ecosystem")
  88. self.browser.click("#teamId:first-child div")
  89. self.browser.click('[id="react-select-2-option-0"]')
  90. # List View
  91. self.browser.click('[aria-label="Save Changes"]')
  92. self.browser.wait_until_not('[aria-label="Save Changes"]')
  93. self.browser.wait_until_not('[data-test-id="loading-indicator"]')