|
| 1 | +from datetime import timedelta |
| 2 | +from unittest.mock import patch |
| 3 | + |
| 4 | +from fixtures.page_objects.explore_spans import ExploreSpansPage |
| 5 | +from sentry.testutils.cases import AcceptanceTestCase, SnubaTestCase, SpanTestCase |
| 6 | +from sentry.testutils.helpers.datetime import before_now |
| 7 | +from sentry.testutils.silo import no_silo_test |
| 8 | + |
| 9 | +FEATURE_FLAGS = [ |
| 10 | + "organizations:visibility-explore-view", |
| 11 | +] |
| 12 | + |
| 13 | + |
| 14 | +@no_silo_test |
| 15 | +class ExploreSpansTest(AcceptanceTestCase, SpanTestCase, SnubaTestCase): |
| 16 | + viewname = "sentry-api-0-organization-events" |
| 17 | + |
| 18 | + def setUp(self): |
| 19 | + super().setUp() |
| 20 | + self.start = self.day_ago = before_now(days=1).replace( |
| 21 | + hour=10, minute=0, second=0, microsecond=0 |
| 22 | + ) |
| 23 | + |
| 24 | + self.start_minus_one_minute = self.start - timedelta(minutes=1) |
| 25 | + self.start_minus_two_minutes = self.start - timedelta(minutes=2) |
| 26 | + |
| 27 | + self.organization = self.create_organization(owner=self.user, name="Rowdy Tiger") |
| 28 | + self.team = self.create_team( |
| 29 | + organization=self.organization, name="Mariachi Band", members=[self.user] |
| 30 | + ) |
| 31 | + self.project = self.create_project( |
| 32 | + organization=self.organization, teams=[self.team], name="Bengal" |
| 33 | + ) |
| 34 | + self.login_as(self.user) |
| 35 | + |
| 36 | + self.page = ExploreSpansPage(self.browser, self.client) |
| 37 | + self.dismiss_assistant() |
| 38 | + |
| 39 | + @patch("django.utils.timezone.now") |
| 40 | + def test_spans_table_loads_all_events(self, mock_now): |
| 41 | + mock_now.return_value = self.start |
| 42 | + |
| 43 | + assert ( |
| 44 | + self.browser.driver.get_window_size().get("width") == 1680 |
| 45 | + ) # This test makes assertions based on the current default window size. |
| 46 | + |
| 47 | + with self.feature(FEATURE_FLAGS): |
| 48 | + spans = [ |
| 49 | + self.create_span( |
| 50 | + {"description": "foo", "sentry_tags": {"status": "success"}}, |
| 51 | + start_ts=self.start_minus_one_minute, |
| 52 | + ), |
| 53 | + self.create_span( |
| 54 | + { |
| 55 | + "description": "bar", |
| 56 | + "sentry_tags": {"status": "invalid_argument"}, |
| 57 | + }, |
| 58 | + start_ts=self.start_minus_two_minutes, |
| 59 | + ), |
| 60 | + ] |
| 61 | + self.store_spans( |
| 62 | + spans, |
| 63 | + is_eap=True, |
| 64 | + ) |
| 65 | + |
| 66 | + self.page.visit_explore_spans(self.organization.slug) |
| 67 | + for span in spans: |
| 68 | + span_row = self.page.get_spans_row_with_id(span["span_id"][:8]) |
| 69 | + column_objects = self.page.get_spans_row_columns(span_row) |
| 70 | + row_text = [element.text for element in column_objects] |
| 71 | + # Just checking that the attrs of the span are here so test isn't dependent on the order of columns |
| 72 | + assert span["span_id"][:8] in row_text |
| 73 | + assert span["description"] in row_text |
0 commit comments