test_organization_integration_detail_view.py 2.7 KB

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