Skip to content

test: regression tests for dirty with undefined (#5034)#5125

Open
logaretm wants to merge 2 commits into
mainfrom
test/5034-dirty-undefined-regression
Open

test: regression tests for dirty with undefined (#5034)#5125
logaretm wants to merge 2 commits into
mainfrom
test/5034-dirty-undefined-regression

Conversation

@logaretm
Copy link
Copy Markdown
Owner

@logaretm logaretm commented Mar 4, 2026

Summary

  • Adds regression tests for issue meta.dirty never becomes true when a field is initialized with undefined #5034 where meta.dirty never becomes true when a field is initialized with undefined
  • The underlying bug was already fixed via the normalizeObject function in isEqual which strips undefined values before comparison
  • Tests cover: dirty becoming true on value change, dirty resetting on form reset, and isEqual correctly detecting inequality between undefined and string values

Test plan

  • useForm.spec.ts: verify meta.dirty becomes true when a field initialized with undefined is changed to 'hello'
  • useForm.spec.ts: verify meta.dirty returns to false after resetForm() on a field initialized with undefined
  • assertions.spec.ts: verify isEqual({ test: undefined }, { test: 'hello' }) returns false
  • All 55 tests pass locally

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings March 4, 2026 05:53
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 4, 2026

🦋 Changeset detected

Latest 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

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 4, 2026

Deploy Preview for vee-validate-docs canceled.

Name Link
🔨 Latest commit 535b7ef
🔍 Latest deploy log https://app.netlify.com/projects/vee-validate-docs/deploys/69a7c976f7a3440008e0fb41

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 4, 2026

Deploy Preview for vee-validate-v5 ready!

Name Link
🔨 Latest commit 535b7ef
🔍 Latest deploy log https://app.netlify.com/projects/vee-validate-v5/deploys/69a7c97662d5bb0008d6ce7e
😎 Deploy Preview https://deploy-preview-5125--vee-validate-v5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 isEqual regression assertions for undefined → string transitions in objects.
  • Add useForm regression tests verifying meta.dirty becomes true after changing an undefined-initialized field.
  • Add useForm regression tests verifying meta.dirty resets to false after resetForm().

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.

Comment on lines +1495 to +1496
let form!: Record<string, any>;
mountWithHoc({
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +1520 to +1521
let form!: Record<string, any>;
mountWithHoc({
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants