Skip to content

Commit e67a783

Browse files
authored
test(explore): Add tests for the explore spans page (#96579)
- Making sure that we have at least a base level of testing of the explore page - depends on #96578
1 parent 6cfe07a commit e67a783

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from selenium.webdriver.common.by import By
2+
3+
from .base import BasePage
4+
from .global_selection import GlobalSelectionPage
5+
6+
7+
class ExploreSpansPage(BasePage):
8+
def __init__(self, browser, client):
9+
super().__init__(browser)
10+
self.client = client
11+
self.global_selection = GlobalSelectionPage(browser)
12+
13+
def visit_explore_spans(self, org):
14+
self.browser.get(f"/organizations/{org}/explore/traces/")
15+
self.wait_until_loaded()
16+
17+
def get_spans_row_with_id(self, span_id):
18+
row = self.browser.find_element(
19+
by=By.XPATH,
20+
value=f'//tr[.//*[contains(text(),"{span_id}")]]',
21+
)
22+
return row
23+
24+
def get_spans_row_columns(self, row):
25+
# The expanded row actually makes a new sibling row that contains the fields-tree.
26+
columns = row.find_elements(By.XPATH, "child::td")
27+
return columns
28+
29+
def wait_until_loaded(self):
30+
self.browser.wait_until_not('[data-test-id="loading-indicator"]')
31+
self.browser.wait_until_test_id("spans-table")
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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

Comments
 (0)