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(taxonomic-filter): make headless filter stories more deterministic (#60831)

Robbie2b3dfbef39ab
diff --git a/frontend/src/lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator.ts b/frontend/src/lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator.ts
index fc9fec0574a1..4f208ba34643 100644
--- a/frontend/src/lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator.ts
@@ -10,32 +10,17 @@ export const taxonomicFilterMocksDecorator = mswDecorator({
{ id: 3, name: 'height', count: 3 },
{ id: 4, name: '$browser', count: 4 },
],
- '/api/projects/:team_id/property_definitions': [
- {
- name: 'file_count',
- count: 205,
- },
- {
- name: 'industry',
- count: 205,
- },
- {
- name: 'name',
- count: 205,
- },
- {
- name: 'plan',
- count: 205,
- },
- {
- name: 'team_size',
- count: 205,
- },
- {
- name: 'used_mb',
- count: 205,
- },
- ],
+ '/api/projects/:team_id/property_definitions': {
+ count: 6,
+ results: [
+ { id: 'file_count', name: 'file_count', count: 205 },
+ { id: 'industry', name: 'industry', count: 205 },
+ { id: 'name', name: 'name', count: 205 },
+ { id: 'plan', name: 'plan', count: 205 },
+ { id: 'team_size', name: 'team_size', count: 205 },
+ { id: 'used_mb', name: 'used_mb', count: 205 },
+ ],
+ },
'/api/projects/:team_id/event_definitions': [
{
id: 'a',
diff --git a/frontend/src/lib/components/TaxonomicFilter/headless/TaxonomicFilterHeadless.stories.tsx b/frontend/src/lib/components/TaxonomicFilter/headless/TaxonomicFilterHeadless.stories.tsx
index b19c558706b1..f383e78bb58f 100644
--- a/frontend/src/lib/components/TaxonomicFilter/headless/TaxonomicFilterHeadless.stories.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/headless/TaxonomicFilterHeadless.stories.tsx
@@ -6,6 +6,7 @@ import { taxonomicFilterMocksDecorator } from 'lib/components/TaxonomicFilter/__
import { actionsModel } from '~/models/actionsModel'
+import { __clearTaxonomicResourceCache } from '../hooks/useTaxonomicResource'
import { TaxonomicFilterGroup, TaxonomicFilterGroupType, TaxonomicFilterValue } from '../types'
import { TaxonomicFilterHeadless } from './index'
@@ -34,6 +35,10 @@ interface ContainerArgs {
}
function Container({ taxonomicGroupTypes, initialSearchQuery, suggestedFiltersLabel }: ContainerArgs): JSX.Element {
+ useState(() => {
+ __clearTaxonomicResourceCache()
+ return null
+ })
useMountedLogic(actionsModel)
const [lastPick, setLastPick] = useState<{
group: string