test_replay_detail.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. from datetime import datetime, timedelta
  2. from uuid import uuid4
  3. import pytest
  4. from sentry.replays.testutils import (
  5. mock_replay,
  6. mock_rrweb_div_helloworld,
  7. mock_segment_console,
  8. mock_segment_fullsnapshot,
  9. mock_segment_init,
  10. mock_segment_nagivation,
  11. )
  12. from sentry.testutils import ReplaysAcceptanceTestCase
  13. FEATURE_NAME = ["organizations:session-replay", "organizations:session-replay-ui"]
  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 = uuid4().hex
  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. self.browser.snapshot("replay detail not found")
  68. @pytest.mark.skip(reason="flaky: https://github.com/getsentry/sentry/issues/42263")
  69. def test_simple(self):
  70. with self.feature(FEATURE_NAME):
  71. self.browser.get(self.path)
  72. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  73. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  74. self.browser.snapshot("replay detail")