Skip to content

test(ui): preload lazy survey chunk to fix flaky feedback tests - #12387

Merged
alejandrobailo merged 1 commit into
masterfrom
fix/flaky-feedback-survey-test
Aug 7, 2026
Merged

alejandrobailo merged 1 commit into
masterfrom
fix/flaky-feedback-survey-test

Conversation

@alejandrobailo

@alejandrobailo alejandrobailo commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Context

ui/components/survey/feedback-survey.test.tsx was flaky under full-suite load: the component lazy-loads runtime-feedback-survey via React.lazy, and each test's vi.resetModules() forces the whole chunk graph (posthog-js mock, Radix popover, lucide, zustand store) to re-evaluate inside the findBy* 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 during pnpm run test while passing in isolation.

Description

  • renderSurvey now pre-awaits import("./runtime-feedback-survey") before rendering, so the lazy chunk is already in the module registry and React.lazy resolves in a microtask — module evaluation no longer races the 1s findBy* window.
  • No timeout tuning: default query timeouts are kept, so a genuine rendering regression still fails fast.
  • The three guard tests that assert the PostHog surface is never touched (empty runtime config, PostHog disabled, not Cloud) opt out via renderSurvey({ preloadRuntime: false }), keeping their mocks.moduleLoaded never-called assertions meaningful — they still prove OSS never evaluates posthog-js.

Steps to review

  1. In ui/components/survey/feedback-survey.test.tsx, check the renderSurvey helper: the pre-import runs before render() and defaults to on.
  2. Verify the three opt-out call sites are exactly the tests asserting mocks.moduleLoaded was never called.
  3. Run cd ui && pnpm run test a 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

  • Are there new checks included in this PR? No

UI

  • All issue/task requirements work as expected on the UI
  • If this PR adds or updates npm dependencies, include package-health evidence (maintenance, popularity, known vulnerabilities, license, release age) and explain why existing/native alternatives are insufficient.
  • Screenshots/Video of the functionality flow (if applicable) - Mobile (X < 640px)
  • Screenshots/Video of the functionality flow (if applicable) - Table (640px > X < 1024px)
  • Screenshots/Video of the functionality flow (if applicable) - Desktop (X > 1024px)
  • Ensure a changelog fragment is added under ui/changelog.d/, if applicable. (Not applicable: test-only change.)

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

  • Tests
    • Improved feedback survey test setup by preloading the survey component by default.
    • Added coverage for scenarios where the analytics service must not be loaded.

@alejandrobailo
alejandrobailo requested a review from a team August 7, 2026 07:33
@alejandrobailo alejandrobailo added the no-changelog Skip including change in changelog/release notes label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

No Conflicts

No conflict markers, and the branch merges cleanly into its base.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 76570a6b-faf5-4cc8-9265-6c6cf842ed33

📥 Commits

Reviewing files that changed from the base of the PR and between fd555e2 and c5d7d2e.

📒 Files selected for processing (1)
  • ui/components/survey/feedback-survey.test.tsx

📝 Walkthrough

Walkthrough

The feedback survey test helper now optionally preloads the runtime chunk. Preloading is enabled by default. Tests that verify PostHog is not loaded disable preloading.

Changes

Survey runtime tests

Layer / File(s) Summary
Runtime preload control
ui/components/survey/feedback-survey.test.tsx
renderSurvey conditionally imports the runtime chunk before rendering. Tests that assert no PostHog access set preloadRuntime: false.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: adriiiprodri

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the test-only preload change and its purpose of fixing flaky feedback survey tests.
Description check ✅ Passed The description includes context, implementation details, review steps, test evidence, checklist status, and applicable scope information.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/flaky-feedback-survey-test

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@alejandrobailo alejandrobailo self-assigned this Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🔒 Container Security Scan

Image: prowler-ui:d26cf81
Last scan: 2026-08-07 07:37:51 UTC

✅ No Vulnerabilities Detected

The container image passed all security checks. No known CVEs were found.

📋 Resources:

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🔎 Container Security Scan (Grype)

Image: prowler-ui:d26cf81
Last scan: 2026-08-07 07:39:00 UTC

✅ Nothing Blocking

No findings at critical or high severity.


📋 Resources:

@alejandrobailo alejandrobailo added the backport-to-v5.38 Backport PR to the v5.38 branch label Aug 7, 2026
@alejandrobailo
alejandrobailo merged commit 90712c9 into master Aug 7, 2026
63 of 104 checks passed
@alejandrobailo
alejandrobailo deleted the fix/flaky-feedback-survey-test branch August 7, 2026 09:04
@prowler-bot prowler-bot added the was-backported The PR was successfully backported to the target branch label Aug 7, 2026
@prowler-bot

Copy link
Copy Markdown
Collaborator

💚 All backports created successfully

Status Branch Result
v5.38

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v5.38 Backport PR to the v5.38 branch component/ui no-changelog Skip including change in changelog/release notes was-backported The PR was successfully backported to the target branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants