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(storybook): remove redundant waitForSelector causing flaky VR test (#69984)

mendral-app[bot]d93a86f9741a
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
index 7ecfdee54473..4173d7504a7e 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
@@ -397,7 +397,7 @@ export const RowExpandedUsagePopulated: Story = {
render: () => <App />,
parameters: {
testOptions: {
- waitForSelector: ['[data-attr="accounts-refresh"]', '.DataVisualization canvas'],
+ waitForSelector: ['[data-attr="accounts-refresh"]', '[data-attr="account-expansion"]'],
},
},
decorators: billingTabDecorators(
@@ -406,9 +406,10 @@ 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.
+ // Wait for both the chart canvas AND the sidebar links to be present simultaneously.
+ // The tab switch can trigger a re-render cycle that briefly unmounts the sidebar;
+ // gating on both ensures the snapshot captures a fully settled state.
+ const canvas = within(canvasElement)
await waitFor(
() => {
if (!canvasElement.querySelector('.DataVisualization canvas')) {
@@ -417,5 +418,8 @@ export const RowExpandedUsagePopulated: Story = {
},
{ timeout: 30000, interval: 500 }
)
+ // Re-confirm sidebar links are still rendered after the canvas settled —
+ // guards against the re-fetch race that causes the "Useful links" flicker.
+ await canvas.findByText('Organization', {}, { timeout: 10000 })
},
}