test(ui): preload lazy survey chunk to fix flaky feedback tests - #12387
Conversation
|
✅ No Conflicts No conflict markers, and the branch merges cleanly into its base. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe feedback survey test helper now optionally preloads the runtime chunk. Preloading is enabled by default. Tests that verify PostHog is not loaded disable preloading. ChangesSurvey runtime tests
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔒 Container Security ScanImage: ✅ No Vulnerabilities DetectedThe container image passed all security checks. No known CVEs were found.📋 Resources:
|
🔎 Container Security Scan (Grype)Image: ✅ Nothing BlockingNo findings at critical or high severity. 📋 Resources:
|
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
Context
ui/components/survey/feedback-survey.test.tsxwas flaky under full-suite load: the component lazy-loadsruntime-feedback-surveyviaReact.lazy, and each test'svi.resetModules()forces the whole chunk graph (posthog-js mock, Radix popover, lucide, zustand store) to re-evaluate inside thefindBy*polling window. On a loaded machine that evaluation can exceed Testing Library's default 1s timeout, so the first test in the file failed intermittently duringpnpm run testwhile passing in isolation.Description
renderSurveynow pre-awaitsimport("./runtime-feedback-survey")before rendering, so the lazy chunk is already in the module registry andReact.lazyresolves in a microtask — module evaluation no longer races the 1sfindBy*window.renderSurvey({ preloadRuntime: false }), keeping theirmocks.moduleLoadednever-called assertions meaningful — they still prove OSS never evaluatesposthog-js.Steps to review
ui/components/survey/feedback-survey.test.tsx, check therenderSurveyhelper: the pre-import runs beforerender()and defaults to on.mocks.moduleLoadedwas never called.cd ui && pnpm run testa few times — verified locally with three consecutive green full-suite runs (421 files / 2911 tests), plus the file in isolation (21/21).Checklist
Community Checklist
SDK/CLI
UI
API
No API changes.
MCP Server
No MCP Server changes.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Summary by CodeRabbit