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(insights): await axis-title overlay in TrendsLineChart test (#70228)

Paul D'Ambrace9cb9f2a0ce
diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
index 0582b2c2b208..78ec287047bf 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
@@ -350,8 +350,13 @@ describe('TrendsLineChart', () => {
})
await screen.findByLabelText(/chart with/i)
- expect(getHogChart().xAxisLabel()).toBe('Signup date')
- expect(getHogChart().yAxisLabel()).toBe('Unique users')
+ // Axis titles are a layout-dependent overlay that commits a tick after the
+ // chart's aria-label appears (like referenceLines/valueLabels below), so read
+ // them through waitFor rather than synchronously.
+ await waitFor(() => {
+ expect(getHogChart().xAxisLabel()).toBe('Signup date')
+ expect(getHogChart().yAxisLabel()).toBe('Unique users')
+ })
})
})