test_performance_vital_detail.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from unittest.mock import patch
  2. from urllib.parse import urlencode
  3. import pytz
  4. from django.db.models import F
  5. from fixtures.page_objects.base import BasePage
  6. from sentry.models import Project
  7. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  8. from sentry.testutils.helpers.datetime import before_now
  9. from sentry.utils.samples import load_data
  10. FEATURE_NAMES = ("organizations:performance-view",)
  11. class PerformanceVitalDetailsTest(AcceptanceTestCase, SnubaTestCase):
  12. def setUp(self):
  13. super().setUp()
  14. self.org = self.create_organization(owner=self.user, name="Rowdy Tiger")
  15. self.team = self.create_team(
  16. organization=self.org, name="Mariachi Band", members=[self.user]
  17. )
  18. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  19. self.group = self.create_group(project=self.project)
  20. self.login_as(self.user)
  21. self.path = "/organizations/{}/performance/vitaldetail/?{}".format(
  22. self.org.slug,
  23. urlencode({"query": "transaction.duration:>0"}),
  24. )
  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().replace(tzinfo=pytz.utc)
  29. event = load_data("transaction", timestamp=before_now(minutes=1))
  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. self.browser.wait_until_not(
  36. '[data-test-id="grid-editable"] [data-test-id="empty-state"]', timeout=2
  37. )
  38. self.browser.snapshot("performance vital detail - with data")