test_organization_integration_detail_view.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from unittest import mock
  2. from fixtures.page_objects.organization_integration_settings import (
  3. ExampleIntegrationSetupWindowElement,
  4. OrganizationIntegrationDetailViewPage,
  5. )
  6. from sentry.models.integrations.integration import Integration
  7. from sentry.testutils.cases import AcceptanceTestCase
  8. from sentry.testutils.silo import no_silo_test
  9. @no_silo_test
  10. class OrganizationIntegrationDetailView(AcceptanceTestCase):
  11. """
  12. As a developer, I can create an integration, install it, and uninstall it
  13. """
  14. def setUp(self):
  15. super().setUp()
  16. self.login_as(self.user)
  17. def load_page(self, slug, configuration_tab=False):
  18. url = f"/settings/{self.organization.slug}/integrations/{slug}/"
  19. if configuration_tab:
  20. url += "?tab=configurations"
  21. self.browser.get(url)
  22. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  23. def test_example_installation(self):
  24. self.provider = mock.Mock()
  25. self.provider.key = "alert_rule_integration"
  26. self.provider.name = "Example Installation"
  27. self.load_page("alert_rule_integration")
  28. detail_view_page = OrganizationIntegrationDetailViewPage(browser=self.browser)
  29. detail_view_page.click_install_button()
  30. detail_view_page.click_through_integration_setup(
  31. ExampleIntegrationSetupWindowElement, {"name": self.provider.name}
  32. )
  33. self.wait_for_loading()
  34. integration = Integration.objects.filter(
  35. provider=self.provider.key, external_id=self.provider.name
  36. ).first()
  37. assert integration
  38. assert (
  39. f"/settings/{self.organization.slug}/integrations/{self.provider.key}/{integration.id}/"
  40. in self.browser.driver.current_url
  41. )
  42. def test_uninstallation(self):
  43. model = self.create_provider_integration(
  44. provider="slack",
  45. external_id="some_slack",
  46. name="Test Slack",
  47. metadata={
  48. "domain_name": "slack-test.slack.com",
  49. "installation_type": "born_as_bot",
  50. "access_token": "xoxp-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx",
  51. },
  52. )
  53. model.add_organization(self.organization, self.user)
  54. self.load_page("slack", configuration_tab=True)
  55. detail_view_page = OrganizationIntegrationDetailViewPage(browser=self.browser)
  56. assert self.browser.element_exists('[aria-label="Configure"]')
  57. detail_view_page.uninstall()
  58. assert (
  59. self.browser.element('[data-test-id="integration-status"]').text == "Pending Deletion"
  60. )