test_performance_vital_detail.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from datetime import timezone
  2. from unittest.mock import patch
  3. from urllib.parse import urlencode
  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.cases import AcceptanceTestCase, SnubaTestCase
  8. from sentry.testutils.helpers.datetime import before_now
  9. from sentry.testutils.silo import no_silo_test
  10. from sentry.utils.samples import load_data
  11. FEATURE_NAMES = ("organizations:performance-view",)
  12. @no_silo_test(stable=True)
  13. class PerformanceVitalDetailsTest(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 = "/organizations/{}/performance/vitaldetail/?{}".format(
  24. self.org.slug,
  25. urlencode({"query": "transaction.duration:>0"}),
  26. )
  27. self.page = BasePage(self.browser)
  28. @patch("django.utils.timezone.now")
  29. def test_with_data(self, mock_now):
  30. mock_now.return_value = before_now().replace(tzinfo=timezone.utc)
  31. event = load_data("transaction", timestamp=before_now(minutes=10))
  32. self.store_event(data=event, project_id=self.project.id)
  33. self.project.update(flags=F("flags").bitor(Project.flags.has_transactions))
  34. with self.feature(FEATURE_NAMES):
  35. self.browser.get(self.path)
  36. self.page.wait_until_loaded()
  37. self.browser.wait_until_not(
  38. '[data-test-id="grid-editable"] [data-test-id="empty-state"]', timeout=2
  39. )