test_performance_landing.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. from unittest.mock import patch
  2. from django.db.models import F
  3. from fixtures.page_objects.base import BasePage
  4. from sentry.models.project import Project
  5. from sentry.testutils.cases import AcceptanceTestCase, SnubaTestCase
  6. from sentry.testutils.helpers.datetime import before_now
  7. from sentry.testutils.silo import no_silo_test
  8. from sentry.utils.samples import load_data
  9. FEATURE_NAMES = (
  10. "organizations:discover-basic",
  11. "organizations:performance-view",
  12. )
  13. @no_silo_test
  14. class PerformanceLandingTest(AcceptanceTestCase, SnubaTestCase):
  15. def setUp(self):
  16. super().setUp()
  17. self.org = self.create_organization(owner=self.user, name="Rowdy Tiger")
  18. self.team = self.create_team(
  19. organization=self.org, name="Mariachi Band", members=[self.user]
  20. )
  21. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  22. self.group = self.create_group(project=self.project)
  23. self.login_as(self.user)
  24. self.path = f"/organizations/{self.org.slug}/performance/"
  25. self.page = BasePage(self.browser)
  26. @patch("django.utils.timezone.now")
  27. def test_with_data(self, mock_now):
  28. mock_now.return_value = before_now()
  29. event = load_data("transaction", timestamp=before_now(minutes=10))
  30. self.store_event(data=event, project_id=self.project.id)
  31. self.project.update(flags=F("flags").bitor(Project.flags.has_transactions))
  32. with self.feature(FEATURE_NAMES):
  33. self.browser.get(self.path)
  34. self.page.wait_until_loaded()
  35. # This test is flakey in that we sometimes load this page before the event is processed
  36. # depend on pytest-retry to reload the page
  37. self.browser.wait_until_not(
  38. '[data-test-id="grid-editable"] [data-test-id="empty-state"]', timeout=2
  39. )
  40. @patch("django.utils.timezone.now")
  41. def test_with_data_and_new_widget_designs(self, mock_now):
  42. mock_now.return_value = before_now()
  43. event = load_data("transaction", timestamp=before_now(minutes=10))
  44. self.store_event(data=event, project_id=self.project.id)
  45. self.project.update(flags=F("flags").bitor(Project.flags.has_transactions))
  46. FEATURES = (
  47. "organizations:discover-basic",
  48. "organizations:performance-view",
  49. "organizations:performance-new-widget-designs",
  50. )
  51. with self.feature(FEATURES):
  52. self.browser.get(self.path)
  53. self.page.wait_until_loaded()
  54. # This test is flakey in that we sometimes load this page before the event is processed
  55. # depend on pytest-retry to reload the page
  56. self.browser.wait_until_not(
  57. '[data-test-id="grid-editable"] [data-test-id="empty-state"]', timeout=2
  58. )