Add regression test for #49 (remove mutator after move)#107
Add regression test for #49 (remove mutator after move)#107erikras-richard-agent wants to merge 1 commit intofinal-form:masterfrom
Conversation
📝 WalkthroughWalkthroughA new regression test file validates the interaction between Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 Tip You can customize the high-level summary generated by CodeRabbit.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/remove.move-bug-49.test.ts`:
- Around line 61-65: The test currently only checks existence for nested fields
'customers[0].id' and 'customers[0].name' which can hide stale values; update
the assertions for state.fields['customers[0].id'] and
state.fields['customers[0].name'] to assert their .value equals the expected
primitives (e.g., 2 for id and 'Customer `#2`' for name) instead of using
toBeDefined(), keeping the existing check for state.fields['customers[0]'].value
object as-is to ensure both the composite and nested field values are validated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 331a17d6-ed05-4af0-b3ce-a7b9c05477ce
📒 Files selected for processing (1)
src/remove.move-bug-49.test.ts
| // Field state should reflect the remaining customer at index 0 | ||
| expect(state.fields['customers[0]']).toBeDefined() | ||
| expect(state.fields['customers[0]'].value).toEqual({ id: 2, name: 'Customer #2' }) | ||
| expect(state.fields['customers[0].id']).toBeDefined() | ||
| expect(state.fields['customers[0].name']).toBeDefined() |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Assert nested surviving field values, not just existence.
At Line 64 and Line 65, toBeDefined() can still pass with stale nested values. Add value assertions to harden the regression test.
Suggested test-strengthening diff
expect(state.fields['customers[0].id']).toBeDefined()
expect(state.fields['customers[0].name']).toBeDefined()
+ expect(state.fields['customers[0].id'].value).toBe(2)
+ expect(state.fields['customers[0].name'].value).toBe('Customer `#2`')📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Field state should reflect the remaining customer at index 0 | |
| expect(state.fields['customers[0]']).toBeDefined() | |
| expect(state.fields['customers[0]'].value).toEqual({ id: 2, name: 'Customer #2' }) | |
| expect(state.fields['customers[0].id']).toBeDefined() | |
| expect(state.fields['customers[0].name']).toBeDefined() | |
| // Field state should reflect the remaining customer at index 0 | |
| expect(state.fields['customers[0]']).toBeDefined() | |
| expect(state.fields['customers[0]'].value).toEqual({ id: 2, name: 'Customer `#2`' }) | |
| expect(state.fields['customers[0].id']).toBeDefined() | |
| expect(state.fields['customers[0].name']).toBeDefined() | |
| expect(state.fields['customers[0].id'].value).toBe(2) | |
| expect(state.fields['customers[0].name'].value).toBe('Customer `#2`') |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/remove.move-bug-49.test.ts` around lines 61 - 65, The test currently only
checks existence for nested fields 'customers[0].id' and 'customers[0].name'
which can hide stale values; update the assertions for
state.fields['customers[0].id'] and state.fields['customers[0].name'] to assert
their .value equals the expected primitives (e.g., 2 for id and 'Customer `#2`'
for name) instead of using toBeDefined(), keeping the existing check for
state.fields['customers[0]'].value object as-is to ensure both the composite and
nested field values are validated.
Adds regression test coverage for issue #49 where the remove mutator would remove the wrong field from the screen after items were reordered with the move mutator.
The bug was fixed in commit f69ab19 (Nov 2020) by using
copyFieldwhich clearslastFieldStateto force React component re-renders.This test ensures the fix continues to work by:
Summary by CodeRabbit