Comprehensive testing checklist for el-form-react-hooks package
Total Features: 23 categories | Individual Test Cases: 100+
This document provides a systematic approach to testing all features of the el-form-react-hooks package. Features are grouped logically to allow efficient testing of related functionality.
✅ CONFIRMED WORKING (Through BasicValidationTest):
- ✅ Core Setup: Hook initialization, field registration, default values, TypeScript support
- ✅ Validation: Zod schema validation, real-time onChange validation, cross-field validation, error handling
- ✅ Field Registration: All input types (text, number, select, checkbox, textarea), automatic type coercion
- ✅ State Management: Form state tracking, dirty state detection, real-time updates
- ✅ Watch System: watch(), watch(fieldName), conditional rendering, real-time subscriptions
- ✅ Array Operations: addArrayItem, removeArrayItem, nested arrays (skills.projects), complex structures
- ✅ Form Submission: handleSubmit, validation before submit, canSubmit(), submission state
- ✅ Reset Operations: Basic reset() functionality, state clearing
- ✅ Complex Data: Nested objects, array indexing, deep validation, mixed notation support
- ✅ File Upload Support: File input registration, validation, management, preview, Zod integration
🔄 PARTIALLY TESTED:
- 🔄 Advanced Validation: Only onChange mode tested, need onBlur, onSubmit, manual modes
- 🔄 Form Control: Basic functionality confirmed, need setValue/setValues testing
- 🔄 Error Management: Display working, need programmatic setError/clearErrors testing
❌ NOT YET TESTED:
- ❌ Context Integration: FormProvider, useFormContext patterns
- ❌ Focus Management: setFocus() methods
- ❌ State Persistence: Snapshots, field state queries
- ❌ Edge Cases: Error boundaries, invalid inputs, memory leaks
| Category | Features | Priority | Can Test Together |
|---|---|---|---|
| Core Setup | Hook initialization, field registration | 🔴 Critical | ✅ Yes |
| Validation | All validation modes and types | 🔴 Critical | ✅ Yes |
| State Management | Form state, dirty/touched tracking | 🔴 Critical | ✅ Yes |
| Form Control | Value setting, errors, reset | 🟡 High | ✅ Yes |
| Advanced Features | Watch, submission, arrays, files | 🟡 High | ✅ Partially |
| File Upload Support | File inputs, validation, preview | 🟡 High | ✅ Yes |
| Context Integration | FormProvider, reusability patterns | 🟢 Medium | ✅ Yes |
| Performance | Optimization, edge cases | 🟢 Medium | ✅ Yes |
Test Together: All initialization features in one test suite
-
useForm hook instantiation
- Basic hook call with no options
- Hook call with all options provided
- TypeScript generic type inference
- Default values assignment
-
Initial form state verification
-
formState.valuesmatches defaultValues -
formState.errorsis empty object -
formState.touchedis empty object -
formState.isSubmittingis false -
formState.isValidinitial state -
formState.isDirtyis false
-
-
Hook options handling
-
defaultValuesobject processing -
validatorsconfiguration -
fieldValidatorsconfiguration -
modesetting (onChange, onBlur, onSubmit, all) -
validateOnoption override -
onSubmitcallback registration
-
Test Together: All register() functionality
-
register() function behavior
- Returns correct props object structure
-
nameproperty correctly set -
onChangehandler function provided -
onBlurhandler function provided
-
Input type handling
- Text inputs: returns
valueproperty - Checkbox inputs: returns
checkedproperty - Textarea inputs: value handling
- Number inputs: value type conversion
- Text inputs: returns
-
Field value management
- Initial field values from defaultValues
- Empty/undefined field value handling
- Nested field registration (dot notation)
- Field value retrieval and display
-
Event handler functionality
- onChange updates form state correctly
- onBlur marks field as touched
- Event object parameter handling
- Synthetic event compatibility
Test Together: Validation timing scenarios
-
onChange validation
- Validates on every keystroke when enabled
- Does not validate when disabled
- Error display in real-time
- Performance with rapid changes
-
onBlur validation
- Validates when field loses focus
- Does not validate on focus
- Touched state interaction
- Multiple field blur sequence
-
onSubmit validation
- Validates all fields on form submission
- Prevents submission if invalid
- Shows all errors at once
- Does not validate during typing
-
Manual validation (validateOn: "manual")
- No automatic validation
- Only validates when trigger() called
- Form remains in initial state
- Custom validation logic support
-
Mode combinations
mode: "all"enables all validationvalidateOnoverridesmodesetting- Complex validation timing scenarios
- Mode switching behavior
Test Together: Different validation approaches
-
Schema validation
- Zod schema validation
- Yup schema validation
- Custom schema libraries
- Schema error message parsing
-
Field-level validators
- Individual field validation rules
- Override schema validation
- Custom validation functions
- Async field validation
-
Custom validation functions
- Function-based validation
- Multiple validation rules per field
- Conditional validation logic
- Cross-field validation
-
No validation mode
- Forms without any validation
- Schema-agnostic operation
- Pure state management
- Performance without validation
-
Error handling
- Error message format
- Multiple errors per field
- Error persistence
- Error clearing logic
Test Together: Programmatic validation
-
trigger() - validate all fields
- Returns promise with boolean result
- Validates all registered fields
- Updates formState.errors
- Updates formState.isValid
-
trigger(fieldName) - single field
- Validates only specified field
- Returns field-specific result
- Does not affect other fields
- Type safety with field names
-
trigger([fields]) - multiple fields
- Validates specified fields only
- Array of field names handling
- Partial validation results
- Type safety with field array
-
Async validation handling
- Promise resolution timing
- Loading states during validation
- Error handling for failed validation
- Concurrent validation calls
Test Together: State inspection methods
-
formState object access
- Real-time state updates
- Immutable state handling
- Reference stability
- Re-render triggers
-
hasErrors() method
- Returns true when errors exist
- Returns false when no errors
- Updates with validation changes
- Performance with large forms
-
getErrorCount() method
- Accurate error counting
- Updates with error changes
- Zero count handling
- Nested error counting
-
isFieldValid(name) method
- Field-specific validity check
- Returns inverse of error state
- Updates with field validation
- Non-existent field handling
Test Together: Change detection system
-
isDirty() - entire form
- Detects any form changes
- Initial state (not dirty)
- After value changes (dirty)
- After reset (not dirty)
-
isDirty(fieldName) - specific field
- Field-specific dirty detection
- Compares to initial value
- Deep equality checking
- Nested field support
-
isFieldDirty(name) method
- Alternative dirty check syntax
- Consistent with isDirty(fieldName)
- String field name parameter
- Type safety considerations
-
getDirtyFields() method
- Returns object of dirty fields
- Boolean values for dirty state
- Efficient dirty field tracking
- Large form performance
-
hasChanges() method
- Global change detection
- Alias for isDirty() check
- Navigation warning scenarios
- Form persistence decisions
-
getChanges() method
- Returns only modified fields
- Partial object with changes
- API PATCH request preparation
- Deep comparison accuracy
Test Together: User interaction tracking
-
isFieldTouched(name) method
- Tracks field focus/blur events
- Initial state (not touched)
- After blur event (touched)
- Persistent touched state
-
getTouchedFields() method
- Returns all touched fields
- Object with boolean values
- Touch state persistence
- Form submission interaction
-
markFieldTouched(name) method
- Programmatically mark as touched
- Show validation errors
- Custom interaction handling
- Bulk touch operations
-
markFieldUntouched(name) method
- Remove touched state
- Hide validation errors
- Reset field interaction
- Conditional touch states
-
markAllTouched() method
- Mark all fields as touched
- Pre-submission validation display
- Bulk state changes
- Performance with many fields
Test Together: Programmatic value control
-
setValue(path, value) method
- Single field value setting
- Nested path support (user.profile.name)
- Array index paths (items[0].name)
- Type conversion handling
-
setValues(values) method
- Multiple field value setting
- Partial object updates
- Nested object support
- Merge with existing values
-
Nested value handling
- Deep object structures
- Dot notation path parsing
- Array index notation
- Mixed nested/array paths
-
Value update side effects
- Dirty state updates
- Error clearing on change
- Re-render triggering
- Watch system notifications
Test Together: Error state control
-
setError(name, error) method
- Custom error setting
- Server-side error display
- Override validation errors
- Type-safe field names
-
clearErrors() method
- Clear all form errors
- Reset validation state
- Error-free form state
- Performance considerations
-
clearErrors(name) method
- Clear specific field error
- Selective error removal
- Field-level error control
- Partial error clearing
-
Error persistence logic
- When errors are cleared
- When errors persist
- Validation vs manual errors
- Error priority handling
Test Together: Form state reset functionality
-
reset() - basic reset
- Restore default values
- Clear all errors
- Clear touched state
- Reset dirty state
-
reset(options) - advanced reset
keepErrorsoption behaviorkeepTouchedoption behaviorkeepDirtyoption behavior- Option combinations
-
resetValues(values) method
- Reset with new default values
- Complete state clearing
- New baseline establishment
- Different from setValue
-
resetField(name) method
- Single field reset
- Field-specific state clearing
- Selective form reset
- Nested field reset
Test Together: Value observation system
-
watch() - all values
- Return complete form values
- Real-time value updates
- Object reference stability
- Performance with subscriptions
-
watch(fieldName) - specific field
- Single field value watching
- Type-safe field access
- Value change notifications
- Undefined field handling
-
watch([fields]) - multiple fields
- Array of field names
- Subset value watching
- Type-safe field arrays
- Performance optimization
-
Watch subscription behavior
- Re-render optimization
- Memory leak prevention
- Subscription cleanup
- Conditional watching
Test Together: Submission workflow
-
handleSubmit(onValid, onError)
- Form event handling
- Validation before submission
- Success callback execution
- Error callback execution
-
submit() - programmatic submission
- Direct form submission
- Requires onSubmit handler
- Validation integration
- Promise-based operation
-
submitAsync() - async submission
- Returns submission results
- Success/failure discrimination
- Data and error handling
- Type-safe result objects
-
canSubmit() method
- Submission readiness check
- Validation state consideration
- Loading state checking
- UI control integration
-
Submission state management
-
isSubmitting state tracking
-
Loading UI support
-
Submission prevention
-
Error state handling
-
Form event handling
-
Validation before submission
-
Success callback execution
-
Error callback execution
-
-
submit() - programmatic submission
- Direct form submission
- Requires onSubmit handler
- Validation integration
- Promise-based operation
-
submitAsync() - async submission
- Returns submission results
- Success/failure discrimination
- Data and error handling
- Type-safe result objects
-
canSubmit() method
- Submission readiness check
- Validation state consideration
- Loading state checking
- UI control integration
-
Submission state management
- isSubmitting state tracking
- Loading UI support
- Submission prevention
- Error state handling
Test Together: Dynamic array handling
-
addArrayItem(path, item)
- Add items to form arrays
- Nested array path support
- Dynamic list management
- Type preservation
-
removeArrayItem(path, index)
- Remove items by index
- Array bounds checking
- Index shifting handling
- State consistency
-
Array path handling
- Dot notation for arrays
- Bracket notation support
- Nested array structures
- Array within objects
-
Array dirty state tracking
- Array modification detection
- Item-level dirty tracking
- Efficient change detection
- Performance optimization
Test Together: Programmatic focus control
-
setFocus(name) method
- Programmatic field focusing
- DOM element targeting
- Focus event triggering
- Error field focusing
-
setFocus(name, options) method
shouldSelectoption behavior- Text selection on focus
- Focus with custom options
- Input type compatibility
-
Field reference management
- DOM element tracking
- Reference cleanup
- Dynamic field handling
- Memory management
Test Together: State backup and restore
-
getSnapshot() method
- Complete state capture
- Values, errors, touched state
- Timestamp generation
- Dirty state inclusion
-
restoreSnapshot(snapshot)
- State restoration
- Dirty state recalculation
- Timestamp validation
- Partial snapshot handling
-
Snapshot use cases
- Auto-save functionality
- Undo/redo implementation
- Form drafts
- State persistence
Test Together: Detailed field inspection
-
getFieldState(name) method
- Complete field state object
- isDirty, isTouched, error properties
- Field-level state access
- Non-existent field handling
-
Field state consistency
- State synchronization
- Cross-method consistency
- State update propagation
- Performance optimization
Test Together: Context-based form sharing
-
FormProvider component
- Form instance provision
- Child component access
- TypeScript generic preservation
- Multiple form support
-
useFormContext() hook
- Context access in components
- Type-safe form retrieval
- Error handling for missing context
- Nested provider support
-
useFormState() convenience hook
- Direct form instance access
- Simplified context usage
- Alternative to useFormContext
- Performance considerations
Test Together: Form component patterns
-
Context pattern integration
- Reusable field components
- Form state sharing
- Component composition
- Type safety preservation
-
Form passing pattern
- Explicit form prop passing
- Component testability
- Clear dependencies
- Prop-based form access
-
Hybrid pattern support
- Components working both ways
- Optional context usage
- Fallback mechanisms
- Flexible API design
Test Together: Performance characteristics
-
useCallback optimization
- Method memoization
- Dependency array accuracy
- Re-render prevention
- Performance measurement
-
Minimal re-renders
- State change isolation
- Component update optimization
- Unnecessary render prevention
- Large form performance
-
Efficient dirty tracking
- Set-based dirty field tracking
- O(1) dirty operations
- Memory usage optimization
- Comparison algorithm efficiency
-
Memory leak prevention
- Event listener cleanup
- Reference management
- Component unmounting
- Subscription cleanup
Test Together: Complex data structure handling
-
Nested object handling
- Deep object property access
- Dot notation parsing
- Immutable updates
- Type preservation
-
Array index notation
- Bracket notation support
- Index validation
- Dynamic array access
- Mixed notation support
-
Complex data validation
- Deep object validation
- Array item validation
- Nested structure support
- Performance with complexity
Test Together: Basic file input handling
-
register() function for file inputs
- Detects
type="file"automatically - Returns
filesproperty instead ofvalue - Handles single file selection
- Handles multiple file selection (
multipleattribute)
- Detects
-
File object access
- Returns
FileListobject for multiple files - Returns single
Fileobject for single files - Provides access to file properties (name, size, type, lastModified)
- Handles empty file selection (null/undefined)
- Returns
-
File state management
- File selection updates form state
- File removal clears form state
- File replacement updates existing selection
- Files persist through form operations
Test Together: File validation scenarios
-
File type validation
- Accept attribute validation
- MIME type checking
- File extension validation
- Custom file type validators
-
File size validation
- Maximum file size limits
- Minimum file size limits
- Total size limits for multiple files
- Human-readable size error messages
-
File count validation
- Maximum number of files
- Minimum number of files
- Single file enforcement
- Multiple file count limits
-
File content validation
- File reading for content validation
- Image dimension validation
- File header validation
- Async file content checks
Test Together: File manipulation methods
-
addFile(name, file) method
- Add file to existing selection
- Append to multiple file inputs
- Validate before adding
- Update form state correctly
-
removeFile(name, index) method
- Remove specific file by index
- Remove all files
- Update indices correctly
- Maintain file order
-
replaceFile(name, index, file) method
- Replace specific file
- Validate replacement file
- Maintain other files
- Update form state
-
clearFiles(name) method
- Clear all selected files
- Reset file input state
- Update form validation
- Trigger change events
Test Together: File display utilities
-
getFilePreview(file) utility
- Generate image previews
- Handle different file types
- Base64 data URL generation
- Preview cleanup on file removal
-
getFileInfo(file) utility
- Format file size display
- Extract file metadata
- File type categorization
- Upload progress tracking
-
File drag & drop support
- Drop zone integration
- Drag over visual feedback
- File type filtering on drop
- Multiple file drop handling
Test Together: Schema-based file validation
-
z.instanceof(File) validation
- Basic File type checking
- File refinements for size validation
- File refinements for type validation
- Custom error messages
-
Array of files validation
-
z.array(z.instanceof(File))support - Array refinements for file validation
- Min/max file count validation
- Mixed validation (files + other fields)
-
-
Progressive validation
- onChange validation with partial schemas
- onSubmit validation with full schemas
- Real-time error display
- Validation state management
Test Together: Upload workflow
-
File upload progress tracking
- Upload progress percentage
- Individual file progress
- Batch upload progress
- Error handling during upload
-
Upload state management
- isUploading state tracking
- Upload completion status
- Upload error states
- Retry upload functionality
-
File upload utilities
- FormData preparation
- Multipart form encoding
- Upload cancellation
- Upload resume support
Test Together: Robustness testing
-
Invalid field names
- Non-existent field handling
- Malformed path strings
- Empty field names
- Special character handling
-
Undefined/null values
- Null defaultValues handling
- Undefined field values
- Null validation results
- Empty object handling
-
Missing validation schema
- No schema provided
- Invalid schema objects
- Schema parsing errors
- Fallback behavior
-
Async validation errors
- Network failure handling
- Timeout scenarios
- Concurrent validation
- Error state management
-
Component lifecycle
- Unmounting during async operations
- Memory leak prevention
- State cleanup
- Event handler cleanup
Test Together: Real-world scenarios
-
Complete form workflows
- User registration forms
- Multi-step forms
- Complex validation scenarios
- Submission flows
-
Popular library integration
- Zod schema integration
- Yup schema integration
- React Hook Form migration
- Formik comparison
-
Performance under load
- Large form handling (100+ fields)
- Rapid user input
- Concurrent operations
- Memory usage monitoring
-
Real browser testing
- Cross-browser compatibility
- Mobile device testing
- Accessibility compliance
- Screen reader support
✅ Test Together (Same Test Suite):
- All core initialization features (1.1)
- All register() functionality (1.2)
- All validation timing scenarios (2.1)
- All state query methods (3.1)
- All dirty state methods (3.2)
- All touched state methods (3.3)
- Performance tests (separate test runner)
- Integration tests (require full setup)
- Async validation (timeout handling)
- Edge cases (error simulation)
-
🔴 Critical Path (Test First)
- Core Setup (1.1, 1.2)
- Basic Validation (2.1, 2.2)
- Form State (3.1, 3.2, 3.3)
-
🟡 High Priority (Test Second)
- Form Control (4.1, 4.2, 4.3)
- Advanced Features (5.1, 5.2)
- File Upload Support (9.1, 9.2, 9.3)
-
🟢 Medium Priority (Test Last)
- File Upload Utilities (9.4, 9.5)
- Context Integration (7.1, 7.2)
- Performance (8.1, 8.2)
- Edge Cases (10.1, 10.2)
// Common test form schemas
const simpleUserSchema = z.object({
name: z.string().min(1),
email: z.string().email(),
age: z.number().min(18),
});
const complexNestedSchema = z.object({
user: z.object({
profile: z.object({
name: z.string(),
settings: z.object({
notifications: z.boolean(),
}),
}),
}),
items: z.array(
z.object({
title: z.string(),
tags: z.array(z.string()),
})
),
});
// Default test values
const defaultValues = {
name: "",
email: "",
age: 18,
};✅ Feature Complete: All 100+ test cases passing
✅ Performance: < 16ms for typical operations
✅ Memory: No memory leaks in long-running forms
✅ TypeScript: 100% type coverage
✅ Compatibility: Works with React 16.8+ through 18+
✅ Integration: Works with popular validation libraries
This testing strategy ensures comprehensive coverage of all el-form-react-hooks features while optimizing testing efficiency through logical grouping and prioritization.