Add test coverage for controlled FileInput component#569
Add test coverage for controlled FileInput component#569stdavis merged 4 commits intofeat/controlled-file-inputfrom
Conversation
Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.com>
Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive automated test coverage for the FileInput component's controlled and uncontrolled behavior patterns. The tests validate that the component correctly implements the controlled/uncontrolled paradigm where value={undefined} enables uncontrolled mode with internal state management, while value={null} or value={[...]} enables controlled mode where the parent component manages state.
- 15 new test cases covering controlled mode, uncontrolled mode, and onChange callbacks
- Tests verify that controlled components don't update internal state until parent updates value prop
- Validates proper mode detection based on whether the value prop is defined
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/utah-design-system/src/components/FileInput.test.tsx | New test file with comprehensive coverage of controlled/uncontrolled behavior, file selection, clearing, and removal operations |
| package-lock.json | Automatic dependency resolution updates (peer dependency flag adjustments) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot It looks like you have some linting errors. Please fix them. You can lint by running |
Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.com>
Fixed in
Also ran Prettier to fix formatting. All lint, type checks, and tests pass now. |
#569) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.com>
Addresses review feedback requesting automated tests for the controlled/uncontrolled behavior in
FileInput.Tests added
File[] | nullon selection/clear/removalvalue={null}is controlled,value={undefined}is uncontrolledFixes in this PR
sizeparameter renamed to_sizeremoveButtons[0]onChange.mock.calls[0]?.[0]15 tests total, all passing.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.