Skip to content

Commit

Permalink
Add test for hash when dashboard filters are applied
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Oct 19, 2023
1 parent eddb21f commit 8b3e185
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions posthog/models/test/test_insight_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,26 @@ def test_dashboard_with_query_insight_and_filters(self) -> None:
data = query_insight.dashboard_query(dashboard)
actual = data["source"]["filters"]
assert expected_filters == actual

def test_query_hash_varies_with_dashboard_filters(self) -> None:
query_insight = Insight.objects.create(
team=self.team,
query={
"kind": "DataTableNode",
"source": {
"filters": {"dateRange": {"date_from": "-14d", "date_to": "-7d"}},
"kind": "HogQLQuery",
"modifiers": None,
"query": "select * from events where {filters}",
"response": None,
"values": None,
},
},
)

dashboard = Dashboard.objects.create(team=self.team, filters={"date_from": "-4d", "date_to": "-3d"})

hash_sans_dashboard = generate_insight_cache_key(query_insight, None)
hash_with_dashboard = generate_insight_cache_key(query_insight, dashboard)

assert hash_sans_dashboard != hash_with_dashboard

0 comments on commit 8b3e185

Please sign in to comment.