test: cover uncovered lines for patient components
Overview
Adds targeted unit tests for PatientStatusTracker.tsx and PreviousCampPrescriptionsCard.tsx to achieve 100% test coverage. This improves reliability and reduces regression risk.
What does this MR do and why?
Existing tests did not cover all execution paths in these components. Missing areas included conditional rendering, fallback states, and edge cases.
This MR closes those gaps by adding focused tests to ensure all logic branches are executed and validated.
Approach
- Identified uncovered lines using coverage reports
- Added targeted tests for missing branches and conditions
- Avoided redundant or duplicate test cases
Trade-off
- Slight increase in test size, with improved confidence and maintainability
Changes Made
-
Updated test files for:
PatientStatusTracker.tsxPreviousCampPrescriptionsCard.tsx
-
Achieved 100% test coverage for both components:
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
PatientStatusTracker.tsx | 100 | 100 | 100 | 100 | None
PreviousCampPrescriptionsCard.tsx | 100 | 100 | 100 | 100 | None
-
Coverage now includes:
- Conditional rendering paths
- Empty and fallback states
- Edge cases
- Data-driven UI variations
Technical Details
- Scope: Tests only, no changes to component logic
- Validation: Ensures all branches and conditions are executed
- Impact: No functional or UI changes
Type of Change
-
🧪 Test update
How to Set Up and Validate Locally
- Checkout the branch:
git checkout uncovered-lines-solving
- Install dependencies:
bun install
- Run tests:
bun test
- Check coverage:
bun run coverage
Expected Behavior
- 100% coverage for both components
- All tests passing
Testing Done
-
Unit tests added/updated
Test Cases Covered
| Scenario | Expected Result | Status |
|---|---|---|
| Render with data | UI displays correctly | |
| Empty state | Fallback UI shown | |
| Conditional branches | Correct paths executed | |
| Edge cases | No crashes |
Code Quality Checklist
Code Standards
-
Follows project conventions -
No console.log or unused code -
No duplication -
Proper TypeScript usage -
ESLint and Prettier checks pass
React Best Practices
-
Hooks used correctly -
No unnecessary re-renders
Component Patterns
-
No structural changes -
No UI changes introduced
API & Data Fetching
-
Not applicable
Error Handling
-
Edge cases covered via tests -
No runtime errors
Additional Notes
- No changes made to component implementation
- Focus strictly on improving test coverage
- No breaking changes introduced
screenshot
Before Screenshot
After Screenshot
Edited by Ahlad Pataparla

