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(test): wait for DataVisualization canvas in play fn to prevent flaky timeout (#69464)

mendral-app[bot]c86b49e57f22
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
index d91cc670b6a5..7ecfdee54473 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
@@ -1,5 +1,5 @@
import { Meta, StoryObj } from '@storybook/react'
-import { within } from '@testing-library/dom'
+import { waitFor, within } from '@testing-library/dom'
import userEvent from '@testing-library/user-event'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -406,5 +406,16 @@ export const RowExpandedUsagePopulated: Story = {
),
play: async ({ canvasElement }) => {
await expandAndOpenTab(canvasElement, 'Usage')
+ // Wait for the chart canvas to render before handing off to the snapshot.
+ // The play function timeout (~60s) is much more generous than waitForSelector (10s),
+ // so this prevents flaky timeouts under CI load.
+ await waitFor(
+ () => {
+ if (!canvasElement.querySelector('.DataVisualization canvas')) {
+ throw new Error('DataVisualization canvas not yet rendered')
+ }
+ },
+ { timeout: 30000, interval: 500 }
+ )
},
}