Skip to content

add unit test coverage for formly-utils pure field helpers #6361

Description

@mengw15

Task Summary

frontend/src/app/common/formly/formly-utils.ts (codecov ~16%) has pure helpers over FormlyFieldConfig arrays: getFieldByName, setHideExpression, and the createShouldHideFieldFunc predicate factory. Cover them with Vitest on plain objects (no TestBed). The rxjs createOutputFormChangeEventStream (debounce/distinct/share stream) is out of scope for this issue. See frontend/TESTING.md.

Behavior to cover

  • getFieldByName(name, fields) — returns the field whose key === name; undefined when no field matches; the first match when several share a key
  • createShouldHideFieldFunc(...) — the returned predicate:
    • model is null/undefined -> returns false
    • target field value is null/undefined -> returns hideOnNull
    • regex mode -> hides iff the value matches ^(expected)$
    • non-regex mode -> hides iff value.toString() === expected
  • setHideExpression(toggleHidden, fields, hiddenBy) — sets hideExpression = hiddenBy on each named field that exists; no-op for names not present

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions