12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- from unittest.mock import patch
- import pytz
- from django.db.models import F
- from fixtures.page_objects.base import BasePage
- from sentry.models import Project
- from sentry.testutils import AcceptanceTestCase, SnubaTestCase
- from sentry.testutils.helpers.datetime import before_now
- from sentry.utils.samples import load_data
- FEATURE_NAMES = (
- "organizations:discover-basic",
- "organizations:performance-view",
- )
- class PerformanceOverviewTest(AcceptanceTestCase, SnubaTestCase):
- def setUp(self):
- super().setUp()
- self.org = self.create_organization(owner=self.user, name="Rowdy Tiger")
- self.team = self.create_team(
- organization=self.org, name="Mariachi Band", members=[self.user]
- )
- self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
- self.group = self.create_group(project=self.project)
- self.login_as(self.user)
- self.path = f"/organizations/{self.org.slug}/performance/"
- self.page = BasePage(self.browser)
- @patch("django.utils.timezone.now")
- def test_onboarding(self, mock_now):
- mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
- with self.feature(FEATURE_NAMES):
- self.browser.get(self.path)
- self.page.wait_until_loaded()
- self.browser.snapshot("performance overview - onboarding")
- @patch("django.utils.timezone.now")
- def test_with_data(self, mock_now):
- mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
- event = load_data("transaction", timestamp=before_now(minutes=1))
- self.store_event(data=event, project_id=self.project.id)
- self.project.update(flags=F("flags").bitor(Project.flags.has_transactions))
- with self.feature(FEATURE_NAMES):
- self.browser.get(self.path)
- self.page.wait_until_loaded()
- # This test is flakey in that we sometimes load this page before the event is processed
- # depend on pytest-retry to reload the page
- self.browser.wait_until_not(
- '[data-test-id="grid-editable"] [data-test-id="empty-state"]', timeout=2
- )
- self.browser.snapshot("performance overview - with data")
|