fix: prevent auto tab switch and sort searched patient first
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
onClickhandler for the header's back button to usenavigate('/?role=volunteer').
Technical Details
-
Root Cause: The unit test
tests/volunteers/RecordVitalsPage.test.tsxcontains an assertionexpect(mockNavigate).toHaveBeenCalledWith('/?role=volunteer'). The component was instead callingnavigate(-1), resulting in anAssertionError. -
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
How to Set Up and Validate Locally
- Pull this branch.
- Run the specific test file to verify the fix:
npm run test:run tests/volunteers/RecordVitalsPage.test.tsx - 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

