test_replay_detail.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. self.browser.snapshot("replay detail not found")
  69. @pytest.mark.skip(reason="flaky: https://github.com/getsentry/sentry/issues/42263")
  70. def test_simple(self):
  71. with self.feature(FEATURE_NAME):
  72. self.browser.get(self.path)
  73. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  74. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  75. self.browser.snapshot("replay detail")
  76. def test_dom_events_tab(self):
  77. with self.feature(FEATURE_NAME):
  78. self.browser.get(self.path)
  79. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  80. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  81. self.browser.click('[data-test-id="replay-details-dom-btn"]')
  82. self.browser.wait_until_test_id("replay-details-dom-events-tab")
  83. self.browser.snapshot("replay details - dom events tab")
  84. def test_console_tab(self):
  85. with self.feature(FEATURE_NAME):
  86. self.browser.get(self.path)
  87. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  88. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  89. self.browser.click('[data-test-id="replay-details-console-btn"]')
  90. self.browser.wait_until_test_id("replay-details-console-tab")
  91. self.browser.snapshot("replay details - console tab")
  92. def test_network_tab(self):
  93. with self.feature(FEATURE_NAME):
  94. self.browser.get(self.path)
  95. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  96. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  97. self.browser.click('[data-test-id="replay-details-network-btn"]')
  98. self.browser.wait_until_test_id("replay-details-network-tab")
  99. self.browser.snapshot("replay details - network tab")
  100. def test_memory_tab(self):
  101. with self.feature(FEATURE_NAME):
  102. self.browser.get(self.path)
  103. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  104. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  105. self.browser.click('[data-test-id="replay-details-memory-btn"]')
  106. self.browser.wait_until_test_id("replay-details-memory-tab")
  107. self.browser.snapshot("replay details - memory tab")
  108. def test_errors_tab(self):
  109. with self.feature(FEATURE_NAME):
  110. self.browser.get(self.path)
  111. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  112. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  113. self.browser.click('[data-test-id="replay-details-errors-btn"]')
  114. self.browser.wait_until_test_id("replay-details-errors-tab")
  115. self.browser.snapshot("replay details - errors tab")
  116. def test_trace_tab(self):
  117. with self.feature(FEATURE_NAME):
  118. self.browser.get(self.path)
  119. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  120. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  121. self.browser.click('[data-test-id="replay-details-trace-btn"]')
  122. self.browser.wait_until_test_id("replay-details-trace-tab")
  123. self.browser.snapshot("replay details - trace tab")