Skip to content

Add test coverage for controlled FileInput component#569

Merged
stdavis merged 4 commits intofeat/controlled-file-inputfrom
copilot/sub-pr-568
Dec 5, 2025
Merged

Add test coverage for controlled FileInput component#569
stdavis merged 4 commits intofeat/controlled-file-inputfrom
copilot/sub-pr-568

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 5, 2025

Addresses review feedback requesting automated tests for the controlled/uncontrolled behavior in FileInput.

Tests added

  • Controlled mode: value prop controls displayed files, onChange called but display unchanged until parent updates value
  • Uncontrolled mode: internal state manages files, display updates immediately on selection
  • onChange callback: invoked with File[] | null on selection/clear/removal
  • Mode detection: value={null} is controlled, value={undefined} is uncontrolled

Fixes in this PR

  • Fixed TypeScript error: unused size parameter renamed to _size
  • Fixed TypeScript error: added null check for array access removeButtons[0]
  • Fixed TypeScript error: added optional chaining for onChange.mock.calls[0]?.[0]
  • Ran Prettier to fix formatting issues

15 tests total, all passing.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 5, 2025 18:35
Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.com>
Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on controlled file input implementation Add test coverage for controlled FileInput component Dec 5, 2025
Copilot AI requested a review from stdavis December 5, 2025 18:39
@stdavis stdavis marked this pull request as ready for review December 5, 2025 18:42
Copilot AI review requested due to automatic review settings December 5, 2025 18:42
Copy link
Copy Markdown
Contributor

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

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.

@stdavis
Copy link
Copy Markdown
Member

stdavis commented Dec 5, 2025

@copilot It looks like you have some linting errors. Please fix them. You can lint by running npm run lint.

Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 5, 2025

@copilot It looks like you have some linting errors. Please fix them. You can lint by running npm run lint.

Fixed in 11f9d68. The TypeScript errors were:

  • Unused size parameter (renamed to _size)
  • Missing null check on array index access
  • Missing optional chaining on mock calls access

Also ran Prettier to fix formatting. All lint, type checks, and tests pass now.

Copilot AI requested a review from stdavis December 5, 2025 18:52
@stdavis stdavis merged commit ca04bd9 into feat/controlled-file-input Dec 5, 2025
6 of 7 checks passed
@stdavis stdavis deleted the copilot/sub-pr-568 branch December 5, 2025 18:54
stdavis added a commit that referenced this pull request Dec 5, 2025
#569)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.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.

3 participants