test_performance_landing.py 1.9 KB

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