test_replay_detail.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. from datetime import datetime, timedelta
  2. from uuid import uuid4
  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", "organizations:session-replay-ui"]
  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 = uuid4().hex
  26. seq1_timestamp = datetime.now() - timedelta(seconds=52)
  27. seq2_timestamp = datetime.now() - timedelta(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. 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. self.browser.snapshot("replay detail")