test(frontend): add unit test coverage for formly-utils field helpers#6365
Conversation
Cover the pure FormlyFieldConfig helpers getFieldByName, setHideExpression, and the createShouldHideFieldFunc predicate factory with a Vitest spec on plain objects (no TestBed). The rxjs createOutputFormChangeEventStream is out of scope for this issue. Closes apache#6361.
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Pull request overview
Adds frontend unit test coverage for the pure FormlyFieldConfig helpers in frontend/src/app/common/formly/formly-utils.ts, using Vitest on plain object field configs (no Angular TestBed). This improves confidence in the small utility behaviors while keeping production code unchanged.
Changes:
- Added a new Vitest spec covering
getFieldByNamematch/no-match/first-duplicate behavior. - Added tests for
setHideExpression(sets hide expression for existing fields; no-op for missing names). - Added tests for
createShouldHideFieldFunccovering missing model, null/undefined target handling, regex matching, and equals matching viatoString().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Meng Wang <mengw15@uci.edu>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6365 +/- ##
============================================
+ Coverage 65.43% 65.44% +0.01%
Complexity 3382 3382
============================================
Files 1142 1142
Lines 44980 44980
Branches 4948 4948
============================================
+ Hits 29432 29438 +6
+ Misses 13928 13923 -5
+ Partials 1620 1619 -1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What changes were proposed in this PR?
Add unit test coverage for the pure
FormlyFieldConfighelpers infrontend/src/app/common/formly/formly-utils.ts—getFieldByName,setHideExpression, and thecreateShouldHideFieldFuncpredicate factory. A Vitest spec on plain objects (noTestBed). No production-code changes.The rxjs
createOutputFormChangeEventStream(debounce/distinct/share stream) is out of scope for this issue.Any related issues, documentation, discussions?
Closes #6361. See
frontend/TESTING.md.How was this PR tested?
9 pass. ESLint and Prettier on the new spec are clean. The spec is pure — it builds plain
FormlyFieldConfigobjects (noTestBed) and covers:getFieldByName(match / no-match / first-of-duplicate-keys);setHideExpression(sets the hide expression on present fields, no-op for absent names); and thecreateShouldHideFieldFuncpredicate (missing model →false, null target →hideOnNull, anchored regex match, andequalsviatoString()).Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])