refactor(featureStateToValue): extract into a Flux-free module - #8344
refactor(featureStateToValue): extract into a Flux-free module#8344talissoncosta wants to merge 1 commit into
Conversation
Utils.featureStateToValue is a pure function, but it lives in utils.tsx, which imports the Flux stores (AccountStore/ProjectStore) at module load. That import chain breaks any unit-tested consumer, which is why the deep-link hook had to inline its own copy of the flatten logic. Move it to common/utils/featureStateToValue.ts (types only, no Flux) and have Utils delegate via a shorthand re-export, so the ~22 existing callers are unchanged. The deep-link hook now imports the shared function and drops its duplicate. The function is broadened to also accept an already-flat value (returned untouched) and to normalise a missing int/float to null. First step of decoupling the pure helpers from utils.tsx. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Docker builds report
|
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19641 (attempt 1)Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
🗂️ Previous results✅ private-cloud · depot-ubuntu-latest-16 — run #19641 (attempt 1)Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
✅ oss · depot-ubuntu-latest-arm-16 — run #19641 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
✅ oss · depot-ubuntu-latest-16 — run #19641 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-16)Details
|
Visual Regression19 screenshots compared. See report for details. |
Changes
Contributes to #8337 (follow-up to #8341)
Utils.featureStateToValueis a pure function, but it lives inutils.tsx, which imports the Flux stores (AccountStore/ProjectStore) at module load. That import chain breaks any unit-tested consumer, which is why #8341's deep-link hook had to inline its own copy of the flatten logic.This extracts it into
common/utils/featureStateToValue.ts(types only, no Flux) and hasUtilsdelegate to it via a shorthand re-export — so the ~22 existingUtils.featureStateToValue(...)callers are unchanged. The deep-link hook now imports the shared function and drops its duplicate.The function is broadened while moving:
int/floattonull.This is the first step of decoupling the pure helpers from
utils.tsx(which follows the existingcommon/utils/<name>.tsconvention, e.g.ensureTrailingSlash,multivariate).How did you test this code?
common/utils/__tests__/featureStateToValue.test.ts: covers every type branch (bool/float/int/unicode),value_typefor core traits, missing int/float →null, null/undefined →null, and already-flat passthrough.deepLinkedFeature.test.ts: keeps thepickEnvironmentFlagbehaviour tests plus one integration case proving the nested value is flattened via the shared function.