: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(tests): stabilize flaky StickinessBarChart and FunnelLineChart tests (#61262)
mendral-app[bot]639c8bf53f72
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsxindex f48c3502e9f1..2f2ce790b939 100644--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx@@ -11,7 +11,7 @@ import { AnnotationScope } from '~/types'import { FUNNEL_CONVERSION_SERIES_LABEL } from '../shared/funnelSeriesMeta'-configure({ asyncUtilTimeout: 2000 })+configure({ asyncUtilTimeout: 3000 })ensureJsdom()@@ -119,12 +119,18 @@ describe('FunnelLineChart', () => {})await screen.findByRole('img', { name: /chart with/i })- const lines = getHogChart().referenceLines()- // value→pixel isn't recoverable from the DOM; assert the line is labelled,- // drawn horizontally (across the value axis), and actually positioned.- expect(lines).toEqual([- expect.objectContaining({ label: 'Target', orientation: 'horizontal', position: expect.any(Number) }),- ])+ await waitFor(() => {+ const lines = getHogChart().referenceLines()+ // value→pixel isn't recoverable from the DOM; assert the line is labelled,+ // drawn horizontally (across the value axis), and actually positioned.+ expect(lines).toEqual([+ expect.objectContaining({+ label: 'Target',+ orientation: 'horizontal',+ position: expect.any(Number),+ }),+ ])+ })})})diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsxindex c65990317903..9b68d87633e6 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx+++ b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx@@ -1,6 +1,6 @@import '@testing-library/jest-dom'-import { cleanup, screen, waitFor } from '@testing-library/react'+import { cleanup, configure, screen, waitFor } from '@testing-library/react'import { FEATURE_FLAGS } from 'lib/constants'import { setupJsdom, setupSyncRaf } from 'lib/hog-charts/testing'@@ -9,6 +9,8 @@ import { NodeKind } from '~/queries/schema/schema-general'import { buildStickinessQuery, chart, getHogChart, personsModal, renderInsight } from '~/test/insight-testing'import { ChartDisplayType } from '~/types'+configure({ asyncUtilTimeout: 3000 })+let cleanupJsdom: () => voidlet cleanupRaf: () => void@@ -63,9 +65,11 @@ describe('StickinessBarChart', () => {renderInsight({ query: stickinessBar(), featureFlags: HOG_CHARTS_FLAG })await screen.findByRole('img', { name: /chart with/i })- const ticks = getHogChart().yTicks()- expect(ticks.length).toBeGreaterThan(0)- expect(ticks.every((t) => /%/.test(t))).toBe(true)+ await waitFor(() => {+ const ticks = getHogChart().yTicks()+ expect(ticks.length).toBeGreaterThan(0)+ expect(ticks.every((t) => /%/.test(t))).toBe(true)+ })})it('tooltip: percent value + "stickiness on {interval} {day}" title (not a calendar date)', async () => {