test_replay_detail.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 import ReplaysAcceptanceTestCase
  12. FEATURE_NAME = ["organizations:session-replay"]
  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")