test: added test cases for MediaTypeWheel and MediaUploadComponent
Description:
Added comprehensive unit test coverage for MediaTypeWheel.tsx and MediaUploadComponent.tsx to improve reliability and maintainability of the application.
Created two new test files under tests/src/components/ with a total of 105 test cases:
-
MediaTypeWheel.test.tsx(39 tests) covering rendering, selection behavior, callbacks, visual elements, accessibility, and edge cases. -
MediaUploadComponent.test.tsx(66 tests) covering all upload modes (document, text, audio, video, image), user interactions, conditional UI states, file handling, and edge scenarios.
Achieved:
- 100% statement coverage
- 100% line coverage
- ~99% branch coverage
The minor uncovered branch in MediaTypeWheel is due to a mathematically unreachable condition based on component design and does not indicate a testing gap.
Implemented robust testing patterns including:
- Mocking external dependencies (
react-i18next,lucide-react, UI components, utilities, toast notifications) - Simulating user events (clicks, input changes, uploads)
- Verifying callbacks using
vi.fn() - Testing conditional rendering for different modes and states (recording, camera active, file selected, etc.)
- Handling edge cases such as null values, empty inputs, missing callbacks, and invalid files
Additionally:
- Updated
vitest.config.tsto include@path alias for proper module resolution in tests - Fixed all ESLint issues (e.g., using
const, handling intentionalany) - Ensured all tests pass successfully with no warnings or errors
Commands used:
npm run test:run -- tests/src/components/npm run test:coveragenpm run lint -- tests/src/components/*.test.tsx
This significantly improves test coverage, reduces regression risk, and ensures confidence during future code changes.
Type of Change:
-
Bug Fix -
Feature Development -
Documentation
Testing:
-
Tested on desktop -
Tested on mobile -
Tested in different browsers
Checklist:
-
Code follows project style guidelines -
Self-review completed -
No console errors -
TypeScript types are correct
closes #249 (closed)
