test_organization_integration.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. from __future__ import absolute_import
  2. from exam import mock
  3. from sentry.models import Integration
  4. from sentry.testutils import AcceptanceTestCase
  5. from tests.acceptance.page_objects.organization_integration_settings import (
  6. OrganizationIntegrationSettingsPage, ExampleIntegrationSetupWindowElement
  7. )
  8. class OrganizationIntegrationAcceptanceTestCase(AcceptanceTestCase):
  9. def setUp(self):
  10. super(OrganizationIntegrationAcceptanceTestCase, self).setUp()
  11. self.user = self.create_user('foo@example.com')
  12. self.org = self.create_organization(
  13. name='Rowdy Tiger',
  14. owner=None,
  15. )
  16. self.team = self.create_team(organization=self.org, name='Mariachi Band')
  17. self.project = self.create_project(
  18. organization=self.org,
  19. teams=[self.team],
  20. name='Bengal',
  21. )
  22. self.create_member(
  23. user=self.user,
  24. organization=self.org,
  25. role='owner',
  26. teams=[self.team],
  27. )
  28. self.model = Integration.objects.create(
  29. provider='example',
  30. external_id='example',
  31. name='Test Integration',
  32. metadata={
  33. 'domain_name': 'example-test.com',
  34. },
  35. )
  36. self.org_integration = self.model.add_organization(self.org, self.user)
  37. self.login_as(self.user)
  38. self.integration_settings_path = 'sentry-api-0-organization-integrations'
  39. def load_page(self, url):
  40. self.browser.get(url)
  41. self.browser.wait_until_not('.loading-indicator')
  42. class OrganizationIntegrationSettingsTest(OrganizationIntegrationAcceptanceTestCase):
  43. """
  44. As a user(type?), I can setup, configure, and remove an integration.
  45. """
  46. # TODO(lb): Tests to be written
  47. # test_setup_new_integration_with_repository
  48. # test_setup_new_integration_with_issue_sync
  49. # test_remove_existing_integration_installation
  50. # test_update_legacy_integration
  51. # test_user_permissions_for_integration_settings
  52. # test_add_multiple_integrations_to_one_provider
  53. # TODO(lb): check issues details page and see that integration shows in linked issues
  54. def setUp(self):
  55. super(OrganizationIntegrationSettingsTest, self).setUp()
  56. self.org_integration_settings_path = u'/settings/{}/integrations/'.format(
  57. self.organization.slug)
  58. self.provider = mock.Mock()
  59. self.provider.key = 'example'
  60. self.provider.name = 'Example Installation'
  61. def test_can_create_new_integration(self):
  62. self.load_page(self.org_integration_settings_path)
  63. org_settings_page = OrganizationIntegrationSettingsPage(
  64. browser=self.browser
  65. )
  66. provider_element = org_settings_page.get_provider(self.provider)
  67. # assert installation rather than upgrade button
  68. assert provider_element.install_button.label == 'Install'
  69. assert provider_element.install_button.icon_href == '#icon-circle-add'
  70. integration_details_modal = org_settings_page.click_install_button(provider_element)
  71. assert integration_details_modal.add_button.label == 'Add %s' % self.provider.key
  72. assert integration_details_modal.title == '%s Integration' % self.provider.key.capitalize()
  73. integration_details_modal.add_button.click()
  74. org_settings_page.click_through_integration_setup(
  75. integration_details_modal,
  76. ExampleIntegrationSetupWindowElement,
  77. {'name': self.provider.name}
  78. )
  79. # provider_element might be rerendered
  80. provider_element = org_settings_page.get_provider(self.provider)
  81. installation_element = provider_element.get_installation_with_name(self.provider.name)
  82. assert installation_element
  83. assert Integration.objects.filter(
  84. provider=self.provider.key,
  85. external_id=self.provider.name
  86. ).exists()