: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(actions): show action match groups in rebuild filter "All" tab preview (#66283)
Vasco de Krijger9042199acd03
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/preview/ActionMatchGroups.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/preview/ActionMatchGroups.test.tsxnew file mode 100644index 000000000000..c5d2578cce43--- /dev/null+++ b/frontend/src/lib/components/TaxonomicFilter/menu/preview/ActionMatchGroups.test.tsx@@ -0,0 +1,61 @@+import '@testing-library/jest-dom'++import { cleanup, render, screen, waitFor } from '@testing-library/react'+import { Provider } from 'kea'++import { useMocks } from '~/mocks/jest'+import { actionsModel } from '~/models/actionsModel'+import { initKeaTests } from '~/test/init'++import { ActionMatchGroups } from './ActionMatchGroups'++const TEST_ACTION = {+ id: 282580,+ name: 'Test action',+ steps: [+ {+ event: '$pageview',+ properties: [{ key: '$os_version', value: '14.4.1', operator: 'semver_gte' }],+ },+ ],+}++function renderItem(item: any): ReturnType<typeof render> {+ return render(+ <Provider>+ <ActionMatchGroups item={item} />+ </Provider>+ )+}++describe('ActionMatchGroups', () => {+ beforeEach(async () => {+ useMocks({ get: { '/api/projects/:team_id/actions/': { results: [TEST_ACTION], count: 1 } } })+ initKeaTests()+ actionsModel.mount()+ await waitFor(() => {+ if (actionsModel.values.actions.length !== 1) {+ throw new Error('actions not loaded yet')+ }+ })+ })++ afterEach(() => cleanup())++ // Both an item that already carries `steps` and a lightweight `{ id, name }` shim (the+ // committed selection on the "All" surface) must render the match groups — the bug was+ // that the shim, lacking `steps`, produced a blank preview.+ it.each([+ ['an item that already carries steps', TEST_ACTION],+ ['a step-less {id,name} shim hydrated from actionsModel', { id: TEST_ACTION.id, name: TEST_ACTION.name }],+ ])('renders match groups for %s', (_label, item) => {+ renderItem(item)+ expect(screen.getByText('$os_version')).toBeInTheDocument()+ expect(screen.getByText('greater than or equal (semver)')).toBeInTheDocument()+ })++ it('renders nothing for a step-less item with no matching action', () => {+ const { container } = renderItem({ id: 999999, name: 'unknown' })+ expect(container).toBeEmptyDOMElement()+ })+})diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/preview/ActionMatchGroups.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/preview/ActionMatchGroups.tsxindex 3b1a186d6fa9..cebab49c907d 100644--- a/frontend/src/lib/components/TaxonomicFilter/menu/preview/ActionMatchGroups.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/menu/preview/ActionMatchGroups.tsx@@ -4,16 +4,29 @@* Quill-styled port of the legacy `ActionPopoverInfo` so we don't pull* in the kea-coupled `DefinitionPopover` primitives.*/+import { useValues } from 'kea'+import { Separator } from '@posthog/quill'import { genericOperatorToHumanName, propertyValueToHumanName } from 'lib/components/DefinitionPopover/utils'+import { actionsModel } from '~/models/actionsModel'import { ActionStepType, ActionType } from '~/types'import { TaxonomicDefinitionTypes } from '../../types'export function ActionMatchGroups({ item }: { item: TaxonomicDefinitionTypes }): JSX.Element | null {- const action = item as ActionType+ const { actionsById } = useValues(actionsModel)+ // The highlighted entry can be a lightweight `{ id, name }` shim — e.g. the+ // committed selection on the "All" surface, when the full action isn't among+ // the rows currently shown — which carries no `steps`. Hydrate it from+ // actionsModel so the match groups render instead of silently nothing.+ const partial = item as Partial<ActionType>+ const action: ActionType | undefined = Array.isArray(partial.steps)+ ? (partial as ActionType)+ : partial.id != null+ ? actionsById[partial.id]+ : undefinedif (!action || !Array.isArray(action.steps) || action.steps.length === 0) {return null}