Skip to content

fix(storybook): mock INSIGHTS_ENDPOINT in expanded-row stories to prevent re-render collapse - #70243

Merged
rafaeelaudibert merged 4 commits into
masterfrom
mendral/fix-accounts-tab-vr-flake
Jul 14, 2026
Merged

fix(storybook): mock INSIGHTS_ENDPOINT in expanded-row stories to prevent re-render collapse#70243
rafaeelaudibert merged 4 commits into
masterfrom
mendral/fix-accounts-tab-vr-flake

Conversation

@mendral-app

@mendral-app mendral-app Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix flaky RowExpandedWithNote / RowExpandedUsagePopulated VR tests that time out on [data-attr="account-expansion"] waitForSelector
  • Root cause: AccountNotebooksExpansion eagerly mounts accountBillingLogic (usage + spend), which fires requests to the insights endpoint. Stories without that mock see the unhandled fetch error trigger a React re-render that collapses the expansion row.
  • Add EXPANDED_ROW_DECORATORS_BASE with an empty INSIGHTS_ENDPOINT mock to all affected stories
  • Bump waitForSelectorTimeout from 30s → 60s as a safety net

Fixes the flake seen in PR #70223 and PR #70236 (and ~25 other occurrences across unrelated branches).


Note

Created by Mendral. Tag @mendral-app with feedback or questions.

@mendral-app
mendral-app Bot requested a review from sampennington July 11, 2026 17:00
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 11, 2026 17:00
@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Bundle size — 🔺 +33.5 KiB (+0.1%)

Uncompressed size of every built .js bundle, compared against the base branch.

Total: 64.75 MiB · 🔺 +33.5 KiB (+0.1%)

File Size Δ vs base
render-query/src/render-query/render-query.js 21.25 MiB 🔺 +15.3 KiB (+0.1%)
posthog-app/_parent/products/replay_vision/frontend/replay_scanners/ActionEditorScene.js 22.2 KiB 🔺 +6.2 KiB (+39.2%)
posthog-app/src/scenes/inbox/InboxScene.js 659.0 KiB 🔺 +5.0 KiB (+0.8%)
exporter/src/queries/schema.js 1.01 MiB 🔺 +1.7 KiB (+0.2%)
posthog-app/src/queries/schema.js 1.01 MiB 🔺 +1.7 KiB (+0.2%)
posthog-app/src/scenes/insights/views/BoxPlot/BoxPlot.js 4.7 KiB 🟢 -1.3 KiB (-21.2%)
exporter/src/lib/components/ActivityLog/describers.js 128.4 KiB 🔺 +1.3 KiB (+1.0%)
posthog-app/src/lib/components/ActivityLog/describers.js 131.3 KiB 🔺 +1.3 KiB (+1.0%)
exporter/src/scenes/insights/views/BoxPlot/BoxPlot.js 3.2 KiB 🟢 -1.2 KiB (-28.1%)

Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report

Eager graph — within budget

How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.

Root Eager (shipped) Δ vs base Budget
entry (logged-out pages, app bootstrap)
src/index.tsx
1.22 MiB · 22 files 🔺 +11.6 KiB (+0.9%) ███░░░░░░░ 28.4% of 4.29 MiB
authenticated shell (every logged-in page)
src/scenes/AuthenticatedShell.tsx
8.14 MiB · 2,977 files 🔺 +16.5 KiB (+0.2%) █████████░ 88.0% of 9.25 MiB

🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx

Largest files eagerly shipped from src/index.tsx
Size File
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
24.6 KiB ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
6.3 KiB ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
4.5 KiB ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js
3.9 KiB ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js
1.4 KiB ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
1.3 KiB src/RootErrorBoundary.tsx
912 B ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
789 B src/scenes/ChunkLoadErrorBoundary.tsx
762 B src/index.tsx
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
Size File
280.3 KiB ../node_modules/.pnpm/posthog-js@1.400.1/node_modules/posthog-js/dist/rrweb.js
267.7 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
234.9 KiB src/taxonomy/core-filter-definitions-by-group.json
222.7 KiB ../node_modules/.pnpm/posthog-js@1.400.1/node_modules/posthog-js/dist/module.js
164.0 KiB src/queries/validators.js
154.3 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
92.7 KiB ../packages/quill/packages/quill/dist/index.js

Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479

