test_replay_detail.py 6.1 KB

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