-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: no varying in snapshot test (#21009)
* fix: no varying in snapshot test * can we snapshot CH while we're here * Update query snapshots * Update query snapshots * need to freeze time for CH now * Update query snapshots * ah, that's why we don't snapshot CH in this test * Update query snapshots * wat * Update query snapshots --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
711b282
commit a8d3ba9
Showing
2 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,9 @@ def create_snapshot( | |
) | ||
|
||
@snapshot_postgres_queries | ||
# we can't take snapshots of the CH queries | ||
# because we use `now()` in the CH queries which don't know about any frozen time | ||
# @snapshot_clickhouse_queries | ||
def test_get_session_recordings(self): | ||
twelve_distinct_ids: List[str] = [f"user_one_{i}" for i in range(12)] | ||
|
||
|
@@ -78,8 +81,8 @@ def test_get_session_recordings(self): | |
base_time = (now() - relativedelta(days=1)).replace(microsecond=0) | ||
session_id_one = f"test_get_session_recordings-1" | ||
self.create_snapshot("user_one_0", session_id_one, base_time) | ||
self.create_snapshot("user_one_1", session_id_one, base_time + relativedelta(seconds=10)) | ||
self.create_snapshot("user_one_2", session_id_one, base_time + relativedelta(seconds=30)) | ||
self.create_snapshot("user_one_0", session_id_one, base_time + relativedelta(seconds=10)) | ||
self.create_snapshot("user_one_0", session_id_one, base_time + relativedelta(seconds=30)) | ||
session_id_two = f"test_get_session_recordings-2" | ||
self.create_snapshot("user2", session_id_two, base_time + relativedelta(seconds=20)) | ||
|
||
|
@@ -125,6 +128,44 @@ def test_get_session_recordings(self): | |
assert results_[0]["distinct_id"] == "user2" | ||
assert results_[1]["distinct_id"] in twelve_distinct_ids | ||
|
||
def test_can_list_recordings_even_when_the_person_has_multiple_distinct_ids(self): | ||
# almost duplicate of test_get_session_recordings above | ||
# but if we have multiple distinct ids on a recording the snapshot | ||
# varies which makes the snapshot useless | ||
twelve_distinct_ids: List[str] = [f"user_one_{i}" for i in range(12)] | ||
|
||
Person.objects.create( | ||
team=self.team, | ||
distinct_ids=twelve_distinct_ids, # that's too many! we should limit them | ||
properties={"$some_prop": "something", "email": "[email protected]"}, | ||
) | ||
Person.objects.create( | ||
team=self.team, | ||
distinct_ids=["user2"], | ||
properties={"$some_prop": "something", "email": "[email protected]"}, | ||
) | ||
|
||
base_time = (now() - relativedelta(days=1)).replace(microsecond=0) | ||
session_id_one = f"test_get_session_recordings-1" | ||
self.create_snapshot("user_one_0", session_id_one, base_time) | ||
self.create_snapshot("user_one_1", session_id_one, base_time + relativedelta(seconds=10)) | ||
self.create_snapshot("user_one_2", session_id_one, base_time + relativedelta(seconds=30)) | ||
session_id_two = f"test_get_session_recordings-2" | ||
self.create_snapshot("user2", session_id_two, base_time + relativedelta(seconds=20)) | ||
|
||
response = self.client.get(f"/api/projects/{self.team.id}/session_recordings") | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
response_data = response.json() | ||
|
||
results_ = response_data["results"] | ||
assert results_ is not None | ||
# detailed assertion is in the other test | ||
assert len(results_) == 2 | ||
|
||
# user distinct id varies because we're adding more than one | ||
assert results_[0]["distinct_id"] == "user2" | ||
assert results_[1]["distinct_id"] in twelve_distinct_ids | ||
|
||
@patch("posthog.session_recordings.session_recording_api.SessionRecordingListFromReplaySummary") | ||
def test_console_log_filters_are_correctly_passed_to_listing(self, mock_summary_lister): | ||
mock_summary_lister.return_value.run.return_value = ([], False) | ||
|