Skip to content

test: cover uncovered lines for patient components

Lakshmi pavani Challa requested to merge uncovered-lines-solving into develop

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.tsx
    • PreviousCampPrescriptionsCard.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

  1. Checkout the branch:
git checkout uncovered-lines-solving
  1. Install dependencies:
bun install
  1. Run tests:
bun test
  1. 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

image

After Screenshot

image

Edited by Ahlad Pataparla

Merge request reports

Loading