Skip to content

fix: prevent auto tab switch and sort searched patient first

Suma Pullaiahgari requested to merge fix/queue-search-duplicate into develop

Fix Record Vitals Back Button Navigation

Overview

This MR fixes a navigation inconsistency in the RecordVitalsPage where the back button in the header was using navigate(-1) instead of returning to the volunteer dashboard. This change resolves a failure in the unit test suite.

What does this MR do and why?

The RecordVitalsPage back button was previously using navigate(-1), which led to a test failure because the test suite explicitly expects the application to navigate back to the volunteer dashboard (/?role=volunteer). By explicitly setting the navigation target, we ensure a consistent user experience regardless of the navigation history and maintain compatibility with the existing test assertions.

Changes Made

  • Modified RecordVitalsPage.tsx: Updated the onClick handler for the header's back button to use navigate('/?role=volunteer').

Technical Details

  • Root Cause: The unit test tests/volunteers/RecordVitalsPage.test.tsx contains an assertion expect(mockNavigate).toHaveBeenCalledWith('/?role=volunteer'). The component was instead calling navigate(-1), resulting in an AssertionError.
  • Fix: Changed the navigation logic to match the expected behavior defined in the test and used by other similar volunteer pages (e.g., PatientRegistrationPage.tsx).

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • ️ Refactor (no functional changes)
  • Performance improvement
  • 🧪 Test update
  • 🔧 Configuration change
  • 🚨 Security fix

Related Issues / References

  • Fixes test failures reported in tests/volunteers/RecordVitalsPage.test.tsx.

Screenshots or Screen Recordings

before image after image

How to Set Up and Validate Locally

  1. Pull this branch.
  2. Run the specific test file to verify the fix:
    npm run test:run tests/volunteers/RecordVitalsPage.test.tsx
  3. Run the full test suite to ensure no regressions:
    npm run test:run

Testing Done

  • Manual testing completed (Verified via Vitest)
  • Unit tests updated/verified

Test Cases Covered:

Scenario Expected Result Status
Click back button in Record Vitals header Navigates to /?role=volunteer
Run all vitals page tests All 35 tests pass

Code Quality Checklist

Code Standards

  • Code follows project conventions
  • No console.log() or debugger statements left in code
  • No unused imports, variables, or functions
  • ESLint and Prettier checks pass

API & Data Fetching

  • Loading and error states handled in the page

Error Handling

  • Network failures handled appropriately in the page mutation logic

MR Acceptance Checklist

Edited by Suma Pullaiahgari

Merge request reports

Loading