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.

chore(insights): deflake LongLoading visual-regression story (#74294)

Raúl Negrón-Oterob89f04dcd293
diff --git a/frontend/src/scenes/insights/EmptyStates/EmptyStates.stories.tsx b/frontend/src/scenes/insights/EmptyStates/EmptyStates.stories.tsx
index e6225c53426a..6a4064f171d8 100644
--- a/frontend/src/scenes/insights/EmptyStates/EmptyStates.stories.tsx
+++ b/frontend/src/scenes/insights/EmptyStates/EmptyStates.stories.tsx
@@ -1,15 +1,12 @@
import { Meta, StoryObj } from '@storybook/react'
import { delay, HttpResponse } from 'msw'
-import { useDelayedOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { App } from 'scenes/App'
import { createInsightStory } from 'scenes/insights/__mocks__/createInsightScene'
import { useStorybookMocks } from '~/mocks/browser'
-import { InsightShortId } from '~/types'
import insight from '../../../mocks/fixtures/api/projects/team_id/insights/trendsLine.json'
-import { insightVizDataLogic } from '../insightVizDataLogic'
import funnelOneStep from './funnelOneStep.json'
type Story = StoryObj<{}>
@@ -239,11 +236,6 @@ export const LongLoading: Story = {
},
})
- useDelayedOnMountEffect(() => {
- const logic = insightVizDataLogic.findMounted({ dashboardItemId: insight.short_id as InsightShortId })
- logic?.actions.setTimedOutQueryId('a-uuid-query-id') // Show the suggestions immediately
- })
-
return <App />
},
parameters: {
diff --git a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx
index a1c7cee55c2f..24d90b3d0698 100644
--- a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx
+++ b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx
@@ -425,7 +425,13 @@ export function SlowQuerySuggestions({
}): JSX.Element | null {
const { slowQueryPossibilities } = useValues(insightVizDataLogic(insightProps))
- if (loadingTimeSeconds < SLOW_LOADING_TIME) {
+ // `loadingTimeSeconds` only advances on dataNodeLogic's wall-clock timer, which Storybook has no
+ // way to fast-forward, so a story covering these suggestions would have to sit through
+ // SLOW_LOADING_TIME of real loading before they render. Dropping the threshold in Storybook makes
+ // them a consequence of the insight loading instead of a race against the clock.
+ const slowLoadingTime = inStorybook() || inStorybookTestRunner() ? 0 : SLOW_LOADING_TIME
+
+ if (loadingTimeSeconds < slowLoadingTime) {
return null
}