test_replay_detail.py 5.1 KB

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