test_organization_events_v2.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. import copy
  2. from datetime import timedelta
  3. from unittest.mock import patch
  4. from urllib.parse import urlencode
  5. import pytest
  6. import pytz
  7. from selenium.webdriver.common.keys import Keys
  8. from sentry.discover.models import DiscoverSavedQuery
  9. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  10. from sentry.testutils.helpers.datetime import before_now, iso_format, timestamp_format
  11. from sentry.utils.samples import load_data
  12. FEATURE_NAMES = [
  13. "organizations:discover-basic",
  14. "organizations:discover-query",
  15. "organizations:performance-view",
  16. ]
  17. def all_events_query(**kwargs):
  18. options = {
  19. "sort": ["-timestamp"],
  20. "field": ["title", "event.type", "project", "user.display", "timestamp"],
  21. "name": ["All Events"],
  22. }
  23. options.update(kwargs)
  24. return urlencode(options, doseq=True)
  25. def errors_query(**kwargs):
  26. options = {
  27. "sort": ["-title"],
  28. "name": ["Errors"],
  29. "field": ["title", "count(id)", "count_unique(user)", "project"],
  30. "query": ["event.type:error"],
  31. }
  32. options.update(kwargs)
  33. return urlencode(options, doseq=True)
  34. def transactions_query(**kwargs):
  35. options = {
  36. "sort": ["-count"],
  37. "name": ["Transactions"],
  38. "field": ["transaction", "project", "count()"],
  39. "statsPeriod": ["14d"],
  40. "query": ["event.type:transaction"],
  41. }
  42. options.update(kwargs)
  43. return urlencode(options, doseq=True)
  44. def generate_transaction(trace=None, span=None):
  45. end_datetime = before_now(minutes=1)
  46. start_datetime = end_datetime - timedelta(milliseconds=500)
  47. event_data = load_data(
  48. "transaction",
  49. timestamp=end_datetime,
  50. start_timestamp=start_datetime,
  51. trace=trace,
  52. span_id=span,
  53. )
  54. event_data.update({"event_id": "a" * 32})
  55. # generate and build up span tree
  56. reference_span = event_data["spans"][0]
  57. parent_span_id = reference_span["parent_span_id"]
  58. span_tree_blueprint = {
  59. "a": {},
  60. "b": {"bb": {"bbb": {"bbbb": "bbbbb"}}},
  61. "c": {},
  62. "d": {},
  63. "e": {},
  64. }
  65. time_offsets = {
  66. "a": (timedelta(), timedelta(milliseconds=10)),
  67. "b": (timedelta(milliseconds=120), timedelta(milliseconds=250)),
  68. "bb": (timedelta(milliseconds=130), timedelta(milliseconds=10)),
  69. "bbb": (timedelta(milliseconds=140), timedelta(milliseconds=10)),
  70. "bbbb": (timedelta(milliseconds=150), timedelta(milliseconds=10)),
  71. "bbbbb": (timedelta(milliseconds=160), timedelta(milliseconds=90)),
  72. "c": (timedelta(milliseconds=260), timedelta(milliseconds=100)),
  73. "d": (timedelta(milliseconds=375), timedelta(milliseconds=50)),
  74. "e": (timedelta(milliseconds=400), timedelta(milliseconds=100)),
  75. }
  76. def build_span_tree(span_tree, spans, parent_span_id):
  77. for span_id, child in sorted(span_tree.items(), key=lambda item: item[0]):
  78. span = copy.deepcopy(reference_span)
  79. # non-leaf node span
  80. span["parent_span_id"] = parent_span_id.ljust(16, "0")
  81. span["span_id"] = span_id.ljust(16, "0")
  82. (start_delta, span_length) = time_offsets.get(span_id, (timedelta(), timedelta()))
  83. span_start_time = start_datetime + start_delta
  84. span["start_timestamp"] = timestamp_format(span_start_time)
  85. span["timestamp"] = timestamp_format(span_start_time + span_length)
  86. spans.append(span)
  87. if isinstance(child, dict):
  88. spans = build_span_tree(child, spans, span_id)
  89. elif isinstance(child, str):
  90. parent_span_id = span_id
  91. span_id = child
  92. span = copy.deepcopy(reference_span)
  93. # leaf node span
  94. span["parent_span_id"] = parent_span_id.ljust(16, "0")
  95. span["span_id"] = span_id.ljust(16, "0")
  96. (start_delta, span_length) = time_offsets.get(span_id, (timedelta(), timedelta()))
  97. span_start_time = start_datetime + start_delta
  98. span["start_timestamp"] = timestamp_format(span_start_time)
  99. span["timestamp"] = timestamp_format(span_start_time + span_length)
  100. spans.append(span)
  101. return spans
  102. event_data["spans"] = build_span_tree(span_tree_blueprint, [], parent_span_id)
  103. return event_data
  104. class OrganizationEventsV2Test(AcceptanceTestCase, SnubaTestCase):
  105. def setUp(self):
  106. super().setUp()
  107. self.user = self.create_user("foo@example.com", is_superuser=True)
  108. self.org = self.create_organization(name="Rowdy Tiger")
  109. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  110. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  111. self.create_member(user=self.user, organization=self.org, role="owner", teams=[self.team])
  112. self.login_as(self.user)
  113. self.landing_path = f"/organizations/{self.org.slug}/discover/queries/"
  114. self.result_path = f"/organizations/{self.org.slug}/discover/results/"
  115. def wait_until_loaded(self):
  116. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  117. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  118. def test_events_default_landing(self):
  119. with self.feature(FEATURE_NAMES):
  120. self.browser.get(self.landing_path)
  121. self.wait_until_loaded()
  122. self.browser.snapshot("events-v2 - default landing")
  123. def test_all_events_query_empty_state(self):
  124. with self.feature(FEATURE_NAMES):
  125. self.browser.get(self.result_path + "?" + all_events_query())
  126. self.wait_until_loaded()
  127. self.browser.snapshot("events-v2 - all events query - empty state")
  128. with self.feature(FEATURE_NAMES):
  129. # expect table to expand to the right when no tags are provided
  130. self.browser.get(self.result_path + "?" + all_events_query(tag=[]))
  131. self.wait_until_loaded()
  132. self.browser.snapshot("events-v2 - all events query - empty state - no tags")
  133. @patch("django.utils.timezone.now")
  134. def test_all_events_query(self, mock_now):
  135. now = before_now().replace(tzinfo=pytz.utc)
  136. mock_now.return_value = now
  137. min_ago = iso_format(now - timedelta(minutes=1))
  138. two_min_ago = iso_format(now - timedelta(minutes=2))
  139. self.store_event(
  140. data={
  141. "event_id": "a" * 32,
  142. "message": "oh no",
  143. "timestamp": min_ago,
  144. "fingerprint": ["group-1"],
  145. },
  146. project_id=self.project.id,
  147. assert_no_errors=False,
  148. )
  149. self.store_event(
  150. data={
  151. "event_id": "b" * 32,
  152. "message": "this is bad.",
  153. "timestamp": two_min_ago,
  154. "fingerprint": ["group-2"],
  155. "user": {
  156. "id": "123",
  157. "email": "someone@example.com",
  158. "username": "haveibeenpwned",
  159. "ip_address": "8.8.8.8",
  160. "name": "Someone",
  161. },
  162. },
  163. project_id=self.project.id,
  164. assert_no_errors=False,
  165. )
  166. self.wait_for_event_count(self.project.id, 2)
  167. with self.feature(FEATURE_NAMES):
  168. self.browser.get(self.result_path + "?" + all_events_query())
  169. self.wait_until_loaded()
  170. # This test is flakey in that we sometimes load this page before the event is processed
  171. # depend on pytest-retry to reload the page
  172. self.browser.wait_until('[data-test-id="grid-editable"] > tbody > tr:nth-child(2)')
  173. self.browser.snapshot("events-v2 - all events query - list")
  174. with self.feature(FEATURE_NAMES):
  175. # expect table to expand to the right when no tags are provided
  176. self.browser.get(self.result_path + "?" + all_events_query(tag=[]))
  177. self.wait_until_loaded()
  178. self.browser.wait_until('[data-test-id="grid-editable"] > tbody > tr:nth-child(2)')
  179. self.browser.snapshot("events-v2 - all events query - list - no tags")
  180. def test_errors_query_empty_state(self):
  181. with self.feature(FEATURE_NAMES):
  182. self.browser.get(self.result_path + "?" + errors_query())
  183. self.wait_until_loaded()
  184. self.browser.snapshot("events-v2 - errors query - empty state")
  185. self.browser.click_when_visible('[data-test-id="grid-edit-enable"]')
  186. self.browser.snapshot(
  187. "events-v2 - errors query - empty state - querybuilder - column edit state"
  188. )
  189. @patch("django.utils.timezone.now")
  190. def test_errors_query(self, mock_now):
  191. now = before_now().replace(tzinfo=pytz.utc)
  192. mock_now.return_value = now
  193. min_ago = iso_format(now - timedelta(minutes=1))
  194. self.store_event(
  195. data={
  196. "event_id": "a" * 32,
  197. "message": "oh no",
  198. "timestamp": min_ago,
  199. "fingerprint": ["group-1"],
  200. "type": "error",
  201. },
  202. project_id=self.project.id,
  203. assert_no_errors=False,
  204. )
  205. self.store_event(
  206. data={
  207. "event_id": "b" * 32,
  208. "message": "oh no",
  209. "timestamp": min_ago,
  210. "fingerprint": ["group-1"],
  211. "type": "error",
  212. },
  213. project_id=self.project.id,
  214. assert_no_errors=False,
  215. )
  216. self.store_event(
  217. data={
  218. "event_id": "c" * 32,
  219. "message": "this is bad.",
  220. "timestamp": min_ago,
  221. "fingerprint": ["group-2"],
  222. "type": "error",
  223. },
  224. project_id=self.project.id,
  225. assert_no_errors=False,
  226. )
  227. with self.feature(FEATURE_NAMES):
  228. self.browser.get(self.result_path + "?" + errors_query())
  229. self.wait_until_loaded()
  230. self.browser.snapshot("events-v2 - errors")
  231. def test_transactions_query_empty_state(self):
  232. with self.feature(FEATURE_NAMES):
  233. self.browser.get(self.result_path + "?" + transactions_query())
  234. self.wait_until_loaded()
  235. self.browser.snapshot("events-v2 - transactions query - empty state")
  236. with self.feature(FEATURE_NAMES):
  237. # expect table to expand to the right when no tags are provided
  238. self.browser.get(self.result_path + "?" + transactions_query(tag=[]))
  239. self.wait_until_loaded()
  240. self.browser.snapshot("events-v2 - transactions query - empty state - no tags")
  241. @patch("django.utils.timezone.now")
  242. def test_transactions_query(self, mock_now):
  243. mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
  244. event_data = generate_transaction()
  245. self.store_event(data=event_data, project_id=self.project.id, assert_no_errors=True)
  246. with self.feature(FEATURE_NAMES):
  247. self.browser.get(self.result_path + "?" + transactions_query())
  248. self.wait_until_loaded()
  249. self.browser.wait_until_not(
  250. '[data-test-id="grid-editable"] [data-test-id="empty-state"]', timeout=2
  251. )
  252. self.browser.snapshot("events-v2 - transactions query - list")
  253. @patch("django.utils.timezone.now")
  254. def test_event_detail_view_from_all_events(self, mock_now):
  255. now = before_now().replace(tzinfo=pytz.utc)
  256. mock_now.return_value = now
  257. min_ago = iso_format(now - timedelta(minutes=1))
  258. event_data = load_data("python")
  259. event_data.update(
  260. {
  261. "event_id": "a" * 32,
  262. "timestamp": min_ago,
  263. "received": min_ago,
  264. "fingerprint": ["group-1"],
  265. }
  266. )
  267. if "contexts" not in event_data:
  268. event_data["contexts"] = {}
  269. event_data["contexts"]["trace"] = {
  270. "type": "trace",
  271. "trace_id": "a" * 32,
  272. "span_id": "b" * 16,
  273. }
  274. self.store_event(data=event_data, project_id=self.project.id, assert_no_errors=False)
  275. with self.feature(FEATURE_NAMES):
  276. # Get the list page.
  277. self.browser.get(self.result_path + "?" + all_events_query())
  278. self.wait_until_loaded()
  279. # View Event
  280. self.browser.elements('[data-test-id="view-event"]')[0].click()
  281. self.wait_until_loaded()
  282. # header = self.browser.element('[data-test-id="event-header"] div div span')
  283. # assert event_data["message"] in header.text
  284. self.browser.snapshot("events-v2 - single error details view")
  285. @patch("django.utils.timezone.now")
  286. def test_event_detail_view_from_errors_view(self, mock_now):
  287. now = before_now().replace(tzinfo=pytz.utc)
  288. mock_now.return_value = now
  289. event_data = load_data("javascript")
  290. event_data.update(
  291. {
  292. "timestamp": iso_format(now - timedelta(minutes=5)),
  293. "event_id": "d" * 32,
  294. "fingerprint": ["group-1"],
  295. }
  296. )
  297. event_data["contexts"]["trace"] = {
  298. "type": "trace",
  299. "trace_id": "a" * 32,
  300. "span_id": "b" * 16,
  301. }
  302. self.store_event(data=event_data, project_id=self.project.id)
  303. self.wait_for_event_count(self.project.id, 1)
  304. with self.feature(FEATURE_NAMES):
  305. # Get the list page
  306. self.browser.get(self.result_path + "?" + errors_query() + "&statsPeriod=24h")
  307. self.wait_until_loaded()
  308. # Open the stack
  309. self.browser.element('[data-test-id="open-group"]').click()
  310. self.wait_until_loaded()
  311. # View Event
  312. self.browser.elements('[data-test-id="view-event"]')[0].click()
  313. self.wait_until_loaded()
  314. self.browser.snapshot("events-v2 - error event detail view")
  315. @patch("django.utils.timezone.now")
  316. def test_event_detail_view_from_transactions_query(self, mock_now):
  317. mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
  318. event_data = generate_transaction(trace="a" * 32, span="ab" * 8)
  319. self.store_event(data=event_data, project_id=self.project.id, assert_no_errors=True)
  320. # Create a child event that is linked to the parent so we have coverage
  321. # of traversal buttons.
  322. child_event = generate_transaction(
  323. trace=event_data["contexts"]["trace"]["trace_id"], span="bc" * 8
  324. )
  325. child_event["event_id"] = "b" * 32
  326. child_event["contexts"]["trace"]["parent_span_id"] = event_data["spans"][4]["span_id"]
  327. child_event["transaction"] = "z-child-transaction"
  328. child_event["spans"] = child_event["spans"][0:3]
  329. self.store_event(data=child_event, project_id=self.project.id, assert_no_errors=True)
  330. with self.feature(FEATURE_NAMES):
  331. # Get the list page
  332. self.browser.get(self.result_path + "?" + transactions_query())
  333. self.wait_until_loaded()
  334. # Open the stack
  335. self.browser.elements('[data-test-id="open-group"]')[0].click()
  336. self.wait_until_loaded()
  337. # View Event
  338. self.browser.elements('[data-test-id="view-event"]')[0].click()
  339. self.wait_until_loaded()
  340. self.browser.snapshot("events-v2 - transactions event with auto-grouped spans")
  341. # Expand auto-grouped spans
  342. self.browser.elements('[data-test-id="span-row"]')[4].click()
  343. # Open a span detail so we can check the search by trace link.
  344. # Click on the 6th one as a missing instrumentation span is inserted.
  345. self.browser.elements('[data-test-id="span-row"]')[6].click()
  346. # Wait until the child event loads.
  347. child_button = '[data-test-id="view-child-transaction"]'
  348. self.browser.wait_until(child_button)
  349. self.browser.snapshot("events-v2 - transactions event detail view")
  350. # Click on the child transaction.
  351. self.browser.click(child_button)
  352. self.wait_until_loaded()
  353. @patch("django.utils.timezone.now")
  354. def test_transaction_event_detail_view_ops_filtering(self, mock_now):
  355. mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
  356. event_data = generate_transaction(trace="a" * 32, span="ab" * 8)
  357. self.store_event(data=event_data, project_id=self.project.id, assert_no_errors=True)
  358. with self.feature(FEATURE_NAMES):
  359. # Get the list page
  360. self.browser.get(self.result_path + "?" + transactions_query())
  361. self.wait_until_loaded()
  362. # Open the stack
  363. self.browser.elements('[data-test-id="open-group"]')[0].click()
  364. self.wait_until_loaded()
  365. # View Event
  366. self.browser.elements('[data-test-id="view-event"]')[0].click()
  367. self.wait_until_loaded()
  368. # Interact with ops filter dropdown
  369. self.browser.elements('[data-test-id="filter-button"]')[0].click()
  370. # select all ops
  371. self.browser.elements(
  372. '[data-test-id="op-filter-dropdown"] [data-test-id="checkbox-fancy"]'
  373. )[0].click()
  374. # un-select django.middleware
  375. self.browser.elements(
  376. '[data-test-id="op-filter-dropdown"] [data-test-id="checkbox-fancy"]'
  377. )[1].click()
  378. self.browser.snapshot("events-v2 - transactions event detail view - ops filtering")
  379. def test_create_saved_query(self):
  380. # Simulate a custom query
  381. query = {"field": ["project.id", "count()"], "query": "event.type:error"}
  382. query_name = "A new custom query"
  383. with self.feature(FEATURE_NAMES):
  384. # Go directly to the query builder view
  385. self.browser.get(self.result_path + "?" + urlencode(query, doseq=True))
  386. self.wait_until_loaded()
  387. # Open the save as drawer
  388. self.browser.element('[aria-label="Save as"]').click()
  389. # Fill out name and submit form.
  390. self.browser.element('input[name="query_name"]').send_keys(query_name)
  391. self.browser.element('[aria-label="Save for Org"]').click()
  392. self.browser.wait_until(f'[data-test-id="discover2-query-name-{query_name}"]')
  393. # Page title should update.
  394. editable_text_label = self.browser.element('[data-test-id="editable-text-label"]').text
  395. assert editable_text_label == query_name
  396. # Saved query should exist.
  397. assert DiscoverSavedQuery.objects.filter(name=query_name).exists()
  398. def test_view_and_rename_saved_query(self):
  399. # Create saved query to rename
  400. query = DiscoverSavedQuery.objects.create(
  401. name="Custom query",
  402. organization=self.org,
  403. version=2,
  404. query={"fields": ["title", "project.id", "count()"], "query": "event.type:error"},
  405. )
  406. with self.feature(FEATURE_NAMES):
  407. # View the query list
  408. self.browser.get(self.landing_path)
  409. self.wait_until_loaded()
  410. # Look at the results for our query.
  411. self.browser.element(f'[data-test-id="card-{query.name}"]').click()
  412. self.wait_until_loaded()
  413. self.browser.element('[data-test-id="editable-text-label"]').click()
  414. self.browser.wait_until('[data-test-id="editable-text-input"]')
  415. editable_text_input = self.browser.element('[data-test-id="editable-text-input"] input')
  416. editable_text_input.click()
  417. editable_text_input.send_keys(Keys.END + "updated!")
  418. # Move focus somewhere else to trigger a blur and update the query
  419. self.browser.element("table").click()
  420. self.browser.wait_until('[data-test-id="editable-text-label"]')
  421. new_name = "Custom queryupdated!"
  422. # new_card_selector = f'div[name="discover2-query-name"][value="{new_name}"]'
  423. # self.browser.wait_until(new_card_selector)
  424. self.browser.wait_until(f'[data-test-id="discover2-query-name-{new_name}"]')
  425. # Assert the name was updated.
  426. assert DiscoverSavedQuery.objects.filter(name=new_name).exists()
  427. def test_delete_saved_query(self):
  428. # Create saved query with ORM
  429. query = DiscoverSavedQuery.objects.create(
  430. name="Custom query",
  431. organization=self.org,
  432. version=2,
  433. query={"fields": ["title", "project.id", "count()"], "query": "event.type:error"},
  434. )
  435. with self.feature(FEATURE_NAMES):
  436. # View the query list
  437. self.browser.get(self.landing_path)
  438. self.wait_until_loaded()
  439. # Get the card with the new query
  440. card_selector = f'[data-test-id="card-{query.name}"]'
  441. card = self.browser.element(card_selector)
  442. # Open the context menu
  443. card.find_element_by_css_selector('[data-test-id="menu-trigger"]').click()
  444. # Delete the query
  445. card.find_element_by_css_selector('[data-test-id="delete"]').click()
  446. # Wait for card to clear
  447. self.browser.wait_until_not(card_selector)
  448. assert DiscoverSavedQuery.objects.filter(name=query.name).exists() is False
  449. def test_duplicate_query(self):
  450. # Create saved query with ORM
  451. query = DiscoverSavedQuery.objects.create(
  452. name="Custom query",
  453. organization=self.org,
  454. version=2,
  455. query={"fields": ["title", "project.id", "count()"], "query": "event.type:error"},
  456. )
  457. with self.feature(FEATURE_NAMES):
  458. # View the query list
  459. self.browser.get(self.landing_path)
  460. self.wait_until_loaded()
  461. # Get the card with the new query
  462. card_selector = f'[data-test-id="card-{query.name}"]'
  463. card = self.browser.element(card_selector)
  464. # Open the context menu, and duplicate
  465. card.find_element_by_css_selector('[data-test-id="menu-trigger"]').click()
  466. card.find_element_by_css_selector('[data-test-id="duplicate"]').click()
  467. duplicate_name = f"{query.name} copy"
  468. # Reload the page
  469. self.browser.get(self.landing_path)
  470. # Wait for new element to show up.
  471. self.browser.element(f'[data-test-id="card-{duplicate_name}"]')
  472. # Assert the new query exists and has 'copy' added to the name.
  473. assert DiscoverSavedQuery.objects.filter(name=duplicate_name).exists()
  474. @pytest.mark.skip(reason="causing timeouts in github actions and travis")
  475. @patch("django.utils.timezone.now")
  476. def test_drilldown_result(self, mock_now):
  477. now = before_now().replace(tzinfo=pytz.utc)
  478. mock_now.return_value = now
  479. min_ago = iso_format(now - timedelta(minutes=1))
  480. events = (
  481. ("a" * 32, "oh no", "group-1"),
  482. ("b" * 32, "oh no", "group-1"),
  483. ("c" * 32, "this is bad", "group-2"),
  484. )
  485. for event in events:
  486. self.store_event(
  487. data={
  488. "event_id": event[0],
  489. "message": event[1],
  490. "timestamp": min_ago,
  491. "fingerprint": [event[2]],
  492. "type": "error",
  493. },
  494. project_id=self.project.id,
  495. )
  496. query = {"field": ["message", "project", "count()"], "query": "event.type:error"}
  497. with self.feature(FEATURE_NAMES):
  498. # Go directly to the query builder view
  499. self.browser.get(self.result_path + "?" + urlencode(query, doseq=True))
  500. self.wait_until_loaded()
  501. # Click the first drilldown
  502. self.browser.element('[data-test-id="expand-count"]').click()
  503. self.wait_until_loaded()
  504. assert self.browser.element_exists_by_test_id("grid-editable"), "table should exist."
  505. headers = self.browser.elements('[data-test-id="grid-editable"] thead th')
  506. expected = ["", "MESSAGE", "PROJECT", "ID"]
  507. actual = [header.text for header in headers]
  508. assert expected == actual
  509. @pytest.mark.skip(reason="not done")
  510. @patch("django.utils.timezone.now")
  511. def test_usage(self, mock_now):
  512. mock_now.return_value = before_now().replace(tzinfo=pytz.utc)
  513. # TODO: load events
  514. # go to landing
  515. # go to a precanned query
  516. # save query 1
  517. # add environment column
  518. # update query
  519. # add condition from facet map
  520. # delete a column
  521. # click and drag a column
  522. # save as query 2
  523. # load save query 1
  524. # sort column
  525. # update query
  526. # delete save query 1