test_performance_landing.py 2.9 KB

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