Skip to content

test: add tests for patient status and volunteer flows

Rushika Sritha Maddula requested to merge feature/tests-clean into develop

This MR adds and updates unit tests for critical user flows, specifically Patient Status and Volunteer Registration. The goal is to improve test coverage, ensure UI reliability, and prevent regressions in these workflows.


What does this MR do and why?

This MR focuses on strengthening the testing layer for important application features:

  • Patient status step handling and transitions
  • Volunteer registration form validation and submission flow

Motivation

  • Improve confidence during deployments
  • Detect regressions early
  • Ensure correct behavior across different UI states

Approach

  • Added structured test cases using existing testing utilities
  • Mocked component state where required
  • Covered key interaction and validation scenarios

Trade-offs

  • Some tests rely on mocked state (useState), which may require future refactoring for better maintainability

Changes Made

  • Added/updated test files:

    • tests/volunteers/PatientStatus.test.tsx
    • tests/pages/VolunteerRegisterPage.test.tsx
    • tests/admin/ManageDoctorsPage.test.tsx
  • Covered:

    • UI state transitions
    • Form input validation
    • Conditional rendering
    • User interaction flows

Technical Details

  • Fixed TypeScript compatibility issues in test files
  • Adjusted type assertions using unknown where required
  • Removed unsupported Node-specific APIs (e.g., node:vm, process) from frontend tests
  • Ensured tests align with strict TypeScript and ESLint rules

Type of Change

  • 🐛 Bug fix
  • New feature
  • 💥 Breaking change
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • ️ Refactor
  • Performance improvement
  • 🧪 Test update
  • 🔧 Configuration change
  • 🚨 Security fix

Related Issues / References

  • N/A

Screenshots or Screen Recordings

Not applicable (test updates only)


How to Set Up and Validate Locally

  1. Checkout this branch:

    git checkout feature/tests-clean
  2. Install dependencies:

    bun install
  3. Run the development server:

    bun dev
  4. Run tests:

    bun test
  5. Expected behavior:

    • All test cases should pass
    • No TypeScript or ESLint errors

Testing Done

  • Manual testing completed
  • Unit tests added/updated

Test Cases Covered:

Scenario Expected Result Status
Patient status transitions Correct step progression
Volunteer registration form Proper validation and submission
Manage doctors interactions Correct UI updates and state handling

Code Quality Checklist

Code Standards

  • Code follows project conventions
  • No console logs or debug statements
  • No unused imports or variables
  • No duplicate code
  • TypeScript types handled correctly
  • ESLint and Prettier checks pass

React Best Practices

  • Components follow single responsibility
  • Hooks used correctly
  • State handling appropriate
  • No unnecessary re-renders

Documentation

  • README.md updated
  • .env.example updated
  • CHANGELOG.md updated

Known Limitations / Technical Debt

  • Some test cases rely on mocked useState, which may need improvement for long-term maintainability

Merge request reports

Loading