: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(test): resolve flaky hog-charts tooltip tests (#59052)
mendral-app[bot]7bcf4d461ba7
diff --git a/frontend/src/lib/hog-charts/testing/tooltip.ts b/frontend/src/lib/hog-charts/testing/tooltip.tsindex 3e83f1f25432..631fb0eb4590 100644--- a/frontend/src/lib/hog-charts/testing/tooltip.ts+++ b/frontend/src/lib/hog-charts/testing/tooltip.ts@@ -31,6 +31,9 @@ export function getHogChartTooltip(): HTMLElement | null {/** Wait until a chart tooltip is present in the document and return it. */export async function waitForHogChartTooltip(timeout = 3000): Promise<HTMLElement> {+ // Flush pending microtasks so React portal commits complete before polling.+ await new Promise((r) => setTimeout(r, 0))+let tooltip!: HTMLElementawait waitFor(() => {@@ -40,7 +43,7 @@ export async function waitForHogChartTooltip(timeout = 3000): Promise<HTMLElemen}tooltip = el},- { timeout }+ { timeout, interval: 10 })return tooltip}diff --git a/frontend/src/scenes/trends/viz/trends-line-chart/TrendsLineChart.test.tsx b/frontend/src/scenes/trends/viz/trends-line-chart/TrendsLineChart.test.tsxindex ee899f68ddf3..d9ca9055f218 100644--- a/frontend/src/scenes/trends/viz/trends-line-chart/TrendsLineChart.test.tsx+++ b/frontend/src/scenes/trends/viz/trends-line-chart/TrendsLineChart.test.tsx@@ -3,7 +3,7 @@ import '@testing-library/jest-dom'import { cleanup, fireEvent, screen, waitFor } from '@testing-library/react'import { FEATURE_FLAGS } from 'lib/constants'-import { setupJsdom } from 'lib/hog-charts/testing'+import { setupJsdom, setupSyncRaf } from 'lib/hog-charts/testing'import { NodeKind } from '~/queries/schema/schema-general'import {@@ -19,13 +19,16 @@ import { buildAnnotation } from '~/test/insight-testing/test-data'import { AnnotationScope, ChartDisplayType } from '~/types'let cleanupJsdom: () => void+let cleanupRaf: () => voidbeforeEach(() => {cleanupJsdom = setupJsdom()+ cleanupRaf = setupSyncRaf()})afterEach(() => {personsModal.cleanupAll()+ cleanupRaf()cleanupJsdom()cleanup()})