test_organization_plugin_detail_view.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from functools import cached_property
  2. from fixtures.page_objects.organization_integration_settings import (
  3. OrganizationAbstractDetailViewPage,
  4. )
  5. from sentry.testutils.cases import AcceptanceTestCase
  6. from sentry.testutils.silo import no_silo_test
  7. from sentry_plugins.opsgenie.plugin import OpsGeniePlugin
  8. @no_silo_test(stable=True)
  9. class OrganizationPluginDetailedView(AcceptanceTestCase):
  10. @cached_property
  11. def plugin(self):
  12. return OpsGeniePlugin()
  13. def setUp(self):
  14. super().setUp()
  15. # need at least two projects
  16. self.project = self.create_project(organization=self.organization, name="Back end")
  17. self.create_project(organization=self.organization, name="Front End")
  18. self.login_as(self.user)
  19. def load_page(self, slug, configuration_tab=False):
  20. url = f"/settings/{self.organization.slug}/plugins/{slug}/"
  21. if configuration_tab:
  22. url += "?tab=configurations"
  23. self.browser.get(url)
  24. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  25. def test_opsgenie_add_to_project(self):
  26. self.load_page("opsgenie")
  27. detail_view_page = OrganizationAbstractDetailViewPage(browser=self.browser)
  28. detail_view_page.click_install_button()
  29. self.browser.click('[role="dialog"] [id$="option-0-0"]')
  30. # check if we got to the configuration page with the form
  31. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  32. self.browser.wait_until_test_id("plugin-config")
  33. def test_uninstallation(self):
  34. self.plugin.set_option("api_key", "7c8951d1", self.project)
  35. self.plugin.set_option("alert_url", "https://api.opsgenie.com/v2/alerts", self.project)
  36. self.load_page("opsgenie", configuration_tab=True)
  37. detail_view_page = OrganizationAbstractDetailViewPage(browser=self.browser)
  38. assert self.browser.element_exists('[aria-label="Configure"]')
  39. detail_view_page.uninstall()
  40. self.browser.wait_until('[data-test-id="toast-success"]')
  41. assert not self.browser.element_exists('[aria-label="Configure"]')