Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

fieldDetailsBridge.test.ts

770 lines24.1 KB

1import {
2 InternalFormApi,
3 InternalFormGroupApi,
4 installDevtoolsBridge,
5} from '@tanstack/form-core/internals'
6import { afterEach, describe, expect, it, vi } from 'vitest'
7import { z } from 'zod'
8import { createFieldsController } from '../src/bridge/fields'
9import { createFieldIdentityController } from '../src/bridge/fields/identity'
10import { createMountedFormsController } from '../src/bridge/forms/mountedForms'
11import { getDevtoolsFieldDetail } from '../src/bridge/fields/detailSnapshot'
12import { createFormDevtoolsBridge } from '../src/bridge/createBridge'
13import { formDevtoolsEventClient } from '../src/eventClient.lib'
14import { connectTestEventBus } from './testEventBus'
15import { setFieldValidatorErrors } from './testUtils'
16import type {
17 AnyInternalValidationSourceInstance,
18 ValidationSourceErrorState,
19} from '@tanstack/form-core/internals'
20import type {
21 DevtoolsFieldDetail,
22 FieldDetailSubscriptionDescriptor,
23 FormDevtoolsEventMap,
24} from '../src/eventClientTypes'
25import type { FieldId, FormId } from '../src/types/branded'
26​
27const callbackValidator = {
28 triggers: ['change'] as const,
29 run: () => null,
31​
32const schemaValidator = {
33 triggers: ['change'] as const,
34 run: z.unknown(),
36​
37function descriptor(
38 formInstanceId: FormId,
39 fieldId: FieldId,
40 overrides: Partial<FieldDetailSubscriptionDescriptor['settings']> = {},
41): FieldDetailSubscriptionDescriptor {
42 return {
43 formInstanceId,
44 fieldId,
45 settings: {
46 includeValues: true,
47 errorPayloadMode: 'full',
48 debounceMs: 0,
49 ...overrides,
50 },
51 }
53​
54afterEach(() => {
55 vi.useRealTimers()
56})
57​
58describe('field detail snapshots', () => {
59 it('projects validator provenance and preserves FieldState error visibility', () => {
60 const identity = createFieldIdentityController()
61 const form = new InternalFormApi({
62 defaultValues: { profile: { name: 'Ada' } },
63 validators: [callbackValidator, schemaValidator] as never,
64 })
65 const group = new InternalFormGroupApi({
66 form,
67 name: 'profile',
68 validators: [schemaValidator] as never,
69 })
70 const field = form._getOrCreateFieldApi({
71 name: 'profile.name',
72 validators: [callbackValidator, schemaValidator] as never,
73 })
74 const unregister = field._register()
75 const subscription = descriptor('form', 'field')
76​
77 try {
78 const [fieldCallback, fieldSchema] = field._validatorInstances!
79 const groupSchema = group._validatorInstances![0]!
80 const [formCallback, formSchema] = form._validatorInstances!
81 field._setMeta((meta) => ({
82 ...meta,
83 _validationSourceErrors: new Map<
84 AnyInternalValidationSourceInstance,
85 ValidationSourceErrorState
86 >([
87 [
88 fieldCallback!,
89 {
90 errors: [
91 { message: 'Field callback', code: 'field-code' } as never,
92 {
93 message: 'Field callback second',
94 code: 'field-code-2',
95 } as never,
96 ],
97 sourceEvent: 'change',
98 },
99 ],
100 [
101 fieldSchema!,
102 {
103 errors: [{ message: 'Field schema', path: ['name'] } as never],
104 sourceEvent: 'blur',
105 },
106 ],
107 [
108 groupSchema,
109 {
110 errors: [{ message: 'Group schema', path: ['name'] } as never],
111 sourceEvent: 'server',
112 },
113 ],
114 [
115 formCallback!,
116 {
117 errors: [
118 { message: 'Form callback', code: 'form-code' } as never,
119 ],
120 sourceEvent: 'change',
121 },
122 ],
123 [
124 formSchema!,
125 {
126 errors: [
127 {
128 message: 'Form schema',
129 path: ['profile', 'name'],
130 } as never,
131 ],
132 sourceEvent: 'server',
133 },
134 ],
135 [
136 form._onSubmitSource,
137 {
138 errors: [
139 { message: 'Submit callback', code: 'submit-code' } as never,
140 ],
141 sourceEvent: 'submit',
142 },
143 ],
144 ]),
145 }))
146​
147 const full = getDevtoolsFieldDetail(field, subscription, identity)
148 expect(full.state.value).toBe('Ada')
149 expect(full.defaultValue).toBe('Ada')
150 expect(
151 full.state.meta.original.errors.map(({ source }) => source),
152 ).toEqual([
153 { scope: 'field', validatorIndex: 0, validatorType: 'callback' },
154 { scope: 'field', validatorIndex: 0, validatorType: 'callback' },
155 { scope: 'field', validatorIndex: 1, validatorType: 'schema' },
156 {
157 scope: 'formGroup',
158 formGroupPath: 'profile',
159 validatorIndex: 0,
160 validatorType: 'schema',
161 },
162 { scope: 'form', validatorIndex: 0, validatorType: 'callback' },
163 { scope: 'form', validatorIndex: 1, validatorType: 'schema' },
164 { scope: 'onSubmit', validatorType: 'callback' },
165 ])
166 expect(
167 full.state.meta.original.errors.map(({ sourceEvent }) => sourceEvent),
168 ).toEqual([
169 'change',
170 'change',
171 'blur',
172 'server',
173 'change',
174 'server',
175 'submit',
176 ])
177 expect(
178 full.state.meta.original.errors.map(({ error }) => error.message),
179 ).toEqual(field.state.meta.original.errors.map(({ message }) => message))
180 expect(full.state.meta.errors).toEqual(full.state.meta.original.errors)
181 expect(full.state.meta.errors[0]?.error).toEqual({
182 message: 'Field callback',
183 code: 'field-code',
184 })
185​
186 const messages = getDevtoolsFieldDetail(
187 field,
188 {
189 ...subscription,
190 settings: { ...subscription.settings, errorPayloadMode: 'messages' },
191 },
192 identity,
193 )
194 expect(messages.state.meta.original.errors[0]?.error).toEqual({
195 message: 'Field callback',
196 })
197 expect(messages.state.meta.original.errors[2]?.error).toEqual({
198 message: 'Field schema',
199 })
200​
201 field._errorVisibility = () => false
202 field._setMeta((meta) => ({ ...meta, isBlurred: true }))
203 const hidden = getDevtoolsFieldDetail(field, subscription, identity)
204 expect(hidden.state.meta.errors).toEqual([])
205 expect(hidden.state.meta.original.errors).toHaveLength(7)
206​
207 const metaOnly = getDevtoolsFieldDetail(
208 field,
209 {
210 ...subscription,
211 settings: { ...subscription.settings, includeValues: false },
212 },
213 identity,
214 )
215 expect(Object.hasOwn(metaOnly.state, 'value')).toBe(false)
216 expect(Object.hasOwn(metaOnly, 'defaultValue')).toBe(false)
217 } finally {
218 unregister()
219 group._cleanup()
220 }
221 })
222​
223 it('projects direct children and normalized relations in both directions', () => {
224 const identity = createFieldIdentityController()
225 const form = new InternalFormApi({
226 defaultValues: {
227 parent: { child: { grandchild: '' } },
228 other: '',
229 source: '',
230 target: '',
231 },
232 })
233 const parent = form._getOrCreateFieldApi({
234 name: 'parent',
235 })
236 form._getOrCreateFieldApi({ name: 'parent.child.grandchild' })
237 const target = form._getOrCreateFieldApi({
238 name: 'target',
239 listeners: [
240 {
241 triggers: ['change'],
242 watchFields: ['source', 'other'],
243 run: () => {},
244 },
245 {
246 triggers: ['change'],
247 watchFields: ['source'],
248 run: () => {},
249 },
250 ],
251 validators: [
252 {
253 triggers: ['change'],
254 watchFields: ['source'],
255 run: () => null,
256 },
257 ],
258 })
259 const source = form._getOrCreateFieldApi({ name: 'source' })
260 const other = form._getOrCreateFieldApi({ name: 'other' })
261 const subscription = descriptor('form', 'field')
262​
263 const parentDetail = getDevtoolsFieldDetail(parent, subscription, identity)
264 expect(parentDetail.relations.directChildCount).toBe(1)
265 expect(parentDetail.state.meta.subfields).toEqual({
266 isEveryValid: true,
267 isAnyInvalid: false,
268 isEveryPristine: true,
269 isSomeDirty: false,
270 isSomeTouched: false,
271 isSomeValidating: false,
272 })
273​
274 expect(
275 getDevtoolsFieldDetail(target, subscription, identity).relations,
276 ).toEqual({
277 directChildCount: 0,
278 listensTo: [
279 {
280 fieldId: identity.getFieldId(other),
281 causes: [{ kind: 'listener', itemIndex: 0 }],
282 },
283 {
284 fieldId: identity.getFieldId(source),
285 causes: [
286 { kind: 'listener', itemIndex: 0 },
287 { kind: 'listener', itemIndex: 1 },
288 { kind: 'validator', itemIndex: 0 },
289 ],
290 },
291 ],
292 listenedToBy: [],
293 })
294 expect(
295 getDevtoolsFieldDetail(source, subscription, identity).relations,
296 ).toEqual({
297 directChildCount: 0,
298 listensTo: [],
299 listenedToBy: [
300 {
301 fieldId: identity.getFieldId(target),
302 causes: [
303 { kind: 'listener', itemIndex: 0 },
304 { kind: 'listener', itemIndex: 1 },
305 { kind: 'validator', itemIndex: 0 },
306 ],
307 },
308 ],
309 })
310 })
311})
312​
313describe('field detail bridge', () => {
314 it('streams topology changes and registers newly watched fields', async () => {
315 const disconnectEventBus = connectTestEventBus()
316 const mountedForms = createMountedFormsController()
317 const fields = createFieldsController(mountedForms)
318 const uninstallBridge = installDevtoolsBridge(
319 createFormDevtoolsBridge({ fields, mountedForms }),
320 )
321 const form = new InternalFormApi({
322 defaultValues: { parent: {}, target: '' },
323 })
324 const unmountForm = form.mount()
325 form._getOrCreateFieldApi({ name: 'parent' })
326 const target = form._getOrCreateFieldApi({ name: 'target' })
327 const details: Array<DevtoolsFieldDetail> = []
328 const patches: Array<FormDevtoolsEventMap['field-list-patch']> = []
329 const cleanupDetails = formDevtoolsEventClient.on(
330 'field-detail-changed',
331 (event) => details.push(event.payload),
332 )
333 const cleanupPatches = formDevtoolsEventClient.on(
334 'field-list-patch',
335 (event) => patches.push(event.payload),
336 )
337​
338 try {
339 const formInstanceId =
340 mountedForms.getMountedFormsSnapshot()[0]!.instanceId
341 formDevtoolsEventClient.emit('field-list-subscribe', { formInstanceId })
342 const rows = fields.getFieldRowsSnapshot(form)
343 const parentId = rows.find(({ path }) => path === 'parent')!.fieldId
344 const targetId = rows.find(({ path }) => path === 'target')!.fieldId
345 formDevtoolsEventClient.emit(
346 'field-detail-subscribe',
347 descriptor(formInstanceId, parentId),
348 )
349 formDevtoolsEventClient.emit(
350 'field-detail-subscribe',
351 descriptor(formInstanceId, targetId),
352 )
353​
354 form._getOrCreateFieldApi({ name: 'parent.child.grandchild' as never })
355 expect(
356 details.filter(({ fieldId }) => fieldId === parentId).at(-1)?.relations
357 .directChildCount,
358 ).toBe(1)
359​
360 target._update({
361 listeners: [
362 {
363 triggers: ['change'],
364 watchFields: ['source'],
365 run: () => {},
366 },
367 ],
368 validators: [
369 {
370 triggers: ['change'],
371 watchFields: ['source'],
372 run: () => null,
373 },
374 ],
375 })
376​
377 const targetRelations = details
378 .filter(({ fieldId }) => fieldId === targetId)
379 .at(-1)!.relations
380 expect(targetRelations.listensTo).toHaveLength(1)
381 expect(targetRelations.listensTo[0]?.causes).toEqual([
382 { kind: 'listener', itemIndex: 0 },
383 { kind: 'validator', itemIndex: 0 },
384 ])
385​
386 await Promise.resolve()
387 const sourceId = targetRelations.listensTo[0]!.fieldId
388 expect(
389 patches.some((patch) =>
390 patch.upsert?.some(
391 (field) => field.fieldId === sourceId && field.path === 'source',
392 ),
393 ),
394 ).toBe(true)
395​
396 const source = form._tryGetFieldApi('source')!
397 const unregisterSource = source._register()
398 formDevtoolsEventClient.emit(
399 'field-detail-subscribe',
400 descriptor(formInstanceId, sourceId),
401 )
402 expect(details.at(-1)?.relations.listenedToBy).toEqual([
403 {
404 fieldId: targetId,
405 causes: [
406 { kind: 'listener', itemIndex: 0 },
407 { kind: 'validator', itemIndex: 0 },
408 ],
409 },
410 ])
411​
412 target._update({ listeners: [], validators: [] })
413 expect(
414 details.filter(({ fieldId }) => fieldId === sourceId).at(-1)?.relations
415 .listenedToBy,
416 ).toEqual([])
417 unregisterSource()
418 await new Promise((resolve) => setTimeout(resolve, 0))
419 await Promise.resolve()
420 expect(patches.some((patch) => patch.remove?.includes(sourceId))).toBe(
421 true,
422 )
423​
424 const child = form._tryGetFieldApi('parent.child')!
425 child._kill()
426 expect(
427 details.filter(({ fieldId }) => fieldId === parentId).at(-1)?.relations
428 .directChildCount,
429 ).toBe(0)
430​
431 expect(source._isKilled).toBe(false)
432 } finally {
433 cleanupPatches()
434 cleanupDetails()
435 unmountForm()
436 uninstallBridge()
437 fields.dispose()
438 mountedForms.dispose()
439 disconnectEventBus()
440 }
441 })
442​
443 it('streams initial relations for a newly added field', async () => {
444 const disconnectEventBus = connectTestEventBus()
445 const mountedForms = createMountedFormsController()
446 const fields = createFieldsController(mountedForms)
447 const uninstallBridge = installDevtoolsBridge(
448 createFormDevtoolsBridge({ fields, mountedForms }),
449 )
450 const form = new InternalFormApi({
451 defaultValues: { source: '', target: '' },
452 })
453 const unmountForm = form.mount()
454 const source = form._getOrCreateFieldApi({ name: 'source' })
455 const unregisterSource = source._register()
456 const details: Array<DevtoolsFieldDetail> = []
457 const patches: Array<FormDevtoolsEventMap['field-list-patch']> = []
458 const cleanupDetails = formDevtoolsEventClient.on(
459 'field-detail-changed',
460 (event) => details.push(event.payload),
461 )
462 const cleanupPatches = formDevtoolsEventClient.on(
463 'field-list-patch',
464 (event) => patches.push(event.payload),
465 )
466​
467 try {
468 const formInstanceId =
469 mountedForms.getMountedFormsSnapshot()[0]!.instanceId
470 formDevtoolsEventClient.emit('field-list-subscribe', { formInstanceId })
471 const sourceId = fields
472 .getFieldRowsSnapshot(form)
473 .find(({ path }) => path === 'source')!.fieldId
474 formDevtoolsEventClient.emit(
475 'field-detail-subscribe',
476 descriptor(formInstanceId, sourceId),
477 )
478​
479 const target = form._getOrCreateFieldApi({
480 name: 'target',
481 listeners: [
482 {
483 triggers: ['change'],
484 watchFields: ['source'],
485 run: () => {},
486 },
487 ],
488 })
489 const targetRelation = details
490 .filter(({ fieldId }) => fieldId === sourceId)
491 .at(-1)!.relations.listenedToBy[0]!
492​
493 expect(targetRelation.causes).toEqual([
494 { kind: 'listener', itemIndex: 0 },
495 ])
496 await Promise.resolve()
497 expect(
498 patches.some((patch) =>
499 patch.upsert?.some(
500 ({ fieldId, path }) =>
501 fieldId === targetRelation.fieldId && path === 'target',
502 ),
503 ),
504 ).toBe(true)
505​
506 target._kill()
507 expect(
508 details.filter(({ fieldId }) => fieldId === sourceId).at(-1)?.relations
509 .listenedToBy,
510 ).toEqual([])
511 } finally {
512 cleanupPatches()
513 cleanupDetails()
514 unregisterSource()
515 unmountForm()
516 uninstallBridge()
517 fields.dispose()
518 mountedForms.dispose()
519 disconnectEventBus()
520 }
521 })
522​
523 it('keeps relation IDs and canonical rows aligned across array moves', async () => {
524 const disconnectEventBus = connectTestEventBus()
525 const mountedForms = createMountedFormsController()
526 const fields = createFieldsController(mountedForms)
527 const uninstallBridge = installDevtoolsBridge(
528 createFormDevtoolsBridge({ fields, mountedForms }),
529 )
530 const form = new InternalFormApi({
531 defaultValues: { users: [{ name: 'first' }], target: '' },
532 })
533 const unmountForm = form.mount()
534 const source = form._getOrCreateFieldApi({ name: 'users[0].name' })
535 const target = form._getOrCreateFieldApi({
536 name: 'target',
537 listeners: [
538 {
539 triggers: ['change'],
540 watchFields: ['users[0].name'],
541 run: () => {},
542 },
543 ],
544 })
545 const details: Array<DevtoolsFieldDetail> = []
546 const patches: Array<FormDevtoolsEventMap['field-list-patch']> = []
547 const cleanupDetails = formDevtoolsEventClient.on(
548 'field-detail-changed',
549 (event) => details.push(event.payload),
550 )
551 const cleanupPatches = formDevtoolsEventClient.on(
552 'field-list-patch',
553 (event) => patches.push(event.payload),
554 )
555​
556 try {
557 const formInstanceId =
558 mountedForms.getMountedFormsSnapshot()[0]!.instanceId
559 formDevtoolsEventClient.emit('field-list-subscribe', { formInstanceId })
560 const rows = fields.getFieldRowsSnapshot(form)
561 const sourceId = rows.find(
562 ({ path }) => path === 'users[0].name',
563 )!.fieldId
564 const targetId = rows.find(({ path }) => path === 'target')!.fieldId
565 formDevtoolsEventClient.emit(
566 'field-detail-subscribe',
567 descriptor(formInstanceId, targetId),
568 )
569​
570 expect(details.at(-1)?.relations.listensTo).toEqual([
571 {
572 fieldId: sourceId,
573 causes: [{ kind: 'listener', itemIndex: 0 }],
574 },
575 ])
576​
577 form.insertFieldValue('users', 0, { name: 'inserted' })
578​
579 expect(source.name).toBe('users[1].name')
580 expect(details.at(-1)?.relations.listensTo).toEqual([
581 {
582 fieldId: sourceId,
583 causes: [
584 {
585 kind: 'listener',
586 itemIndex: 0,
587 configuredPath: 'users[0].name',
588 },
589 ],
590 },
591 ])
592​
593 await Promise.resolve()
594 expect(
595 patches.some((patch) =>
596 patch.upsert?.some(
597 (field) =>
598 field.fieldId === sourceId && field.path === 'users[1].name',
599 ),
600 ),
601 ).toBe(true)
602 expect(target._isKilled).toBe(false)
603 } finally {
604 cleanupPatches()
605 cleanupDetails()
606 unmountForm()
607 uninstallBridge()
608 fields.dispose()
609 mountedForms.dispose()
610 disconnectEventBus()
611 }
612 })
613​
614 it('streams directly from the field atom and keeps errored unmounted fields subscribed', async () => {
615 const disconnectEventBus = connectTestEventBus()
616 const mountedForms = createMountedFormsController()
617 const fields = createFieldsController(mountedForms)
618 const form = new InternalFormApi({ defaultValues: { name: '' } })
619 const field = form._getOrCreateFieldApi({ name: 'name' })
620 const unregister = field._register()
621 const details: Array<DevtoolsFieldDetail> = []
622 const cleanupDetails = formDevtoolsEventClient.on(
623 'field-detail-changed',
624 (event) => details.push(event.payload),
625 )
626​
627 try {
628 mountedForms.mountForm(form)
629 const formInstanceId =
630 mountedForms.getMountedFormsSnapshot()[0]!.instanceId
631 const fieldId = fields.getFieldRowsSnapshot(form)[0]!.fieldId
632 const subscription = descriptor(formInstanceId, fieldId)
633​
634 formDevtoolsEventClient.emit('field-detail-subscribe', subscription)
635 expect(details).toHaveLength(1)
636 expect(details[0]?.state.value).toBe('')
637​
638 field.handleChange('Ada')
639 expect(details.at(-1)?.state.value).toBe('Ada')
640 expect(details.at(-1)?.state.meta.isDirty).toBe(true)
641​
642 setFieldValidatorErrors(field, [{ message: 'Keep this field' }])
643 unregister()
644 await new Promise((resolve) => setTimeout(resolve, 0))
645 field.handleChange('Grace')
646​
647 expect(field._isMounted).toBe(false)
648 expect(details.at(-1)?.state.value).toBe('Grace')
649​
650 const countBeforeUnsubscribe = details.length
651 formDevtoolsEventClient.emit('field-detail-unsubscribe', subscription)
652 field.handleChange('Lin')
653 expect(details).toHaveLength(countBeforeUnsubscribe)
654 } finally {
655 cleanupDetails()
656 fields.dispose()
657 mountedForms.dispose()
658 disconnectEventBus()
659 }
660 })
661​
662 it('debounces transformation and emission to the latest atom state', async () => {
663 const disconnectEventBus = connectTestEventBus()
664 const mountedForms = createMountedFormsController()
665 const fields = createFieldsController(mountedForms)
666 const form = new InternalFormApi({ defaultValues: { name: '' } })
667 const field = form._getOrCreateFieldApi({ name: 'name' })
668 const unregister = field._register()
669 const details: Array<DevtoolsFieldDetail> = []
670 const cleanupDetails = formDevtoolsEventClient.on(
671 'field-detail-changed',
672 (event) => details.push(event.payload),
673 )
674​
675 try {
676 mountedForms.mountForm(form)
677 const formInstanceId =
678 mountedForms.getMountedFormsSnapshot()[0]!.instanceId
679 const fieldId = fields.getFieldRowsSnapshot(form)[0]!.fieldId
680 const subscription = descriptor(formInstanceId, fieldId, {
681 debounceMs: 100,
682 })
683​
684 formDevtoolsEventClient.emit('field-detail-subscribe', subscription)
685 expect(details).toHaveLength(1)
686​
687 vi.useFakeTimers()
688 field.handleChange('A')
689 field.handleChange('B')
690 field.handleChange('C')
691​
692 await vi.advanceTimersByTimeAsync(99)
693 expect(details).toHaveLength(1)
694​
695 await vi.advanceTimersByTimeAsync(1)
696 expect(details).toHaveLength(2)
697 expect(details.at(-1)?.state.value).toBe('C')
698​
699 field.handleChange('pending')
700 fields.removeFieldSubtree(form, [{ field, previousPath: field.name }])
701 await vi.advanceTimersByTimeAsync(100)
702 expect(details).toHaveLength(2)
703 } finally {
704 cleanupDetails()
705 unregister()
706 fields.dispose()
707 mountedForms.dispose()
708 disconnectEventBus()
709 }
710 })
711​
712 it('ignores stale descriptor unsubscriptions after settings change', () => {
713 const disconnectEventBus = connectTestEventBus()
714 const mountedForms = createMountedFormsController()
715 const fields = createFieldsController(mountedForms)
716 const form = new InternalFormApi({ defaultValues: { name: '' } })
717 const field = form._getOrCreateFieldApi({ name: 'name' })
718 const unregister = field._register()
719 const details: Array<DevtoolsFieldDetail> = []
720 const cleanupDetails = formDevtoolsEventClient.on(
721 'field-detail-changed',
722 (event) => details.push(event.payload),
723 )
724​
725 try {
726 mountedForms.mountForm(form)
727 const formInstanceId =
728 mountedForms.getMountedFormsSnapshot()[0]!.instanceId
729 const fieldId = fields.getFieldRowsSnapshot(form)[0]!.fieldId
730 const oldDescriptor = descriptor(formInstanceId, fieldId, {
731 debounceMs: 100,
732 })
733 const newDescriptor = descriptor(formInstanceId, fieldId, {
734 includeValues: false,
735 })
736​
737 formDevtoolsEventClient.emit('field-detail-subscribe', oldDescriptor)
738 formDevtoolsEventClient.emit('field-detail-subscribe', newDescriptor)
739 formDevtoolsEventClient.emit('field-detail-unsubscribe', oldDescriptor)
740 field._setMeta((meta) => ({ ...meta, isBlurred: true }))
741​
742 expect(details.at(-1)?.settings).toEqual(newDescriptor.settings)
743 expect(details.at(-1)?.state.meta.isBlurred).toBe(true)
744 expect(Object.hasOwn(details.at(-1)!.state, 'value')).toBe(false)
745​
746 field.handleChange('A', {
747 causeValidation: false,
748 markAsDirty: false,
749 markAsTouched: false,
750 })
751 const countAfterMetaChange = details.length
752 field.handleChange('B', {
753 causeValidation: false,
754 markAsDirty: false,
755 markAsTouched: false,
756 })
757 expect(details).toHaveLength(countAfterMetaChange)
758​
759 mountedForms.unmountForm(form, fields.unmountForm)
760 field._setMeta((meta) => ({ ...meta, isBlurred: false }))
761 expect(details).toHaveLength(countAfterMetaChange)
762 } finally {
763 cleanupDetails()
764 unregister()
765 fields.dispose()
766 mountedForms.dispose()
767 disconnectEventBus()
768 }
769 })
770})