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): deflake FunnelLeftToRightBreakdownEdit snapshot (#59749)

mendral-app[bot]1609f36c300c
diff --git a/frontend/src/scenes/insights/Funnels.stories.tsx b/frontend/src/scenes/insights/Funnels.stories.tsx
index ce88293cfa14..f88e2da66281 100644
--- a/frontend/src/scenes/insights/Funnels.stories.tsx
+++ b/frontend/src/scenes/insights/Funnels.stories.tsx
@@ -42,6 +42,21 @@ export default meta
// Funnels
+const waitForFunnelToStabilize: NonNullable<Story['play']> = async ({ canvasElement }) => {
+ let lastHeight = 0
+ await waitFor(
+ () => {
+ const funnelContainer = canvasElement.querySelector('[data-attr=funnel-bar-vertical]')
+ const currentHeight = funnelContainer ? funnelContainer.getBoundingClientRect().height : 0
+ if (currentHeight === 0 || currentHeight !== lastHeight) {
+ lastHeight = currentHeight
+ throw new Error('funnel height not yet stable')
+ }
+ },
+ { timeout: 3000, interval: 200 }
+ )
+}
+
// FLAP!
// export const FunnelLeftToRight: Story = createInsightStory(
// require('../../mocks/fixtures/api/projects/team_id/insights/funnelLeftToRight.json')
@@ -73,6 +88,7 @@ export const FunnelLeftToRightBreakdownEdit: Story = createInsightStory(
FunnelLeftToRightBreakdownEdit.parameters = {
testOptions: { waitForSelector: ['[data-attr=funnel-bar-vertical] .StepBar', '.PayGateMini'] },
}
+FunnelLeftToRightBreakdownEdit.play = waitForFunnelToStabilize
export const FunnelTopToBottom: Story = createInsightStory(
require('../../mocks/fixtures/api/projects/team_id/insights/funnelTopToBottom.json')
)
@@ -148,20 +164,6 @@ export const FunnelLeftToRightEditViewports: Story = createInsightStory(
require('../../mocks/fixtures/api/projects/team_id/insights/funnelLeftToRight.json'),
'edit'
)
-const waitForFunnelToStabilize: NonNullable<Story['play']> = async ({ canvasElement }) => {
- let lastHeight = 0
- await waitFor(
- () => {
- const funnelContainer = canvasElement.querySelector('[data-attr=funnel-bar-vertical]')
- const currentHeight = funnelContainer ? funnelContainer.getBoundingClientRect().height : 0
- if (currentHeight === 0 || currentHeight !== lastHeight) {
- lastHeight = currentHeight
- throw new Error('funnel height not yet stable')
- }
- },
- { timeout: 3000, interval: 200 }
- )
-}
FunnelLeftToRightEditViewports.parameters = {
testOptions: {
waitForSelector: ['[data-attr=funnel-bar-vertical] .StepBar', '.PayGateMini'],