Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(tests): stop replay listing tests leaking materialized columns (#69430)

Paul D'Ambra651ed891a4be
diff --git a/posthog/session_recordings/queries/test/listing_recordings/test_session_recording_list_from_query.py b/posthog/session_recordings/queries/test/listing_recordings/test_session_recording_list_from_query.py
index b807455a51f5..94e05964aee8 100644
--- a/posthog/session_recordings/queries/test/listing_recordings/test_session_recording_list_from_query.py
+++ b/posthog/session_recordings/queries/test/listing_recordings/test_session_recording_list_from_query.py
@@ -13,6 +13,7 @@ from posthog.test.base import (
_create_event,
_create_person,
also_test_with_materialized_columns,
+ cleanup_materialized_columns,
flush_persons_and_events,
snapshot_clickhouse_queries,
)
@@ -4668,6 +4669,9 @@ class TestClickhouseSessionRecordingsListFromQuery(ClickhouseTestMixin, APIBaseT
):
assert self.team.person_on_events_mode == expected_poe_mode
materialize("events", "rgInternal", table_column="person_properties")
+ # Materialized directly (not via the decorator), so drop it after the test — leaked
+ # columns break later runs' query snapshots when the ClickHouse schema is reused.
+ self.addCleanup(cleanup_materialized_columns)
query = RecordingsQuery.model_validate(
{
@@ -4735,6 +4739,9 @@ class TestClickhouseSessionRecordingsListFromQuery(ClickhouseTestMixin, APIBaseT
if materialize_person_props:
materialize("events", "email", table_column="person_properties")
materialize("person", "email")
+ # Materialized directly (not via the decorator), so drop them after the test — leaked
+ # columns break later runs' query snapshots when the ClickHouse schema is reused.
+ self.addCleanup(cleanup_materialized_columns)
@retry(wait=wait_exponential(multiplier=0.5, min=0.5, max=5), stop=stop_after_attempt(10))
def wait_for_materialized_columns():
@@ -4846,6 +4853,9 @@ class TestClickhouseSessionRecordingsListFromQuery(ClickhouseTestMixin, APIBaseT
if materialize_person_props:
materialize("events", "email", table_column="person_properties")
materialize("person", "email")
+ # Materialized directly (not via the decorator), so drop them after the test — leaked
+ # columns break later runs' query snapshots when the ClickHouse schema is reused.
+ self.addCleanup(cleanup_materialized_columns)
mat_mock = (
nullcontext()