Skip to content

Add regression coverage for FieldArray mutators after name changes#200

Open
erikras-richard-agent wants to merge 1 commit into
masterfrom
fix/fieldarray-mutators-current-name-156
Open

Add regression coverage for FieldArray mutators after name changes#200
erikras-richard-agent wants to merge 1 commit into
masterfrom
fix/fieldarray-mutators-current-name-156

Conversation

@erikras-richard-agent
Copy link
Copy Markdown
Contributor

@erikras-richard-agent erikras-richard-agent commented May 6, 2026

Summary

  • adds regression coverage for useFieldArray mutators after the FieldArray name changes
  • verifies pushes target the currently selected nested array instead of the initially rendered name

Closes #156

Test

  • yarn test

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for field array functionality with improved validation behavior verification and edge case scenarios.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

Test coverage for the useFieldArray hook is expanded to verify validate prop propagation and mutator currying behavior. Tests are reformatted for clarity, a spy on useField tracks validator calls, and a new test validates mutators apply to the correct field name when the field name changes in nested field array scenarios.

Changes

useFieldArray Validation and Mutator Tests

Layer / File(s) Summary
Test Setup & Imports
src/useFieldArray.test.tsx
Added fireEvent import from @testing-library/react for test event handling.
Component Formatting
src/useFieldArray.test.tsx
Reformatted Form component to use multiline layout with onSubmit, mutators, and subscription props for readability.
Validate Propagation Verification
src/useFieldArray.test.tsx
Added spy on useField hook and assertions to verify that validate prop is undefined when not provided, and extracted relevant useField calls to confirm field validation behavior.
Validate Prop Behavior
src/useFieldArray.test.tsx
Enhanced test with act block to push values and verify validator call counts when validate prop is provided.
Field Name Change with Mutators
src/useFieldArray.test.tsx
New test verifying that mutators curry correctly with the latest field name in nested field array scenarios when the selected index changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • erikras

Poem

🐰 Hops past the tests with glee,
Mutators curry wild and free,
Field names dance, old or new,
Spies watch close—now validation's true! 🎭✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding regression tests for FieldArray mutators behavior when the field name changes.
Linked Issues check ✅ Passed The PR adds regression test coverage verifying that useFieldArray mutators target the currently selected nested array after name changes, directly addressing the bug described in issue #156.
Out of Scope Changes check ✅ Passed All changes are confined to test file additions for the specific regression case described in issue #156; no production code or unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fieldarray-mutators-current-name-156

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 and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conditionally visible FieldArrays pushing to wrong field

1 participant