test_organization_integration_detail_view.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. from unittest import mock
  2. from fixtures.page_objects.organization_integration_settings import (
  3. ExampleIntegrationSetupWindowElement,
  4. OrganizationIntegrationDetailViewPage,
  5. )
  6. from sentry.models import Integration
  7. from sentry.testutils.cases import AcceptanceTestCase
  8. from sentry.testutils.silo import region_silo_test
  9. @region_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. self.browser.snapshot("integrations - integration detail overview")
  29. detail_view_page = OrganizationIntegrationDetailViewPage(browser=self.browser)
  30. detail_view_page.click_install_button()
  31. detail_view_page.click_through_integration_setup(
  32. ExampleIntegrationSetupWindowElement, {"name": self.provider.name}
  33. )
  34. self.wait_for_loading()
  35. integration = Integration.objects.filter(
  36. provider=self.provider.key, external_id=self.provider.name
  37. ).first()
  38. assert integration
  39. assert (
  40. f"/settings/{self.organization.slug}/integrations/{self.provider.key}/{integration.id}/"
  41. in self.browser.driver.current_url
  42. )
  43. def test_uninstallation(self):
  44. model = Integration.objects.create(
  45. provider="slack",
  46. external_id="some_slack",
  47. name="Test Slack",
  48. metadata={
  49. "domain_name": "slack-test.slack.com",
  50. "installation_type": "born_as_bot",
  51. "access_token": "xoxp-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx",
  52. },
  53. )
  54. model.add_organization(self.organization, self.user)
  55. self.load_page("slack", configuration_tab=True)
  56. self.browser.snapshot(name="integrations - integration detail one configuration")
  57. detail_view_page = OrganizationIntegrationDetailViewPage(browser=self.browser)
  58. assert self.browser.element_exists('[aria-label="Configure"]')
  59. detail_view_page.uninstall()
  60. assert (
  61. self.browser.element('[data-test-id="integration-status"]').text == "Pending Deletion"
  62. )
  63. self.browser.snapshot(name="integrations - integration detail no configurations")