Dist folder size — 🔺 +23.11 MiB (+1.8%)

Total size of the built frontend/dist folder (all assets), compared against the base branch.

Total: 1308.06 MiB · 🔺 +23.11 MiB (+1.8%)

@trunk-io

trunk-io Bot commented Jul 11, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

mendral-app Bot added 2 commits July 14, 2026 10:21
…vent re-render collapse

AccountNotebooksExpansion eagerly mounts accountBillingLogic for both
usage and spend tabs, firing requests to the insights endpoint. Stories
that only test the Notes/Links tabs (RowExpandedEmpty, RowExpandedWithNote,
RowExpandedLinksDisabled) did not mock this endpoint, so the unhandled
fetch could error and trigger a React re-render that collapses the
expansion row — causing [data-attr="account-expansion"] to disappear
and the post-play waitForSelector to time out (30s).

Fix:
- Add EXPANDED_ROW_DECORATORS_BASE with an empty INSIGHTS_ENDPOINT mock
  to all expanded-row stories
- Bump waitForSelectorTimeout from 30s to 60s as a safety net for slow CI
…eout

The RowExpandedUsagePopulated play function was waiting 30s for the
DataVisualization canvas + 10s for sidebar text, which combined with
test setup exceeded the 60s Jest test timeout.

Move the canvas rendering check into the waitForSelector array (which
runs in the test-runner's postVisit hook with its own 60s budget,
separate from the Jest timeout). The play function now just switches
to the Usage tab — the async canvas rendering is verified by
waitForSelector before the snapshot fires.
@mendral-app
mendral-app Bot force-pushed the mendral/fix-accounts-tab-vr-flake branch from 2f5973b to 67fc009 Compare July 14, 2026 17:22
Skip sidebar link waits (findByText 'Useful links', 'Organization') in
the play function — under CI load these can take 20-30s, and combined
with the postVisit waitForSelector for '.DataVisualization canvas' they
exceed the 60s Jest test timeout.

Instead, do a minimal expand + tab-click in the play function and let
the waitForSelector in testOptions handle verifying the canvas renders.
6 updated
Run: e4087c58-bacf-48f6-a688-f2bd2b75a8f9

Co-authored-by: rafaeelaudibert <32079912+rafaeelaudibert@users.noreply.github.com>
@rafaeelaudibert
rafaeelaudibert merged commit 96beab3 into master Jul 14, 2026
49 checks passed
@rafaeelaudibert
rafaeelaudibert deleted the mendral/fix-accounts-tab-vr-flake branch July 14, 2026 20:41
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 14, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-14 21:05 UTC Run
prod-us ✅ Deployed 2026-07-14 21:32 UTC Run
prod-eu ✅ Deployed 2026-07-14 21:32 UTC Run

mendral-app Bot added a commit that referenced this pull request Jul 15, 2026
…meout flake

The RowExpandedEmpty, RowExpandedWithNote, and RowExpandedLinksDisabled stories
use expandFirstRow() which calls findByText() for sidebar content with short
default timeouts. Under CI load, React rendering of the mocked account data
takes longer than the findByText budget, causing the play function to exhaust
the 60s test timeout on retries.

Simplify the play functions to only click-to-expand (matching the pattern that
fixed RowExpandedUsagePopulated in #70243). The waitForSelector in testOptions
already gates the snapshot on [data-attr="account-expansion"] with a 60s
budget, making sidebar content verification in the play function redundant.

Remove the now-unused expandFirstRow helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants