test_organization_integration_detail_view.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 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. 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 = Integration.objects.create(
  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. self.browser.snapshot(name="integrations - integration detail one configuration")
  56. detail_view_page = OrganizationIntegrationDetailViewPage(browser=self.browser)
  57. assert self.browser.element_exists('[aria-label="Configure"]')
  58. detail_view_page.uninstall()
  59. assert (
  60. self.browser.element('[data-test-id="integration-status"]').text == "Pending Deletion"
  61. )
  62. self.browser.snapshot(name="integrations - integration detail no configurations")