12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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.cases import AcceptanceTestCase, SnubaTestCase
- from sentry.testutils.helpers.datetime import before_now
- from sentry.testutils.silo import no_silo_test
- from sentry.utils.samples import load_data
- FEATURE_NAMES = (
- "organizations:discover-basic",
- "organizations:performance-view",
- )
- @no_silo_test(stable=True)
- class PerformanceLandingTest(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_with_data(self, mock_now):
- mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
- event = load_data("transaction", timestamp=before_now(minutes=10))
- 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 landing - with data")
- @patch("django.utils.timezone.now")
- def test_with_data_and_new_widget_designs(self, mock_now):
- mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
- event = load_data("transaction", timestamp=before_now(minutes=10))
- self.store_event(data=event, project_id=self.project.id)
- self.project.update(flags=F("flags").bitor(Project.flags.has_transactions))
- FEATURES = (
- "organizations:discover-basic",
- "organizations:performance-view",
- "organizations:performance-new-widget-designs",
- )
- with self.feature(FEATURES):
- 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("new widget performance landing - with data")
|