test_organization_plugin_detail_view.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. self.browser.snapshot("integrations - plugin detail overview")
  28. detail_view_page = OrganizationAbstractDetailViewPage(browser=self.browser)
  29. detail_view_page.click_install_button()
  30. self.browser.click('[role="dialog"] [id$="option-0-0"]')
  31. # check if we got to the configuration page with the form
  32. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  33. self.browser.wait_until_test_id("plugin-config")
  34. self.browser.snapshot("integrations - plugin config form")
  35. def test_uninstallation(self):
  36. self.plugin.set_option("api_key", "7c8951d1", self.project)
  37. self.plugin.set_option("alert_url", "https://api.opsgenie.com/v2/alerts", self.project)
  38. self.load_page("opsgenie", configuration_tab=True)
  39. self.browser.snapshot("integrations - plugin detail one configuration")
  40. detail_view_page = OrganizationAbstractDetailViewPage(browser=self.browser)
  41. assert self.browser.element_exists('[aria-label="Configure"]')
  42. detail_view_page.uninstall()
  43. self.browser.wait_until('[data-test-id="toast-success"]')
  44. assert not self.browser.element_exists('[aria-label="Configure"]')
  45. self.browser.snapshot("integrations - plugin detail no configurations")