test: regression tests for dirty with undefined (#5034)#5125
Conversation
The bug where meta.dirty never becomes true when a field is initialized with undefined was already fixed. These tests ensure the fix continues to work. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 535b7ef The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for vee-validate-docs canceled.
|
✅ Deploy Preview for vee-validate-v5 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Adds regression coverage for #5034 in vee-validate, ensuring meta.dirty correctly flips to true when a field starts as undefined, and validating that isEqual treats { x: undefined } vs { x: '...' } as unequal.
Changes:
- Add
isEqualregression assertions forundefined→ string transitions in objects. - Add
useFormregression tests verifyingmeta.dirtybecomestrueafter changing anundefined-initialized field. - Add
useFormregression tests verifyingmeta.dirtyresets tofalseafterresetForm().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/vee-validate/tests/utils/assertions.spec.ts | Adds isEqual regression test for undefined vs string object values. |
| packages/vee-validate/tests/useForm.spec.ts | Adds meta.dirty regression tests for fields initialized with undefined (change + reset). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let form!: Record<string, any>; | ||
| mountWithHoc({ |
There was a problem hiding this comment.
The rest of this spec types form as FormContext (often FormContext<any>). Using Record<string, any> here loses type safety and is inconsistent with the surrounding tests; consider switching to FormContext<any> (or a narrow generic for { test?: string }) for consistency.
| let form!: Record<string, any>; | ||
| mountWithHoc({ |
There was a problem hiding this comment.
Same as above: form is typed as Record<string, any> here, but other tests in this file use FormContext. Typing it as FormContext<any> (or a narrow generic) will keep the test consistent and avoid accidental misuse of the API.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
meta.dirtynever becomestruewhen a field is initialized withundefinednormalizeObjectfunction inisEqualwhich stripsundefinedvalues before comparisonisEqualcorrectly detecting inequality betweenundefinedand string valuesTest plan
useForm.spec.ts: verifymeta.dirtybecomestruewhen a field initialized withundefinedis changed to'hello'useForm.spec.ts: verifymeta.dirtyreturns tofalseafterresetForm()on a field initialized withundefinedassertions.spec.ts: verifyisEqual({ test: undefined }, { test: 'hello' })returnsfalse🤖 Generated with Claude Code