test_replay_detail.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. from datetime import datetime, timedelta
  2. import pytest
  3. from sentry.replays.testutils import (
  4. mock_replay,
  5. mock_rrweb_div_helloworld,
  6. mock_segment_console,
  7. mock_segment_fullsnapshot,
  8. mock_segment_init,
  9. mock_segment_nagivation,
  10. )
  11. from sentry.testutils.cases import ReplaysAcceptanceTestCase
  12. from sentry.testutils.silo import no_silo_test
  13. FEATURE_NAME = ["organizations:session-replay", "organizations:performance-view"]
  14. @no_silo_test(stable=True)
  15. class ReplayDetailTest(ReplaysAcceptanceTestCase):
  16. def setUp(self):
  17. super().setUp()
  18. self.user = self.create_user("foo@example.com")
  19. self.org = self.create_organization(name="Rowdy Tiger", owner=None)
  20. self.team = self.create_team(organization=self.org, name="Mariachi Band 1")
  21. self.project = self.create_project(
  22. organization=self.org,
  23. teams=[self.team],
  24. name="Bengal",
  25. )
  26. self.create_member(user=self.user, organization=self.org, role="owner", teams=[self.team])
  27. replay_id = "b58a67446c914f44a4e329763420047b"
  28. seq1_timestamp = datetime.now() - timedelta(minutes=10, seconds=52)
  29. seq2_timestamp = datetime.now() - timedelta(minutes=10, seconds=35)
  30. self.store_replays(
  31. [
  32. mock_replay(
  33. seq1_timestamp,
  34. self.project.id,
  35. replay_id,
  36. segment_id=0,
  37. urls=[
  38. "http://localhost/",
  39. "http://localhost/home/",
  40. "http://localhost/profile/",
  41. ],
  42. ),
  43. mock_replay(seq2_timestamp, self.project.id, replay_id, segment_id=1),
  44. ]
  45. )
  46. segments = [
  47. mock_segment_init(seq2_timestamp),
  48. mock_segment_fullsnapshot(seq2_timestamp, [mock_rrweb_div_helloworld()]),
  49. mock_segment_console(seq2_timestamp),
  50. mock_segment_nagivation(
  51. seq2_timestamp + timedelta(seconds=1), hrefFrom="/", hrefTo="/home/"
  52. ),
  53. mock_segment_nagivation(
  54. seq2_timestamp + timedelta(seconds=2), hrefFrom="/home/", hrefTo="/profile/"
  55. ),
  56. ]
  57. for (segment_id, segment) in enumerate(segments):
  58. self.store_replay_segments(replay_id, self.project.id, segment_id, segment)
  59. self.login_as(self.user)
  60. slug = f"{self.project.slug}:{replay_id}"
  61. self.path = f"/organizations/{self.org.slug}/replays/{slug}/"
  62. def test_not_found(self):
  63. with self.feature(FEATURE_NAME):
  64. slug = f"{self.project.slug}:abcdef"
  65. self.path = f"/organizations/{self.org.slug}/replays/{slug}/"
  66. self.browser.get(self.path)
  67. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  68. @pytest.mark.skip(reason="flaky: https://github.com/getsentry/sentry/issues/42263")
  69. def test_simple(self):
  70. with self.feature(FEATURE_NAME):
  71. self.browser.get(self.path)
  72. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  73. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  74. def test_dom_events_tab(self):
  75. with self.feature(FEATURE_NAME):
  76. self.browser.get(self.path)
  77. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  78. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  79. self.browser.click('[data-test-id="replay-details-dom-btn"]')
  80. self.browser.wait_until_test_id("replay-details-dom-events-tab")
  81. def test_console_tab(self):
  82. with self.feature(FEATURE_NAME):
  83. self.browser.get(self.path)
  84. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  85. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  86. self.browser.click('[data-test-id="replay-details-console-btn"]')
  87. self.browser.wait_until_test_id("replay-details-console-tab")
  88. def test_network_tab(self):
  89. with self.feature(FEATURE_NAME):
  90. self.browser.get(self.path)
  91. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  92. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  93. self.browser.click('[data-test-id="replay-details-network-btn"]')
  94. self.browser.wait_until_test_id("replay-details-network-tab")
  95. def test_memory_tab(self):
  96. with self.feature(FEATURE_NAME):
  97. self.browser.get(self.path)
  98. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  99. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  100. self.browser.click('[data-test-id="replay-details-memory-btn"]')
  101. self.browser.wait_until_test_id("replay-details-memory-tab")
  102. def test_errors_tab(self):
  103. with self.feature(FEATURE_NAME):
  104. self.browser.get(self.path)
  105. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  106. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  107. self.browser.click('[data-test-id="replay-details-errors-btn"]')
  108. self.browser.wait_until_test_id("replay-details-errors-tab")
  109. def test_trace_tab(self):
  110. with self.feature(FEATURE_NAME):
  111. self.browser.get(self.path)
  112. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  113. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  114. self.browser.click('[data-test-id="replay-details-trace-btn"]')
  115. self.browser.wait_until_test_id("replay-details-trace-tab")